From d1157b49ed4bceeff0c4e437c9f723e88c134d3a Mon Sep 17 00:00:00 2001 From: Andrei Vlad Birgaoanu <99738872+andreivladbrg@users.noreply.github.com> Date: Tue, 5 Sep 2023 21:08:53 +0300 Subject: [PATCH] ci: cache testing contracts (#681) * Fix Github workflow build cache * ci: add "out" dir in github cache * Update .github/workflows/ci.yml * Update .github/workflows/ci.yml * Update .github/workflows/ci-deep.yml --------- Co-authored-by: Lumyo Co-authored-by: Paul Razvan Berg --- .github/workflows/ci-deep.yml | 30 +++++++++++++++++++++++------ .github/workflows/ci.yml | 36 +++++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci-deep.yml b/.github/workflows/ci-deep.yml index 1060e79fc..f00248f20 100644 --- a/.github/workflows/ci-deep.yml +++ b/.github/workflows/ci-deep.yml @@ -80,11 +80,17 @@ jobs: - name: "Produce an optimized build with --via-ir" run: "FOUNDRY_PROFILE=optimized forge build" + - name: "Build the test contracts" + run: "FOUNDRY_PROFILE=test-optimized forge build" + - name: "Cache the build so that it can be re-used by the other jobs" uses: "actions/cache/save@v3" with: - path: "out-optimized" key: "foundry-build-${{ github.sha }}" + path: | + cache + out + out-optimized - name: "Add build summary" run: | @@ -110,7 +116,10 @@ jobs: with: fail-on-cache-miss: true key: "foundry-build-${{ github.sha }}" - path: "out-optimized" + path: | + cache + out + out-optimized - name: "Run the unit tests against the optimized build" run: "FOUNDRY_PROFILE=test-optimized forge test --match-path \"test/unit\"" @@ -139,7 +148,10 @@ jobs: with: fail-on-cache-miss: true key: "foundry-build-${{ github.sha }}" - path: "out-optimized" + path: | + cache + out + out-optimized - name: "Run the integration tests against the optimized build" run: "FOUNDRY_PROFILE=test-optimized forge test --match-path \"test/integration/**/*.sol\"" @@ -169,7 +181,10 @@ jobs: with: fail-on-cache-miss: true key: "foundry-build-${{ github.sha }}" - path: "out-optimized" + path: | + cache + out + out-optimized - name: "Run the invariant tests against the optimized build" run: "FOUNDRY_PROFILE=test-optimized forge test --match-path \"test/invariant/**/*.sol\"" @@ -198,7 +213,10 @@ jobs: with: fail-on-cache-miss: true key: "foundry-build-${{ github.sha }}" - path: "out-optimized" + path: | + cache + out + out-optimized - name: "Run the fork tests against the optimized build" run: "FOUNDRY_PROFILE=test-optimized forge test --match-path \"test/fork/**/*.sol\"" @@ -206,4 +224,4 @@ jobs: - name: "Add test summary" run: | echo "## Fork tests result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c9010386..7a5f6eb27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,19 +78,24 @@ jobs: - name: "Generate and prepare the contract artifacts" run: "./shell/prepare-artifacts.sh" + + - name: "Build the test contracts" + run: "FOUNDRY_PROFILE=test-optimized forge build" - name: "Cache the build so that it can be re-used by the other jobs" uses: "actions/cache/save@v3" with: - path: "out-optimized" key: "foundry-build-${{ github.sha }}" + path: | + cache + out + out-optimized - name: "Store the contract artifacts in CI" uses: "actions/upload-artifact@v3" with: name: "contract-artifacts" path: "artifacts" - - name: "Add build summary" run: | echo "## Build result" >> $GITHUB_STEP_SUMMARY @@ -115,7 +120,10 @@ jobs: with: fail-on-cache-miss: true key: "foundry-build-${{ github.sha }}" - path: "out-optimized" + path: | + cache + out + out-optimized - name: "Run the unit tests against the optimized build" run: "FOUNDRY_PROFILE=test-optimized forge test --match-path \"test/unit/**/*.sol\"" @@ -144,7 +152,10 @@ jobs: with: fail-on-cache-miss: true key: "foundry-build-${{ github.sha }}" - path: "out-optimized" + path: | + cache + out + out-optimized - name: "Run the integration tests against the optimized build" run: "FOUNDRY_PROFILE=test-optimized forge test --match-path \"test/integration/**/*.sol\"" @@ -171,7 +182,10 @@ jobs: with: fail-on-cache-miss: true key: "foundry-build-${{ github.sha }}" - path: "out-optimized" + path: | + cache + out + out-optimized - name: "Run the utils tests against the optimized build" run: "FOUNDRY_PROFILE=test-optimized forge test --match-path \"test/utils/**/*.sol\"" @@ -198,7 +212,10 @@ jobs: with: fail-on-cache-miss: true key: "foundry-build-${{ github.sha }}" - path: "out-optimized" + path: | + cache + out + out-optimized - name: "Run the invariant tests against the optimized build" run: "FOUNDRY_PROFILE=test-optimized forge test --match-path \"test/invariant/**/*.sol\"" @@ -227,7 +244,10 @@ jobs: with: fail-on-cache-miss: true key: "foundry-build-${{ github.sha }}" - path: "out-optimized" + path: | + cache + out + out-optimized - name: "Generate fuzz seed that changes weekly to avoid burning through RPC allowance" run: | @@ -264,4 +284,4 @@ jobs: - name: "Add coverage summary" run: | echo "## Coverage result" >> $GITHUB_STEP_SUMMARY - echo "✅ Uploaded to Codecov" >> $GITHUB_STEP_SUMMARY + echo "✅ Uploaded to Codecov" >> $GITHUB_STEP_SUMMARY \ No newline at end of file