From 51e5bfad4448208300486f7d1a70bb95da1b2c8c Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 15:48:57 +0800 Subject: [PATCH 01/14] feat: add musl build --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53c3c683..9f443906 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,3 +188,38 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true + + musl: + name: Build and Test (musl) + runs-on: ubuntu-latest + env: + CARGO_BUILD_TARGET: x86_64-unknown-linux-musl + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Rust + run: rustup target add $CARGO_BUILD_TARGET + - name: Build + run: | + cargo build --package maa-cli --locked \ + --features vendored-openssl + - name: Install MaaCore + env: + MAA_CONFIG_DIR: ${{ github.workspace }}/maa-cli/config_examples + run: | + cargo run -- install stable + ls -l "$(cargo run -- dir library)" + ls -l "$(cargo run -- dir resource)" + ls -l "$(cargo run -- dir cache)" + package_name=$(basename "$(ls "$(cargo run -- dir cache)")") + echo "Downloaded MaaCore package: $package_name" + version=${package_name#MAA-v} + version=${version%%-*} + if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Downloaded MaaCore version: $version" + echo "MAA_CORE_VERSION=v$version" >> "$GITHUB_ENV" + fi + echo "MAA_CORE_INSTALLED=true" >> "$GITHUB_ENV" + - name: Test + run: | + cargo test -- --include-ignored From 351b95f8766cab835ffc64a62293ec7a5c058ce5 Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 15:58:02 +0800 Subject: [PATCH 02/14] fix: install musl-gcc and musl-tools in CI --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f443906..b82480ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -198,7 +198,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Setup Rust - run: rustup target add $CARGO_BUILD_TARGET + run: rustup target add "$CARGO_BUILD_TARGET" + - name: Setup MUSL + run: | + sudo apt-get update + sudo apt-get install -y musl-tools - name: Build run: | cargo build --package maa-cli --locked \ From 5f84e5fe15da9175628ae4b98575f3bb7cf7ba26 Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 16:07:39 +0800 Subject: [PATCH 03/14] fix: use maa binary from target directory in CI --- .github/workflows/ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b82480ad..7efdec63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -211,11 +211,12 @@ jobs: env: MAA_CONFIG_DIR: ${{ github.workspace }}/maa-cli/config_examples run: | - cargo run -- install stable - ls -l "$(cargo run -- dir library)" - ls -l "$(cargo run -- dir resource)" - ls -l "$(cargo run -- dir cache)" - package_name=$(basename "$(ls "$(cargo run -- dir cache)")") + maa=target/"$CARGO_BUILD_TARGET"/debug/maa + $maa install stable + ls -l "$($maa dir library)" + ls -l "$($maa dir resource)" + ls -l "$($maa dir cache)" + package_name=$(basename "$(ls "$($maa dir cache)")") echo "Downloaded MaaCore package: $package_name" version=${package_name#MAA-v} version=${version%%-*} From b8dfb25253afc346d7437271359b3f44b057fc36 Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 16:12:12 +0800 Subject: [PATCH 04/14] fix --- .github/workflows/ci.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7efdec63..e88f61cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,9 +96,8 @@ jobs: os: ${{ matrix.os }} target_arch: aarch64 - name: Build - run: | - cargo build --package maa-cli --locked \ - --features vendored-openssl + run: > + cargo build --package maa-cli --locked --features vendored-openssl build-feature: name: Build and Test (no default features) @@ -204,9 +203,8 @@ jobs: sudo apt-get update sudo apt-get install -y musl-tools - name: Build - run: | - cargo build --package maa-cli --locked \ - --features vendored-openssl + run: > + cargo build --package maa-cli --locked --features vendored-openssl - name: Install MaaCore env: MAA_CONFIG_DIR: ${{ github.workspace }}/maa-cli/config_examples @@ -226,5 +224,6 @@ jobs: fi echo "MAA_CORE_INSTALLED=true" >> "$GITHUB_ENV" - name: Test - run: | - cargo test -- --include-ignored + run: > + cargo test --package maa-cli --locked --features vendored-openssl + -- --include-ignored From 0eaf0955592bcd21fba2d1737ee2a8f7a1640e34 Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 16:32:14 +0800 Subject: [PATCH 05/14] ci: run musl build in a rust:1-alpine container --- .github/workflows/ci.yml | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e88f61cb..ff6c9b99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -191,38 +191,21 @@ jobs: musl: name: Build and Test (musl) runs-on: ubuntu-latest + container: + image: rust:1-alpine env: CARGO_BUILD_TARGET: x86_64-unknown-linux-musl + defaults: + run: + shell: sh steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Rust run: rustup target add "$CARGO_BUILD_TARGET" - - name: Setup MUSL - run: | - sudo apt-get update - sudo apt-get install -y musl-tools - name: Build run: > cargo build --package maa-cli --locked --features vendored-openssl - - name: Install MaaCore - env: - MAA_CONFIG_DIR: ${{ github.workspace }}/maa-cli/config_examples - run: | - maa=target/"$CARGO_BUILD_TARGET"/debug/maa - $maa install stable - ls -l "$($maa dir library)" - ls -l "$($maa dir resource)" - ls -l "$($maa dir cache)" - package_name=$(basename "$(ls "$($maa dir cache)")") - echo "Downloaded MaaCore package: $package_name" - version=${package_name#MAA-v} - version=${version%%-*} - if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Downloaded MaaCore version: $version" - echo "MAA_CORE_VERSION=v$version" >> "$GITHUB_ENV" - fi - echo "MAA_CORE_INSTALLED=true" >> "$GITHUB_ENV" - name: Test run: > cargo test --package maa-cli --locked --features vendored-openssl From c3f070d2c910f786d76b6f6bdc269f7216431838 Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 16:59:14 +0800 Subject: [PATCH 06/14] fix --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff6c9b99..3ba426ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -201,8 +201,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup Rust - run: rustup target add "$CARGO_BUILD_TARGET" + - name: Setup Toolchain + run: | + apk add --no-cache perl make - name: Build run: > cargo build --package maa-cli --locked --features vendored-openssl From eec246b50e09bc52ea53a50b2051c850a6e9ee71 Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 17:01:41 +0800 Subject: [PATCH 07/14] fix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ba426ba..e70835a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -203,7 +203,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Toolchain run: | - apk add --no-cache perl make + apk add --no-cache perl make musl-dev - name: Build run: > cargo build --package maa-cli --locked --features vendored-openssl From 17d739bba8772fe5dddfd5aafcb34d1e401a32be Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 17:05:42 +0800 Subject: [PATCH 08/14] fix --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e70835a4..230bb0af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,8 +96,9 @@ jobs: os: ${{ matrix.os }} target_arch: aarch64 - name: Build - run: > - cargo build --package maa-cli --locked --features vendored-openssl + run: | + cargo build --package maa-cli --locked \ + --features vendored-openssl build-feature: name: Build and Test (no default features) @@ -203,11 +204,10 @@ jobs: uses: actions/checkout@v4 - name: Setup Toolchain run: | - apk add --no-cache perl make musl-dev + apk add musl-dev openssl-dev - name: Build - run: > - cargo build --package maa-cli --locked --features vendored-openssl + run: | + cargo build --package maa-cli --locked - name: Test - run: > - cargo test --package maa-cli --locked --features vendored-openssl - -- --include-ignored + run: | + cargo test --package maa-cli --locked -- --include-ignored From d1754bc025b757efee885a42e54f6eab1e252c19 Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 17:15:53 +0800 Subject: [PATCH 09/14] fix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 230bb0af..2861acb2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -204,7 +204,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Toolchain run: | - apk add musl-dev openssl-dev + apk add musl-dev openssl openssl-dev - name: Build run: | cargo build --package maa-cli --locked From 9c6ee5cce73d0b2232d04c26d589952c39f2ae40 Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 17:22:05 +0800 Subject: [PATCH 10/14] fix --- .github/workflows/ci.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2861acb2..0427f3b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -204,10 +204,13 @@ jobs: uses: actions/checkout@v4 - name: Setup Toolchain run: | - apk add musl-dev openssl openssl-dev + apk add perl make musl-dev - name: Build run: | - cargo build --package maa-cli --locked + cargo build --package maa-cli --locked \ + --features vendored-openssl - name: Test run: | - cargo test --package maa-cli --locked -- --include-ignored + cargo test --package maa-cli --locked \ + --features vendored-openssl + -- --include-ignored From 5fe9b91926def8625924278323811f0528a62389 Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 17:27:15 +0800 Subject: [PATCH 11/14] fix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0427f3b3..970f1304 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -212,5 +212,5 @@ jobs: - name: Test run: | cargo test --package maa-cli --locked \ - --features vendored-openssl + --features vendored-openssl \ -- --include-ignored From fb082dc2d780f821d40cbf92a5620be23914f471 Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 17:36:12 +0800 Subject: [PATCH 12/14] try to install MaaCore --- .github/workflows/ci.yml | 24 ++++++++++++++++++++---- maa-cli/src/run/mod.rs | 7 +++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 970f1304..f0fa07e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -196,19 +196,35 @@ jobs: image: rust:1-alpine env: CARGO_BUILD_TARGET: x86_64-unknown-linux-musl - defaults: - run: - shell: sh steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Toolchain + shell: sh run: | - apk add perl make musl-dev + apk add perl make musl-dev bash - name: Build run: | cargo build --package maa-cli --locked \ --features vendored-openssl + - name: Install MaaCore + env: + MAA_CONFIG_DIR: ${{ github.workspace }}/maa-cli/config_examples + run: | + maa=target/"$CARGO_BUILD_TARGET"/release/maa-cli + $maa install stable + ls -l "$($maa dir library)" + ls -l "$($maa dir resource)" + ls -l "$($maa dir cache)" + package_name=$(basename "$(ls "$($maa dir cache)")") + echo "Downloaded MaaCore package: $package_name" + version=${package_name#MAA-v} + version=${version%%-*} + if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Downloaded MaaCore version: $version" + echo "MAA_CORE_VERSION=v$version" >> "$GITHUB_ENV" + fi + echo "MAA_CORE_INSTALLED=true" >> "$GITHUB_ENV" - name: Test run: | cargo test --package maa-cli --locked \ diff --git a/maa-cli/src/run/mod.rs b/maa-cli/src/run/mod.rs index d533908e..63186c20 100644 --- a/maa-cli/src/run/mod.rs +++ b/maa-cli/src/run/mod.rs @@ -309,8 +309,11 @@ mod tests { #[test] fn version() { - if let Some(version) = env::var_os("MAA_CORE_VERSION") { - assert_eq!(core_version().unwrap(), version); + if env::var_os("MAA_CORE_INSTALLED").is_some() { + let version = core_version().unwrap(); + if let Some(expect) = env::var_os("MAA_CORE_VERSION") { + assert_eq!(version, expect); + } } } From d4071e1f6447587aac9a053c0a1b948ff9c0f7d6 Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 17:46:16 +0800 Subject: [PATCH 13/14] fix --- .github/workflows/ci.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0fa07e6..9ae74e1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -211,19 +211,7 @@ jobs: env: MAA_CONFIG_DIR: ${{ github.workspace }}/maa-cli/config_examples run: | - maa=target/"$CARGO_BUILD_TARGET"/release/maa-cli - $maa install stable - ls -l "$($maa dir library)" - ls -l "$($maa dir resource)" - ls -l "$($maa dir cache)" - package_name=$(basename "$(ls "$($maa dir cache)")") - echo "Downloaded MaaCore package: $package_name" - version=${package_name#MAA-v} - version=${version%%-*} - if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Downloaded MaaCore version: $version" - echo "MAA_CORE_VERSION=v$version" >> "$GITHUB_ENV" - fi + cargo run -- install stable --features vendored-openssl echo "MAA_CORE_INSTALLED=true" >> "$GITHUB_ENV" - name: Test run: | From ed5b7dcaa1916cb9f3b8142a5a2936a92d0c23f8 Mon Sep 17 00:00:00 2001 From: Loong Date: Thu, 11 Apr 2024 17:57:46 +0800 Subject: [PATCH 14/14] fix --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ae74e1d..299c788d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -211,7 +211,9 @@ jobs: env: MAA_CONFIG_DIR: ${{ github.workspace }}/maa-cli/config_examples run: | - cargo run -- install stable --features vendored-openssl + cargo run \ + --features vendored-openssl \ + -- install stable echo "MAA_CORE_INSTALLED=true" >> "$GITHUB_ENV" - name: Test run: |