Skip to content

Commit

Permalink
build(ci): use a common foundry-setup action
Browse files Browse the repository at this point in the history
...and do not let the cache key depend on the job name.
  • Loading branch information
MaxMustermann2 committed Jun 4, 2024
1 parent 0429b22 commit c256322
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 35 deletions.
44 changes: 9 additions & 35 deletions .github/workflows/forge-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,10 @@ env:

jobs:
build:
runs-on: ubuntu-latest
uses: ./.github/workflows/foundry-setup.yml
with:
version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9
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

Expand All @@ -47,7 +37,7 @@ jobs:
- name: Cache Foundry artifacts (excluding binaries)
uses: actions/cache/save@v3
with:
key: "${{ github.job }}-${{ github.sha }}"
key: "${{ runner.os }}-build-${{ github.sha }}"
path: |
- ./out
- ./cache
Expand All @@ -57,27 +47,19 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- uses: ./.github/workflows/foundry-setup.yml
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 }}"
key: "${{ runner.os }}-build-${{ github.sha }}"
path: |
- ./out
- ./cache
- ./broadcast
- name: Print forge version
run: forge --version

- name: Run tests
run: forge test -vvv

Expand All @@ -98,27 +80,19 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
- uses: ./.github/workflows/foundry-setup.yml
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 }}"
key: "${{ runner.os }}-build-${{ github.sha }}"
path: |
- ./out
- ./cache
- ./broadcast
- name: Print forge version
run: forge --version

- name: Check formatting
run: forge fmt --check

Expand All @@ -133,4 +107,4 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
body: 'The code is not formatted correctly. Please run `forge fmt` and push the changes.'
})
})
25 changes: 25 additions & 0 deletions .github/workflows/foundry-setup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Foundry Setup

on:
workflow_call:
inputs:
version:
required: true
type: string
secrets:
GITHUB_TOKEN:
required: true

jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: ${{ inputs.version }}

- name: Print forge version
run: forge --version

0 comments on commit c256322

Please sign in to comment.