Skip to content

Commit

Permalink
use reusable Solidity Review Artifacts workflow from .github
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed Sep 18, 2024
1 parent a0a27b4 commit 9ef67f2
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 67 deletions.
34 changes: 34 additions & 0 deletions .github/actions/setup-nodejs/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Setup NodeJS
inputs:
prod:
default: "false"
description: Set to 'true' to do a prod only install
base-path:
description: Path to the base of the repo
required: false
default: .
description: Setup pnpm for contracts
runs:
using: composite
steps:
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
with:
version: ^9.0.0

- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: "20"
cache: "pnpm"
cache-dependency-path: "${{ inputs.base-path }}/contracts/pnpm-lock.yaml"

- if: ${{ inputs.prod == 'false' }}
name: Install dependencies
shell: bash
run: pnpm i
working-directory: ${{ inputs.base-path }}/contracts

- if: ${{ inputs.prod == 'true' }}
name: Install prod dependencies
shell: bash
run: pnpm i --prod
working-directory: ${{ inputs.base-path }}/contracts
10 changes: 5 additions & 5 deletions .github/workflows/changeset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ jobs:
id: find-git-top-level-dir
run: echo "top_level_dir=$(pwd)" >> $GITHUB_OUTPUT

- name: Checkout Chainlink Github Actions repository
- name: Checkout .Github repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
repository: smartcontractkit/chainlink-github-actions
ref: 2951e97b9bfca4226bc4294148c322824aad5c0f
path: .chainlink-github-actions
repository: smartcontractkit/.github
ref: 228acc0a7f9f0092450a7673786462832bf3d19c
path: ./dot_github

- name: Update Jira ticket for core
id: jira
if: ${{ steps.files-changed.outputs.core == 'true' || steps.files-changed.outputs.shared == 'true' }}
shell: bash
working-directory: ./.chainlink-github-actions/jira/scripts
working-directory: ./dot_github/libs/jira-tracing
run: |
echo "COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s')" >> $GITHUB_ENV
pnpm install && pnpm issue:update
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ jobs:
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
- name: Setup NodeJS
if: ${{ needs.filter.outputs.changes == 'true' }}
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
uses: ./.github/actions/setup-nodejs
with:
contracts_dir: './contracts'
prod: "true"
- name: Setup Go
if: ${{ needs.filter.outputs.changes == 'true' }}
Expand Down Expand Up @@ -275,9 +274,8 @@ jobs:
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
- name: Setup NodeJS
if: ${{ needs.filter.outputs.changes == 'true' }}
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
uses: ./.github/actions/setup-nodejs
with:
contracts_dir: './contracts'
prod: "true"
- name: Setup Go
if: ${{ needs.filter.outputs.changes == 'true' }}
Expand Down Expand Up @@ -448,9 +446,7 @@ jobs:
- name: Install protoc-gen-go-wsrpc
run: curl https://github.com/smartcontractkit/wsrpc/raw/main/cmd/protoc-gen-go-wsrpc/protoc-gen-go-wsrpc --output $HOME/go/bin/protoc-gen-go-wsrpc && chmod +x $HOME/go/bin/protoc-gen-go-wsrpc
- name: Setup NodeJS
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
with:
contracts_dir: './contracts'
uses: ./.github/actions/setup-nodejs
- name: make generate
run: |
make rm-mocked
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/solidity-foundry-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
generate-artifacts:
name: Generate Solidity Review Artifacts
needs: [changes, prepare-workflow-inputs]
uses: smartcontractkit/chainlink-github-actions/.github/workflows/review-artifacts.yml@2951e97b9bfca4226bc4294148c322824aad5c0f
uses: smartcontractkit/.github/.github/workflows/solidity-review-artifacts.yml@228acc0a7f9f0092450a7673786462832bf3d19c
with:
product: ${{ inputs.product }}
commit_to_use: ${{ inputs.commit_to_use }}
Expand Down
44 changes: 19 additions & 25 deletions .github/workflows/solidity-foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ jobs:
if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
|| contains(fromJson(needs.changes.outputs.all_changes), 'shared')
|| needs.changes.outputs.non_src_changes == 'true' }}
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
uses: ./.github/actions/setup-nodejs
with:
contracts_dir: './contracts'
prod: "true"

