Apply fixes based on code review #7
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Solidity Foundry | |
on: [pull_request] | |
env: | |
FOUNDRY_PROFILE: ci | |
jobs: | |
changes: | |
name: Detect changes | |
runs-on: ubuntu-latest | |
outputs: | |
changes: ${{ steps.changes.outputs.src }} | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 | |
id: changes | |
with: | |
# Foundry is only used for Solidity v0.8 contracts, therefore we can ignore | |
# changes to older contracts. | |
filters: | | |
src: | |
- 'contracts/src/v0.8/**/*' | |
- 'contracts/test/v0.8/foundry/**/*' | |
- '.github/workflows/solidity-foundry.yml' | |
- 'contracts/foundry.toml' | |
- 'contracts/gas-snapshots/*.gas-snapshot' | |
- '.gitmodules' | |
- 'contracts/foundry-lib' | |
coverage: | |
needs: [changes] | |
name: Coverage | |
runs-on: ubuntu-latest | |
env: | |
FOUNDRY_PROFILE: ccip | |
steps: | |
- name: Collect Metrics | |
if: ${{ needs.changes.outputs.changes == 'true' }} | |
id: collect-gha-metrics | |
uses: smartcontractkit/push-gha-metrics-action@0281b09807758be1dcc41651e44e62b353808c47 # v2.1.0 | |
with: | |
org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }} | |
basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }} | |
hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }} | |
this-job-name: Coverage | |
continue-on-error: true | |
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 | |
with: | |
submodules: recursive | |
# Only needed because we use the NPM versions of packages | |
# and not native Foundry. This is to make sure the dependencies | |
# stay in sync. | |
- name: Setup NodeJS | |
uses: ./.github/actions/setup-nodejs | |
- name: Install Foundry | |
uses: foundry-rs/foundry-toolchain@v1 | |
with: | |
version: nightly | |
- name: Run Forge build | |
if: ${{ needs.changes.outputs.changes == 'true' }} | |
working-directory: contracts | |
run: | | |
forge --version | |
forge build | |
id: build | |
- name: Run coverage | |
if: ${{ needs.changes.outputs.changes == 'true' }} | |
working-directory: contracts | |
run: forge coverage --report lcov | |
- name: Prune report | |
if: ${{ needs.changes.outputs.changes == 'true' }} | |
run: | | |
sudo apt-get install lcov | |
./tools/ci/ccip_lcov_prune ./contracts/lcov.info ./lcov.info.pruned | |
- name: Report code coverage | |
if: ${{ needs.changes.outputs.changes == 'true' }} | |
uses: zgosalvez/github-actions-report-lcov@v1 | |
with: | |
update-comment: true | |
coverage-files: lcov.info.pruned | |
minimum-coverage: 98.5 | |
artifact-name: code-coverage-report | |
working-directory: ./contracts | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
product: [vrf, automation, llo-feeds, l2ep, functions, shared, ccip, rebalancer] | |
needs: [changes] | |
name: Foundry Tests ${{ matrix.product }} | |
# See https://github.com/foundry-rs/foundry/issues/3827 | |
runs-on: ubuntu-22.04 | |
# The if statements for steps after checkout repo is workaround for | |
# passing required check for PRs that don't have filtered changes. | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
submodules: recursive | |
# Only needed because we use the NPM versions of packages | |
# and not native Foundry. This is to make sure the dependencies | |
# stay in sync. | |
- name: Setup NodeJS | |
if: needs.changes.outputs.changes == 'true' | |
uses: ./.github/actions/setup-nodejs | |
- name: Install Foundry | |
if: needs.changes.outputs.changes == 'true' | |
uses: foundry-rs/foundry-toolchain@v1 | |
with: | |
# Has to match the `make foundry` version. | |
version: nightly-2cb875799419c907cc3709e586ece2559e6b340e | |
- name: Run Forge build | |
if: needs.changes.outputs.changes == 'true' | |
run: | | |
forge --version | |
forge build | |
id: build | |
working-directory: contracts | |
env: | |
FOUNDRY_PROFILE: ${{ matrix.product }} | |
- name: Run Forge tests | |
if: needs.changes.outputs.changes == 'true' | |
run: | | |
forge test -vvv | |
id: test | |
working-directory: contracts | |
env: | |
FOUNDRY_PROFILE: ${{ matrix.product }} | |
- name: Run Forge snapshot | |
if: ${{ !contains(fromJson('["vrf"]'), matrix.product) && !contains(fromJson('["automation"]'), matrix.product) && needs.changes.outputs.changes == 'true' }} | |
run: | | |
forge snapshot --nmt "testFuzz_\w{1,}?" --check gas-snapshots/${{ matrix.product }}.gas-snapshot | |
id: snapshot | |
working-directory: contracts | |
env: | |
FOUNDRY_PROFILE: ${{ matrix.product }} | |
- name: Collect Metrics | |
if: needs.changes.outputs.changes == 'true' | |
id: collect-gha-metrics | |
uses: smartcontractkit/push-gha-metrics-action@0281b09807758be1dcc41651e44e62b353808c47 # v2.1.0 | |
with: | |
org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }} | |
basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }} | |
hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }} | |
this-job-name: Foundry Tests ${{ matrix.product }} | |
continue-on-error: true |