From bb1ab95eace08798587f2f6f7b17bc079be5e65d Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:15:59 +0000 Subject: [PATCH] chore(lint): lint the ci --- .github/workflows/forge-ci.yml | 27 +++++++++-------- .github/workflows/foundry-setup.yml | 45 +++++++++++++---------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/.github/workflows/forge-ci.yml b/.github/workflows/forge-ci.yml index 4e82e6c7..9e9bb68e 100644 --- a/.github/workflows/forge-ci.yml +++ b/.github/workflows/forge-ci.yml @@ -1,6 +1,7 @@ +--- name: Forge CI to build, test and format -on: +on: pull_request: push: branches: @@ -12,13 +13,15 @@ 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: @@ -26,10 +29,10 @@ jobs: - 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 @@ -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: @@ -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: diff --git a/.github/workflows/foundry-setup.yml b/.github/workflows/foundry-setup.yml index dff0e80a..dfd5688c 100644 --- a/.github/workflows/foundry-setup.yml +++ b/.github/workflows/foundry-setup.yml @@ -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"