-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache foundry build for contracts (#338)
Significantly speeds up builds by: * for each contracts package, caches its build based on the files and foundry config For better visibility, breaks out each contracts package into its own CI task For protocol-deployments, fork-tests have just become the standard tests We can see the speed up in-upstream prs: https://github.com/ourzora/zora-protocol/actions/runs/6817103631?pr=262 <img width="700" alt="Screenshot 2023-11-09 at 12 36 14 PM" src="https://github.com/ourzora/zora-protocol/assets/891755/18f8e2eb-604f-40d8-937c-73964c5ec5a1">
- Loading branch information
Showing
10 changed files
with
170 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: 'Cache foundry build' | ||
description: 'Caches foundry build by path' | ||
|
||
inputs: | ||
package_folder: # id of input | ||
description: 'contracts package folder' | ||
required: true | ||
foundry_profile: | ||
description: 'foundry profile for caching' | ||
|
||
runs: | ||
using: "composite" | ||
|
||
steps: | ||
- name: Cache contracts build | ||
uses: actions/cache@v3 | ||
with: | ||
# npm cache files are stored in out and cache | ||
path: | | ||
${{ inputs.package_folder }}/cache | ||
${{ inputs.package_folder }}/out | ||
# cache key is based on foundry config, contracts source tests, and scripts | ||
key: ${{ inputs.package_folder }}${{ inputs.foundry_profile}}-${{ hashFiles(format('{0}/foundry.toml', inputs.package_folder)) }}-${{ hashFiles(format('{0}/src/**/*.sol', inputs.package_folder)) }}-${{ hashFiles(format('{0}/test/**/*.sol', inputs.package_folder)) }}-${{ hashFiles(format('{0}/script/**/*.sol', inputs.package_folder)) }} | ||
# the following backups cache keys are searched, in case an exact match is not found | ||
# see https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key | ||
restore-keys: | | ||
${{ inputs.package_folder }}${{ inputs.foundry_profile}}-${{ hashFiles(format('{0}/foundry.toml', inputs.package_folder)) }}-${{ hashFiles(format('{0}/src/**/*.sol', inputs.package_folder)) }}-${{ hashFiles(format('{0}/test/**/*.sol', inputs.package_folder)) }}- | ||
${{ inputs.package_folder }}${{ inputs.foundry_profile}}-${{ hashFiles(format('{0}/foundry.toml', inputs.package_folder)) }}-${{ hashFiles(format('{0}/src/**/*.sol', inputs.package_folder)) }}- | ||
${{ inputs.package_folder }}${{ inputs.foundry_profile}}-${{ hashFiles(format('{0}/foundry.toml', inputs.package_folder)) }}- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: "1155" | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
package_folder: packages/1155-contracts | ||
|
||
test: | ||
needs: build | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
package_folder: packages/1155-contracts | ||
|
||
coverage: | ||
uses: ./.github/workflows/coverage.yml | ||
with: | ||
package: "1155-contracts" | ||
files_to_ignore: '"*DeploymentConfig*" "*Redeem*" "*deployment*" "*packages*"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
package_folder: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
check: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install node deps and founry | ||
uses: ./.github/actions/setup_deps | ||
|
||
- name: Cache build | ||
uses: ./.github/actions/cache_foundry_build | ||
with: | ||
package_folder: ${{ inputs.package_folder }} | ||
|
||
- name: Build contracts | ||
run: | | ||
cd ${{ inputs.package_folder}} && forge build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: "Contracts" | ||
|
||
on: "push" | ||
|
||
jobs: | ||
contracts-1155: | ||
name: 1155 | ||
uses: ./.github/workflows/1155.yml | ||
|
||
contracts-protocol-rewards: | ||
name: Protocol Rewards | ||
uses: ./.github/workflows/protocol-rewards.yml | ||
|
||
contracts-protocol-deployments: | ||
name: Protocol Deployments | ||
uses: ./.github/workflows/protocol-deployments.yml | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: "1155" | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
package_folder: packages/protocol-deployments | ||
|
||
test: | ||
needs: build | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
package_folder: packages/protocol-deployments | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: "Protocol Rewards" | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
package_folder: packages/protocol-rewards | ||
|
||
test: | ||
needs: build | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
package_folder: packages/protocol-rewards | ||
|
||
coverage: | ||
uses: ./.github/workflows/coverage.yml | ||
with: | ||
package: "protocol-rewards" | ||
files_to_ignore: '"*lib*"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
package_folder: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
check: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install node deps and founry | ||
uses: ./.github/actions/setup_deps | ||
|
||
- name: Load foundry cache | ||
uses: ./.github/actions/cache_foundry_build | ||
with: | ||
package_folder: ${{ inputs.package_folder }} | ||
|
||
- name: Test | ||
run: | | ||
cd ${{ inputs.package_folder}} && yarn test | ||
env: | ||
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters