From 14662ef726926ff08eb8f687363fa90feebcb157 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Wed, 13 Sep 2023 10:18:09 +0100 Subject: [PATCH] chore(ci): switch to using `Swatinem/rust-cache` action (#2671) --- .github/workflows/formatting.yml | 27 ++++------------- .github/workflows/publish.yml | 50 ++++++++------------------------ .github/workflows/test.yml | 27 ++++------------- .github/workflows/wasm.yml | 26 ++++------------- README.md | 1 - 5 files changed, 30 insertions(+), 101 deletions(-) diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index 69bfe8d7ecf..8d29886e40c 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -17,13 +17,6 @@ jobs: name: cargo clippy runs-on: ${{ matrix.runner }} timeout-minutes: 30 - env: - CACHED_PATHS: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ strategy: fail-fast: false @@ -36,13 +29,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Restore cargo cache - uses: actions/cache/restore@v3 - id: cache - with: - path: ${{ env.CACHED_PATHS }} - key: ${{ matrix.target }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} - - name: Setup toolchain uses: dtolnay/rust-toolchain@master with: @@ -50,15 +36,14 @@ jobs: targets: ${{ matrix.target }} components: clippy, rustfmt + - uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} + cache-on-failure: true + save-if: ${{ github.event_name != 'merge_group' }} + - name: Run `cargo clippy` run: cargo clippy --workspace --locked --release - name: Run `cargo fmt` run: cargo fmt --all --check - - - uses: actions/cache/save@v3 - # Write a cache entry even if the tests fail but don't create any for the merge queue. - if: ${{ always() && steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} - with: - path: ${{ env.CACHED_PATHS }} - key: ${{ steps.cache.outputs.cache-primary-key }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 34f2db7e639..b69970048bd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,12 +29,6 @@ jobs: runs-on: macos-latest env: CROSS_CONFIG: ${{ github.workspace }}/.github/Cross.toml - CACHED_PATHS: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ strategy: matrix: target: [x86_64-apple-darwin, aarch64-apple-darwin] @@ -52,28 +46,21 @@ jobs: echo "SDKROOT=$(xcrun -sdk macosx$(sw_vers -productVersion) --show-sdk-path)" >> $GITHUB_ENV echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx$(sw_vers -productVersion) --show-sdk-platform-version)" >> $GITHUB_ENV - - uses: actions/cache/restore@v3 - id: cache - with: - path: ${{ env.CACHED_PATHS }} - key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Setup toolchain uses: dtolnay/rust-toolchain@1.66.0 with: targets: ${{ matrix.target }} + - uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} + cache-on-failure: true + save-if: ${{ github.event_name != 'merge_group' }} + - name: Build environment and Compile run: | cargo build --package nargo_cli --release --target ${{ matrix.target }} --no-default-features --features "${{ inputs.features }}" - - uses: actions/cache/save@v3 - # Don't create cache entries for the merge queue. - if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} - with: - path: ${{ env.CACHED_PATHS }} - key: ${{ steps.cache.outputs.cache-primary-key }} - - name: Package artifacts run: | mkdir dist @@ -111,12 +98,6 @@ jobs: runs-on: ubuntu-22.04 env: CROSS_CONFIG: ${{ github.workspace }}/.github/Cross.toml - CACHED_PATHS: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ strategy: fail-fast: false matrix: @@ -128,17 +109,17 @@ jobs: with: ref: ${{ inputs.tag || env.GITHUB_REF }} - - uses: actions/cache/restore@v3 - id: cache - with: - path: ${{ env.CACHED_PATHS }} - key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Setup toolchain uses: dtolnay/rust-toolchain@1.66.0 with: targets: ${{ matrix.target }} + - uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} + cache-on-failure: true + save-if: ${{ github.event_name != 'merge_group' }} + - name: Install Cross uses: taiki-e/install-action@v2 with: @@ -147,13 +128,6 @@ jobs: - name: Build Nargo run: cross build --package nargo_cli --release --target=${{ matrix.target }} --no-default-features --features "${{ inputs.features }}" - - uses: actions/cache/save@v3 - # Don't create cache entries for the merge queue. - if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} - with: - path: ${{ env.CACHED_PATHS }} - key: ${{ steps.cache.outputs.cache-primary-key }} - - name: Package artifacts run: | mkdir dist diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e691c4ebd2e..e5a94aaac4b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,13 +17,6 @@ jobs: name: Test on ${{ matrix.os }} runs-on: ${{ matrix.runner }} timeout-minutes: 30 - env: - CACHED_PATHS: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ strategy: fail-fast: false @@ -37,24 +30,16 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Restore nix store cache - uses: actions/cache/restore@v3 - id: cache - with: - path: ${{ env.CACHED_PATHS }} - key: ${{ matrix.target }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} - - name: Setup toolchain uses: dtolnay/rust-toolchain@1.66.0 with: targets: ${{ matrix.target }} + - uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} + cache-on-failure: true + save-if: ${{ github.event_name != 'merge_group' }} + - name: Run tests run: cargo test --workspace --locked --release - - - uses: actions/cache/save@v3 - # Write a cache entry even if the tests fail but don't create any for the merge queue. - if: ${{ always() && steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} - with: - path: ${{ env.CACHED_PATHS }} - key: ${{ steps.cache.outputs.cache-primary-key }} diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index a9d7d4490c4..f02e71be4e6 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -14,13 +14,6 @@ concurrency: jobs: build-nargo: runs-on: ubuntu-22.04 - env: - CACHED_PATHS: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ strategy: matrix: target: [x86_64-unknown-linux-gnu] @@ -29,25 +22,18 @@ jobs: - name: Checkout Noir repo uses: actions/checkout@v4 - - uses: actions/cache/restore@v3 - id: cache - with: - path: ${{ env.CACHED_PATHS }} - key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Setup toolchain uses: dtolnay/rust-toolchain@1.66.0 + - uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} + cache-on-failure: true + save-if: ${{ github.event_name != 'merge_group' }} + - name: Build Nargo run: cargo build --package nargo_cli --release - - uses: actions/cache/save@v3 - # Don't create cache entries for the merge queue. - if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} - with: - path: ${{ env.CACHED_PATHS }} - key: ${{ steps.cache.outputs.cache-primary-key }} - - name: Package artifacts run: | mkdir dist diff --git a/README.md b/README.md index 6958840fae8..22ace1fd3b4 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,6 @@ ACIR Supported OPCODES: - Sha256 - Blake2s - Schnorr signature verification -- MerkleMembership - Pedersen - HashToField