-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(ci): merge workflows and use cache
We now have a multi-job workflow, which means it will run the jobs in parallel. Between jobs, we cache the artifacts generated by Foundry so they can be reused. The artifacts cached are the result of compilation by Foundry, and hence, they can be reused across jobs. The `build` job is responsible for generating them, while the `test` and `fmt` jobs can reuse them, which is why they `need` the `build` job.
- Loading branch information
1 parent
c82d71d
commit 0429b22
Showing
3 changed files
with
136 additions
and
112 deletions.
There are no files selected for viewing
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,136 @@ | ||
name: Forge CI to build, test and format | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- release/** | ||
tags: | ||
- "*" | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
# replace nightly because latest nightly release has some breaking changes that result in test failures | ||
# this is a previous recent nightly release that should work | ||
version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9 | ||
|
||
- name: Print forge version | ||
run: forge --version | ||
|
||
- name: Build | ||
run: forge build | ||
|
||
- name: Add comment for build failure | ||
if: failure() | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'The build has failed. Please check the logs.' | ||
}) | ||
- name: Cache Foundry artifacts (excluding binaries) | ||
uses: actions/cache/save@v3 | ||
with: | ||
key: "${{ github.job }}-${{ github.sha }}" | ||
path: | | ||
- ./out | ||
- ./cache | ||
- ./broadcast | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
# replace nightly because latest nightly release has some breaking changes that result in test failures | ||
# this is a previous recent nightly release that should work | ||
version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9 | ||
|
||
- name: Restore cached Foundry artifacts | ||
uses: actions/cache/restore@v3 | ||
with: | ||
key: "${{ github.job }}-${{ github.sha }}" | ||
path: | | ||
- ./out | ||
- ./cache | ||
- ./broadcast | ||
- name: Print forge version | ||
run: forge --version | ||
|
||
- name: Run tests | ||
run: forge test -vvv | ||
|
||
- name: Add comment for test failure | ||
if: failure() | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'The tests have failed. Please check the logs.' | ||
}) | ||
fmt: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Foundry | ||
uses: onbjerg/foundry-toolchain@v1 | ||
with: | ||
# replace nightly because latest nightly release has some breaking changes that result in test failures | ||
# this is a previous recent nightly release that should work | ||
version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9 | ||
|
||
- name: Restore cached Foundry artifacts | ||
uses: actions/cache/restore@v3 | ||
with: | ||
key: "${{ github.job }}-${{ github.sha }}" | ||
path: | | ||
- ./out | ||
- ./cache | ||
- ./broadcast | ||
- name: Print forge version | ||
run: forge --version | ||
|
||
- name: Check formatting | ||
run: forge fmt --check | ||
|
||
- name: Add comment for format failure | ||
if: failure() | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'The code is not formatted correctly. Please run `forge fmt` and push the changes.' | ||
}) |
This file was deleted.
Oops, something went wrong.