Skip to content

Commit

Permalink
chore(lint): lint the ci
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMustermann2 committed Jun 4, 2024
1 parent e929b0a commit bb1ab95
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/forge-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Forge CI to build, test and format

on:
on:
pull_request:
push:
branches:
Expand All @@ -12,24 +13,26 @@ on:
jobs:
setup:
uses: ./.github/workflows/foundry-setup.yml
with:
foundry-version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9

build:
runs-on: ubuntu-latest
needs: setup
outputs:
installation_dir: ${{ needs.setup.outputs.installation_dir }}
key: ${{ needs.setup.outputs.key }}
installation-dir: ${{ needs.setup.outputs.installation-dir }}
cache-key: ${{ needs.setup.outputs.cache-key }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Restore cached Foundry toolchain
uses: actions/cache/restore@v3
with:
path: ${{ needs.setup.outputs.installation_dir }}
key: ${{ needs.setup.outputs.key }}
path: ${{ needs.setup.outputs.installation-dir }}
key: ${{ needs.setup.outputs.cache-key }}
- name: Add Foundry to PATH
run: echo "${{ needs.setup.outputs.installation_dir }}" >> $GITHUB_PATH
run: echo "${{ needs.setup.outputs.installation-dir }}" >> $GITHUB_PATH
- name: Build
run: forge build
- name: Add comment for build failure
Expand Down Expand Up @@ -62,10 +65,10 @@ jobs:
- name: Restore cached Foundry toolchain
uses: actions/cache/restore@v3
with:
path: ${{ needs.build.outputs.installation_dir }}
key: ${{ needs.build.outputs.key }}
path: ${{ needs.build.outputs.installation-dir }}
key: ${{ needs.build.outputs.cache-key }}
- name: Add Foundry to PATH
run: echo "${{ needs.build.outputs.installation_dir }}" >> $GITHUB_PATH
run: echo "${{ needs.build.outputs.installation-dir }}" >> $GITHUB_PATH
- name: Restore build artifacts
uses: actions/cache/restore@v3
with:
Expand Down Expand Up @@ -100,10 +103,10 @@ jobs:
- name: Restore cached Foundry toolchain
uses: actions/cache/restore@v3
with:
path: ${{ needs.build.outputs.installation_dir }}
key: ${{ needs.build.outputs.key }}
path: ${{ needs.build.outputs.installation-dir }}
key: ${{ needs.build.outputs.cache-key }}
- name: Add Foundry to PATH
run: echo "${{ needs.build.outputs.installation_dir }}" >> $GITHUB_PATH
run: echo "${{ needs.build.outputs.installation-dir }}" >> $GITHUB_PATH
- name: Restore build artifacts
uses: actions/cache/restore@v3
with:
Expand Down
45 changes: 20 additions & 25 deletions .github/workflows/foundry-setup.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,47 @@
---
name: Foundry Setup

on:
workflow_call:
inputs:
foundry-version:
required: true
type: string
outputs:
installation_dir:
installation-dir:
description: "The installation directory of Foundry toolchain"
value: ${{ jobs.setup.outputs.installation_dir }}
key:
value: ${{ jobs.setup.outputs.installation-dir }}
cache-key:
description: "The cache key for Foundry toolchain"
value: ${{ jobs.setup.outputs.key }}
value: ${{ jobs.setup.outputs.cache-key }}

jobs:
pre-setup:
runs-on: ubuntu-latest
outputs:
foundry_version: ${{ steps.set-version.outputs.foundry_version }}
steps:
- name: Set Foundry version
id: set-version
run: |
echo "foundry_version=nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9" >> "$GITHUB_OUTPUT"
setup:
runs-on: ubuntu-latest
needs: pre-setup
outputs:
key: ${{ steps.set-key.outputs.key }}
installation_dir: ${{ steps.find-path.outputs.installation_dir }}
cache-key: ${{ steps.set-cache-key.outputs.cache-key }}
installation-dir: ${{ steps.find-path.outputs.installation-dir }}
steps:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: ${{ needs.pre-setup.outputs.foundry_version }}
version: ${{ inputs.foundry-version }}
- name: Print forge version
run: forge --version
# Unfortunately, the `foundry-toolchain` action installs it in a randomly generated location, so we must determine it ourselves
# Unfortunately, the `foundry-toolchain` action installs it in a
# randomly generated location, so we must determine it ourselves
- name: Determine Foundry installation path
id: find-path
run: |
installation_path=$(which forge)
installation_dir=$(dirname $installation_path)
echo "installation_dir=$installation_dir" >> "$GITHUB_OUTPUT"
echo "installation-dir=$installation_dir" >> "$GITHUB_OUTPUT"
- name: Cached Foundry toolchain
uses: actions/cache/save@v3
with:
path: ${{ steps.find-path.outputs.installation_dir }}
key: ${{ runner.os }}-foundry-${{ needs.pre-setup.outputs.foundry_version }}
- name: Set key
id: set-key
path: ${{ steps.find-path.outputs.installation-dir }}
key: ${{ runner.os }}-foundry-${{ inputs.foundry-version }}
- name: Set cache key
id: set-cache-key
run: |
echo "key=${{ runner.os }}-foundry-${{ needs.pre-setup.outputs.foundry_version }}" >> "$GITHUB_OUTPUT"
echo "cache-key=${{ runner.os }}-foundry-${{ inputs.foundry-version }}" >> "$GITHUB_OUTPUT"

0 comments on commit bb1ab95

Please sign in to comment.