From ecea6f877d366dd0dcbe5cb30dd78a22da5488fb Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 15 Jul 2023 03:08:15 +0800 Subject: [PATCH 1/4] Improve CI --- .github/workflows/checks.yml | 24 ++++++++++-------------- .github/workflows/release.yml | 29 ++++++++++++++--------------- .github/workflows/staging.yml | 9 ++++----- Cargo.toml | 8 ++++++++ README.md | 2 +- 5 files changed, 37 insertions(+), 35 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 9d9f6a3..bb6308e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -8,10 +8,11 @@ on: - main env: - CARGO_INCREMENTAL: 1 + CACHE_VERSION: 0 + + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse CARGO_TERM_COLOR: always - GITHUB_CACHE_VERSION: 1 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RUST_BACKTRACE: full @@ -24,17 +25,13 @@ jobs: matrix: action: [clippy, fmt, nextest] steps: + - name: Setup build environment + run: rustup toolchain install nightly --profile minimal - name: Fetch latest code uses: actions/checkout@v3 - - name: Cache cargo - uses: actions/cache@v3 + - uses: Swatinem/rust-cache@v2 with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: cargo-${{ env.GITHUB_CACHE_VERSION }}-${{ matrix.action }}-${{ hashFiles('**/Cargo.lock') }} - restore-keys: cargo-${{ env.GITHUB_CACHE_VERSION }}-${{ matrix.action }}- + prefix-key: ${{ env.CACHE_VERSION }} - name: Cargo ${{ matrix.action }} if: matrix.action == 'clippy' uses: actions-rs/clippy-check@v1 @@ -43,14 +40,13 @@ jobs: args: --workspace --all-features --all-targets --locked - name: Cargo ${{ matrix.action }} if: matrix.action == 'fmt' - run: cargo ${{ matrix.action }} --all -- --check + run: cargo fmt --all -- --check - name: Install cargo-nextest if: matrix.action == 'nextest' uses: taiki-e/install-action@nextest - - name: Cargo ${{ matrix.action }} + - name: Cargo nextest if: matrix.action == 'nextest' - # Skip `node-test` feature. - run: cargo ${{ matrix.action }} run --release --workspace --all-targets --locked + run: cargo nextest run --cargo-profile ci-dev --workspace --all-features --all-targets --locked - name: Fast fail uses: vishnudxb/cancel-workflow@v1.2 if: failure() diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 04bcafb..56b957b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,6 @@ jobs: [ { name: x86_64-unknown-linux-gnu, os: ubuntu-latest }, { name: aarch64-apple-darwin, os: macos-latest }, - { name: x86_64-apple-darwin, os: macos-latest }, { name: x86_64-pc-windows-msvc, os: windows-latest, @@ -30,15 +29,15 @@ jobs: - name: Setup Rust toolchain run: rustup target add ${{ matrix.target.name }} - name: Build - run: cargo build --release --locked --target ${{ matrix.target.name }} + run: cargo build --profile ci-release --locked --target ${{ matrix.target.name }} - name: Compress run: | - mv target/${{ matrix.target.name }}/release/slothunter${{ matrix.target.extension }} . - zstd --ultra -22 -o slothunter-${{ matrix.target.name }}.zst slothunter${{ matrix.target.extension }} + mv target/${{ matrix.target.name }}/ci-release/${{ matrix.target.extension }} . + zstd --ultra -22 -o -${{ matrix.target.name }}.zst ${{ matrix.target.extension }} - name: Collect artifact run: | mkdir -p artifacts - mv slothunter-${{ matrix.target.name }}.zst artifacts + mv -${{ matrix.target.name }}.zst artifacts - name: Upload artifact uses: actions/upload-artifact@v3.1.2 with: @@ -69,16 +68,16 @@ jobs: generate_release_notes: true files: artifacts/* - publish-on-crates-io: - name: Publish on crates.io - runs-on: ubuntu-latest - steps: - - name: Fetch latest code - uses: actions/checkout@v3 - - name: Login - run: cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }} - - name: Publish - run: cargo publish --locked + # publish-on-crates-io: + # name: Publish on crates.io + # runs-on: ubuntu-latest + # steps: + # - name: Fetch latest code + # uses: actions/checkout@v3 + # - name: Login + # run: cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }} + # - name: Publish + # run: .maintain/release.sh clean-artifacts: name: Clean artifacts diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 71e04a8..17bb458 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -15,7 +15,6 @@ jobs: [ { name: x86_64-unknown-linux-gnu, os: ubuntu-latest }, { name: aarch64-apple-darwin, os: macos-latest }, - { name: x86_64-apple-darwin, os: macos-latest }, { name: x86_64-pc-windows-msvc, os: windows-latest, @@ -28,15 +27,15 @@ jobs: - name: Setup Rust toolchain run: rustup target add ${{ matrix.target.name }} - name: Build - run: cargo build --release --locked --target ${{ matrix.target.name }} + run: cargo build --profile ci-release --locked --target ${{ matrix.target.name }} - name: Compress run: | - mv target/${{ matrix.target.name }}/release/slothunter${{ matrix.target.extension }} . - zstd --ultra -22 -o slothunter-${{ matrix.target.name }}.zst slothunter${{ matrix.target.extension }} + mv target/${{ matrix.target.name }}/ci-release/${{ matrix.target.extension }} . + zstd --ultra -22 -o -${{ matrix.target.name }}.zst ${{ matrix.target.extension }} - name: Collect artifact run: | mkdir -p artifacts - mv slothunter-${{ matrix.target.name }}.zst artifacts + mv -${{ matrix.target.name }}.zst artifacts - name: Upload artifact uses: actions/upload-artifact@v3.1.2 with: diff --git a/Cargo.toml b/Cargo.toml index 50c7d25..c035501 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,14 @@ readme = "README.md" repository = "https://github.com/hack-ink/slothunter" version = "0.1.5" +[profile.ci-dev] +incremental = false +inherits = "dev" + +[profile.ci-release] +inherits = "release" +lto = true + [features] node-test = [] diff --git a/README.md b/README.md index 4492288..b7e4674 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ For more details, please refer to [guide.md](test/guide.md).
![crab](pic/crab.png) -As shown in the picture, Slothunter promptly placed their bid immediately after other competitors. +*As shown in the picture, Slothunter promptly placed their bid immediately after other competitors.*
From 6f352c3629e6d626c2344ca3eb4c6e0d50980311 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 15 Jul 2023 03:12:46 +0800 Subject: [PATCH 2/4] Use name --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index bb6308e..26b5127 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -32,13 +32,13 @@ jobs: - uses: Swatinem/rust-cache@v2 with: prefix-key: ${{ env.CACHE_VERSION }} - - name: Cargo ${{ matrix.action }} + - name: Cargo clippy if: matrix.action == 'clippy' uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} args: --workspace --all-features --all-targets --locked - - name: Cargo ${{ matrix.action }} + - name: Cargo fmt if: matrix.action == 'fmt' run: cargo fmt --all -- --check - name: Install cargo-nextest From 211ffdddc08aee2ab2f05a6dd531e724992d9849 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 15 Jul 2023 03:15:16 +0800 Subject: [PATCH 3/4] Improve --- .github/workflows/checks.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 26b5127..b4076d8 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -46,7 +46,9 @@ jobs: uses: taiki-e/install-action@nextest - name: Cargo nextest if: matrix.action == 'nextest' - run: cargo nextest run --cargo-profile ci-dev --workspace --all-features --all-targets --locked + # Ignore feature `node-test` + # run: cargo nextest run --cargo-profile ci-dev --workspace --all-features --all-targets --locked + run: cargo nextest run --cargo-profile ci-dev --workspace --all-targets --locked - name: Fast fail uses: vishnudxb/cancel-workflow@v1.2 if: failure() From e3d545373dc07f7f7b76518af8b3ba8c41e2a763 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 15 Jul 2023 03:20:13 +0800 Subject: [PATCH 4/4] Name --- .github/workflows/release.yml | 6 +++--- .github/workflows/staging.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 56b957b..3315860 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,12 +32,12 @@ jobs: run: cargo build --profile ci-release --locked --target ${{ matrix.target.name }} - name: Compress run: | - mv target/${{ matrix.target.name }}/ci-release/${{ matrix.target.extension }} . - zstd --ultra -22 -o -${{ matrix.target.name }}.zst ${{ matrix.target.extension }} + mv target/${{ matrix.target.name }}/ci-release/slothunter${{ matrix.target.extension }} . + zstd --ultra -22 -o slothunter-${{ matrix.target.name }}.zst slothunter${{ matrix.target.extension }} - name: Collect artifact run: | mkdir -p artifacts - mv -${{ matrix.target.name }}.zst artifacts + mv slothunter-${{ matrix.target.name }}.zst artifacts - name: Upload artifact uses: actions/upload-artifact@v3.1.2 with: diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 17bb458..210fc1f 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -30,12 +30,12 @@ jobs: run: cargo build --profile ci-release --locked --target ${{ matrix.target.name }} - name: Compress run: | - mv target/${{ matrix.target.name }}/ci-release/${{ matrix.target.extension }} . - zstd --ultra -22 -o -${{ matrix.target.name }}.zst ${{ matrix.target.extension }} + mv target/${{ matrix.target.name }}/ci-release/slothunter${{ matrix.target.extension }} . + zstd --ultra -22 -o slothunter-${{ matrix.target.name }}.zst slothunter${{ matrix.target.extension }} - name: Collect artifact run: | mkdir -p artifacts - mv -${{ matrix.target.name }}.zst artifacts + mv slothunter-${{ matrix.target.name }}.zst artifacts - name: Upload artifact uses: actions/upload-artifact@v3.1.2 with: