Skip to content

ci: report relevant changes from foundry artifacts #12

ci: report relevant changes from foundry artifacts

ci: report relevant changes from foundry artifacts #12

Workflow file for this run

name: Foundry reports
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
on:
pull_request:
push:
branches:
- main
jobs:
gas-report:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Cache Restore
id: cache
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # pin@v4
with:
path: cache
key: ${{ runner.os }}-bgd-foundry-${{ github.sha }}
restore-keys: |
${{ runner.os }}-bgd-foundry-
${{ runner.os }}-
- name: Create backup
if: steps.cache.outputs.cache-matched-key != ''
run: |
cd cache
ls -l
cd ..
cp cache/gas.json cache/gas.backup.json || :
cp cache/lcov.info cache/lcov.backup.info || :
# required
- name: Build
run: forge build
- name: Gas report
run: forge test --fuzz-runs 1 --gas-report --json > cache/gas.json
- uses: bgd-labs/action-foundry-gas-diff@main
id: gas
with:
# The path to the first contract to compare
ROOT_REPORT_PATH: 'cache/gas.backup.json'
# The path to the second contract to compare
REPORT_PATH: 'cache/gas.json'
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Gas report
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Gas report
${{ steps.gas.outputs.gas-report }}
edit-mode: replace
- name: Code coverage
run: forge coverage --fuzz-runs 1 --report lcov --no-match-coverage "(scripts|tests|deployments|mocks)"
# move file to cache folder
- name: Lcov transform
run: mv lcov.info cache/lcov.info
- uses: romeovs/[email protected]
with:
lcov-file: ./cache/lcov.info
lcov-base: ./cache/lcov.backup.info
- name: Cache Save
# if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a # pin@v4
with:
path: cache
key: ${{ runner.os }}-bgd-foundry-${{ github.sha }}