From 8d6adda3219c2b3e2d392268631b0109383e2dd1 Mon Sep 17 00:00:00 2001 From: Tom French Date: Wed, 13 Sep 2023 01:39:01 +0100 Subject: [PATCH 1/4] chore(ci): switch to using `Swatinem/rust-cache` action --- .github/workflows/formatting.yml | 27 +++++--------------- .github/workflows/publish.yml | 42 ++++++-------------------------- .github/workflows/test.yml | 27 +++++--------------- 3 files changed, 20 insertions(+), 76 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..c938d27f5bd 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,11 +46,11 @@ 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 + - uses: Swatinem/rust-cache@v2 with: - path: ${{ env.CACHED_PATHS }} - key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ matrix.target }} + cache-on-failure: true + save-if: ${{ github.event_name != 'merge_group' }} - name: Setup toolchain uses: dtolnay/rust-toolchain@1.66.0 @@ -67,13 +61,6 @@ jobs: 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,11 +109,11 @@ jobs: with: ref: ${{ inputs.tag || env.GITHUB_REF }} - - uses: actions/cache/restore@v3 - id: cache + - uses: Swatinem/rust-cache@v2 with: - path: ${{ env.CACHED_PATHS }} - key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ matrix.target }} + cache-on-failure: true + save-if: ${{ github.event_name != 'merge_group' }} - name: Setup toolchain uses: dtolnay/rust-toolchain@1.66.0 @@ -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 }} From a2888eeb07efec7cd91839c5120149ed91653379 Mon Sep 17 00:00:00 2001 From: Tom French Date: Wed, 13 Sep 2023 09:01:08 +0100 Subject: [PATCH 2/4] chore: extra instance of action to switch --- .github/workflows/wasm.yml | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index a9d7d4490c4..3bcb73e2789 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,11 +22,11 @@ jobs: - name: Checkout Noir repo uses: actions/checkout@v4 - - uses: actions/cache/restore@v3 - id: cache + - uses: Swatinem/rust-cache@v2 with: - path: ${{ env.CACHED_PATHS }} - key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ matrix.target }} + cache-on-failure: true + save-if: ${{ github.event_name != 'merge_group' }} - name: Setup toolchain uses: dtolnay/rust-toolchain@1.66.0 @@ -41,13 +34,6 @@ jobs: - 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 From 1028d4be440f5cf049895e1e4e0e659405178026 Mon Sep 17 00:00:00 2001 From: Tom French Date: Wed, 13 Sep 2023 09:14:43 +0100 Subject: [PATCH 3/4] chore: run cache after toolchain setup --- .github/workflows/publish.yml | 20 ++++++++++---------- .github/workflows/wasm.yml | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c938d27f5bd..b69970048bd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -46,17 +46,17 @@ 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 + - 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: Setup toolchain - uses: dtolnay/rust-toolchain@1.66.0 - with: - targets: ${{ matrix.target }} - - name: Build environment and Compile run: | cargo build --package nargo_cli --release --target ${{ matrix.target }} --no-default-features --features "${{ inputs.features }}" @@ -109,17 +109,17 @@ jobs: with: ref: ${{ inputs.tag || env.GITHUB_REF }} + - 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: Setup toolchain - uses: dtolnay/rust-toolchain@1.66.0 - with: - targets: ${{ matrix.target }} - - name: Install Cross uses: taiki-e/install-action@v2 with: diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 3bcb73e2789..f02e71be4e6 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -22,15 +22,15 @@ jobs: - name: Checkout Noir repo uses: actions/checkout@v4 + - 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: Setup toolchain - uses: dtolnay/rust-toolchain@1.66.0 - - name: Build Nargo run: cargo build --package nargo_cli --release From 9e0b1d236057d1e04d37d8c713618e6a7962eed6 Mon Sep 17 00:00:00 2001 From: Tom French Date: Wed, 13 Sep 2023 09:51:26 +0100 Subject: [PATCH 4/4] chore: dummy commit to run CI --- README.md | 1 - 1 file changed, 1 deletion(-) 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