- name: Install Foundry
if: ${{ contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name)
Expand Down Expand Up @@ -273,20 +273,18 @@ jobs:
if: needs.changes.outputs.not_test_sol_modified == 'true'
runs-on: ubuntu-22.04
steps:
- name: Checkout the repo
- name: Checkout this repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

- name: Checkout the repo
- name: Checkout .github repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
repository: smartcontractkit/chainlink-github-actions
ref: 2951e97b9bfca4226bc4294148c322824aad5c0f
path: ./chainlink-github-actions
repository: smartcontractkit/.github
ref: 228acc0a7f9f0092450a7673786462832bf3d19c
path: ./dot_github

- name: Setup NodeJS
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
with:
contracts_dir: './contracts'
uses: ./.github/actions/setup-nodejs

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773 # v1.2.0
Expand All @@ -299,19 +297,19 @@ jobs:
python-version: '3.8'

- name: Install solc-select and solc
uses: smartcontractkit/chainlink-github-actions/solidity/setup-solc-select@2951e97b9bfca4226bc4294148c322824aad5c0f
uses: smartcontractkit/.github/actions/setup-solc-select@228acc0a7f9f0092450a7673786462832bf3d19c
with:
to_install: '0.8.24'
to_use: '0.8.24'

- name: Install Slither
uses: smartcontractkit/chainlink-github-actions/solidity/setup-slither@2951e97b9bfca4226bc4294148c322824aad5c0f
uses: smartcontractkit/.github/actions/setup-slither@228acc0a7f9f0092450a7673786462832bf3d19c

- name: Run Slither
shell: bash
run: |
# modify remappings so that solc can find dependencies
./chainlink-github-actions/solidity/scripts/modify_remappings.sh contracts contracts/remappings.txt
./dot_github/tools/scripts/solidity/modify_remappings.sh contracts contracts/remappings.txt
mv remappings_modified.txt remappings.txt
# without it Slither sometimes fails to use remappings correctly
Expand All @@ -327,7 +325,7 @@ jobs:
echo "::debug::No Slither config found for $PRODUCT, using default"
SLITHER_CONFIG="contracts/configs/slither/.slither.config-default-pr.json"
fi
./chainlink-github-actions/solidity/scripts/generate_slither_report.sh "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/" "$SLITHER_CONFIG" "./contracts" "$FILE" "contracts/slither-reports-current" "--solc-remaps @=contracts/node_modules/@"
./dot_github/tools/scripts/solidity/generate_slither_report.sh "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/" "$SLITHER_CONFIG" "./contracts" "$FILE" "contracts/slither-reports-current" "--solc-remaps @=contracts/node_modules/@"
done
# all the actions below, up to printing results, run only if any existing contracts were modified
Expand Down Expand Up @@ -363,7 +361,7 @@ jobs:
path: contracts/configs
retention-days: 7

- name: Checkout the repo
- name: Checkout earlier version of this repository
if: needs.changes.outputs.sol_mod_only == 'true'
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
Expand All @@ -386,21 +384,19 @@ jobs:
# since we have just checked out the repository again, we lose NPM dependencies installs previously, we need to install them again to compile contracts
- name: Setup NodeJS
if: needs.changes.outputs.sol_mod_only == 'true'
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
with:
contracts_dir: './contracts'
uses: ./.github/actions/setup-nodejs

- name: Run Slither for base reference
if: needs.changes.outputs.sol_mod_only == 'true'
shell: bash
run: |
# we need to set file permission again since they are lost during download
for file in ./chainlink-github-actions/solidity/scripts/*.sh; do
for file in ./dot_github/tools/scripts/solidity/*.sh; do
chmod +x "$file"
done
# modify remappings so that solc can find dependencies
./chainlink-github-actions/solidity/scripts/modify_remappings.sh contracts contracts/remappings.txt
./dot_github/tools/scripts/solidity/modify_remappings.sh contracts contracts/remappings.txt
mv remappings_modified.txt remappings.txt
# without it Slither sometimes fails to use remappings correctly
Expand All @@ -416,7 +412,7 @@ jobs:
echo "::debug::No Slither config found for $PRODUCT, using default"
SLITHER_CONFIG="contracts/configs/slither/.slither.config-default-pr.json"
fi
./chainlink-github-actions/solidity/scripts/generate_slither_report.sh "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/" "$SLITHER_CONFIG" "./contracts" "$FILE" "contracts/slither-reports-base-ref" "--solc-remaps @=contracts/node_modules/@"
./dot_github/tools/scripts/solidity/generate_slither_report.sh "${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/" "$SLITHER_CONFIG" "./contracts" "$FILE" "contracts/slither-reports-base-ref" "--solc-remaps @=contracts/node_modules/@"
done
- name: Upload Slither report
Expand Down Expand Up @@ -479,7 +475,7 @@ jobs:
done
- name: Validate if all Slither run for all contracts
uses: smartcontractkit/chainlink-github-actions/solidity/validate-solidity-artifacts@2951e97b9bfca4226bc4294148c322824aad5c0f
uses: smartcontractkit/.github/actions/validate-solidity-artifacts@228acc0a7f9f0092450a7673786462832bf3d19c
with:
validate_slither_reports: 'true'
slither_reports_path: 'contracts/slither-reports-current'
Expand Down Expand Up @@ -567,9 +563,7 @@ jobs:

- name: Setup NodeJS
if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || needs.changes.outputs.non_src_changes == 'true') && matrix.product.setup.run-forge-fmt }}
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
with:
contracts_dir: './contracts'
uses: ./.github/actions/setup-nodejs

- name: Install Foundry
if: ${{ (contains(fromJson(needs.changes.outputs.all_changes), matrix.product.name) || needs.changes.outputs.non_src_changes == 'true') && matrix.product.setup.run-forge-fmt }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/solidity-hardhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ jobs:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Setup NodeJS
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
uses: ./.github/actions/setup-nodejs
with:
contracts_dir: './contracts'
prod: "true"
- name: Setup Hardhat
uses: ./.github/actions/setup-hardhat
with:
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/solidity-tracability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,26 @@ jobs:
exit 1
- name: Setup NodeJS
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
with:
contracts_dir: './contracts'
uses: ./.github/actions/setup-nodejs

- name: Checkout Chainlink Github Actions repository
- name: Checkout .Github repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
repository: smartcontractkit/chainlink-github-actions
ref: 2951e97b9bfca4226bc4294148c322824aad5c0f
path: .chainlink-github-actions
repository: smartcontractkit/.github
ref: 228acc0a7f9f0092450a7673786462832bf3d19c
path: ./dot_github

- name: Setup git top level directory
id: find-git-top-level-dir
run: echo "top_level_dir=$(pwd)" >> $GITHUB_OUTPUT

- name: Setup Jira
working-directory: ./.chainlink-github-actions/jira/scripts
working-directory: ./dot_github/libs/jira-tracing
run: pnpm i

# Because of our earlier checks, we know that both the source and changeset files have changed
- name: Enforce Traceability
working-directory: ./.chainlink-github-actions/jira/scripts
working-directory: ./dot_github/libs/jira-tracing
run: |
echo "COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s')" >> $GITHUB_ENV
pnpm issue:enforce
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/solidity-wrappers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ jobs:
uses: ./.github/actions/setup-go

- name: Setup NodeJS
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
uses: ./.github/actions/setup-nodejs
with:
contracts_dir: './contracts'
prod: "true"

- name: Run native compile and generate wrappers
Expand Down
23 changes: 7 additions & 16 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ jobs:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Setup NodeJS
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
uses: smartcontractkit/.github/actions/setup-nodejs@bff23e98280a3f60233e7ab2d5675a006843732c
with:
contracts_dir: './contracts'
package-json-directory: '.contracts'
- name: Run Prepublish test
working-directory: contracts
run: pnpm prepublishOnly
Expand Down Expand Up @@ -97,9 +97,8 @@ jobs:
- name: Install diff-so-fancy
run: echo "$GITHUB_WORKSPACE/diff-so-fancy" >> $GITHUB_PATH
- name: Setup NodeJS
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
uses: ./.github/actions/setup-nodejs
with:
contracts_dir: './contracts'
prod: "true"
- name: Setup Go
uses: ./.github/actions/setup-go
Expand Down Expand Up @@ -136,9 +135,7 @@ jobs:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Setup NodeJS
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
with:
contracts_dir: './contracts'
uses: ./.github/actions/setup-nodejs
- name: Run pnpm lint
run: pnpm lint
- name: Run solhint
Expand Down Expand Up @@ -166,9 +163,7 @@ jobs:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Setup NodeJS
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
with:
contracts_dir: './contracts'
uses: ./.github/actions/setup-nodejs
- name: Run prettier check
run: pnpm prettier:check
- name: Collect Metrics
Expand All @@ -193,9 +188,7 @@ jobs:
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

- name: Setup NodeJS
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
with:
contracts_dir: './contracts'
uses: ./.github/actions/setup-nodejs

- name: Version package.json
working-directory: contracts
Expand Down Expand Up @@ -235,9 +228,7 @@ jobs:
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

- name: Setup NodeJS
uses: smartcontractkit/chainlink-github-actions/solidity/setup-nodejs@2951e97b9bfca4226bc4294148c322824aad5c0f
with:
contracts_dir: './contracts'
uses: ./.github/actions/setup-nodejs

- name: Validate version
working-directory: contracts
Expand Down
1 change: 1 addition & 0 deletions contracts/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 20.13.1

0 comments on commit 9ef67f2

Please sign in to comment.