From c2563226076ce75122aca61d688aec7afe244dee Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 4 Jun 2024 09:29:32 +0000 Subject: [PATCH] build(ci): use a common foundry-setup action ...and do not let the cache key depend on the job name. --- .github/workflows/forge-ci.yml | 44 ++++++---------------------- .github/workflows/foundry-setup.yaml | 25 ++++++++++++++++ 2 files changed, 34 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/foundry-setup.yaml diff --git a/.github/workflows/forge-ci.yml b/.github/workflows/forge-ci.yml index 59dc9a36..1e158b15 100644 --- a/.github/workflows/forge-ci.yml +++ b/.github/workflows/forge-ci.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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.' - }) \ No newline at end of file + }) diff --git a/.github/workflows/foundry-setup.yaml b/.github/workflows/foundry-setup.yaml new file mode 100644 index 00000000..6ee57dbf --- /dev/null +++ b/.github/workflows/foundry-setup.yaml @@ -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