Skip to content

Commit

Permalink
ci: cache testing contracts (#681)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Paul Razvan Berg <[email protected]>
  • Loading branch information
3 people authored Sep 5, 2023
1 parent 98d8fa0 commit d1157b4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 14 deletions.
30 changes: 24 additions & 6 deletions .github/workflows/ci-deep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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\""
Expand Down Expand Up @@ -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\""
Expand Down Expand Up @@ -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\""
Expand Down Expand Up @@ -198,12 +213,15 @@ 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\""

- name: "Add test summary"
run: |
echo "## Fork tests result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
36 changes: 28 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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\""
Expand Down Expand Up @@ -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\""
Expand All @@ -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\""
Expand All @@ -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\""
Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -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

0 comments on commit d1157b4

Please sign in to comment.