Skip to content

Commit

Permalink
move Foundry version detection to an action
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed Aug 8, 2024
1 parent 5f8187d commit 9d4c398
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
26 changes: 26 additions & 0 deletions .github/actions/detect-solidity-foundry-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Detect Foundry version in GNUmakefile'
description: 'Detects Foundry version in GNUmakefile'
inputs:
working-directory:
description: 'The GNUmakefile directory'
required: false
default: 'contracts'
outputs:
foundry-version:
description: 'Foundry version found in GNUmakefile'
value: ${{ steps.extract-foundry-version.outputs.foundry-version }}
runs:
using: 'composite'
steps:
- name: Extract Foundry version
id: extract-foundry-version
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
foundry_version=$(grep -Eo "foundryup --version [^ ]+" GNUmakefile | awk '{print $3}')
if [ -z "$foundry_version" ]; then
echo "::error::Foundry version not found in GNUmakefile"
exit 1
fi
echo "Foundry version found: $foundry_version"
echo "foundry-version=$foundry_version" >> $GITHUB_OUTPUT
25 changes: 5 additions & 20 deletions .github/workflows/solidity-foundry-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,17 @@ jobs:
runs-on: ubuntu-22.04
needs: [ changes ]
outputs:
foundry_version: ${{ steps.extract-foundry-version.outputs.foundry_version }}
foundry_version: ${{ steps.extract-foundry-version.outputs.foundry-version }}
steps:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
fetch-depth: 0

- name: Extract Foundry version
id: extract-foundry-version
shell: bash
working-directory: contracts
run: |
foundry_version=$(grep -Eo "foundryup --version [^ ]+" GNUmakefile | awk '{print $3}')
if [ -z "$foundry_version" ]; then
echo "Error: Foundry version not found in GNUmakefile"
exit 1
fi
echo "Foundry version found: $foundry_version"
echo "foundry_version=$foundry_version" >> $GITHUB_OUTPUT
uses: ./.github/actions/detect-solidity-foundry-version
with:
working-directory: contracts

- name: Copy modified changesets
if: ${{ needs.changes.outputs.changeset_changes == 'true' }}
Expand All @@ -149,14 +141,7 @@ jobs:
IFS=',' read -r -a modified_files <<< "${{ needs.changes.outputs.product_files }}"
echo "# Modified contracts:" > contracts/modified_contracts.md
for file in "${modified_files[@]}"; do
# TODO remove this check when AurorNZ/paths-filter is fixed
status=$(git diff --name-status ${{ inputs.base_ref }} ${{ github.sha }} -- "$file" | awk '{ print $1 }')
if [ "$status" == "D" ]; then
echo "File $file was deleted, skipping."
continue
fi
for file in "${modified_files[@]}"; do
echo " - [$file](${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/$file)" >> contracts/modified_contracts.md
echo "$file" >> contracts/modified_contracts.txt
done
Expand Down
15 changes: 4 additions & 11 deletions .github/workflows/solidity-hardhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,18 @@ jobs:
runs-on: ubuntu-22.04
needs: [ changes ]
outputs:
foundry_version: ${{ steps.extract-foundry-version.outputs.foundry_version }}
foundry_version: ${{ steps.extract-foundry-version.outputs.foundry-version }}
steps:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
fetch-depth: 0

- name: Extract Foundry version
uses: ./.github/actions/detect-solidity-foundry-version
id: extract-foundry-version
shell: bash
working-directory: contracts
run: |
foundry_version=$(grep -Eo "foundryupZ --version [^ ]+" GNUmakefile | awk '{print $3}')
if [ -z "$foundry_version" ]; then
echo "Error: Foundry version not found in GNUmakefile"
exit 1
fi
echo "Foundry version found: $foundry_version"
echo "foundry_version=$foundry_version" >> $GITHUB_OUTPUT
with:
working-directory: contracts

- name: Copy modified changesets
if: ${{ needs.changes.outputs.changeset_changes == 'true' }}
Expand Down

0 comments on commit 9d4c398

Please sign in to comment.