Skip to content

Commit e6050fd

Browse files
committed
create report scripts
1 parent 19e4d86 commit e6050fd

File tree

3 files changed

+46
-24
lines changed

3 files changed

+46
-24
lines changed

.github/workflows/test.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ on:
55
pull_request:
66
workflow_dispatch:
77

8-
env:
9-
FOUNDRY_PROFILE: ci
10-
118
jobs:
129
check:
1310
strategy:
1411
fail-fast: true
12+
matrix:
13+
foundry_profile: ["test-via-ir", "test-no-ir"]
1514

1615
name: Foundry project
1716
runs-on: ubuntu-latest
17+
env:
18+
FOUNDRY_PROFILE: ${{ matrix.foundry_profile }}
1819
steps:
1920
- uses: actions/checkout@v4
2021
with:
@@ -39,23 +40,30 @@ jobs:
3940
forge build --sizes
4041
id: build
4142

43+
# This `forge snapshot` command is only used for CBORDecoder comparison.
44+
# https://book.getfoundry.sh/forge/gas-section-snapshots
4245
- name: Confirm comparison snapshot
4346
run: |
44-
forge snapshot --match-path "test/comparison/*" --check
47+
forge snapshot --check ${{ env.FOUNDRY_PROFILE }}.gas-snapshot \
48+
--match-path "test/comparison/*"
4549
id: comparison-snapshot
4650

47-
- name: Run all Forge tests
51+
- name: Run remaining Forge tests, confirm section snapshots
4852
run: |
49-
forge test -vvv
53+
forge test -vvv \
54+
--no-match-path "test/comparison/*"
55+
git diff --exit-code snapshots-${{ env.FOUNDRY_PROFILE }}
5056
id: test
5157

52-
- name: Confirm section snapshots
53-
run: |
54-
git diff --exit-code snapshots
55-
id: diff-section-snapshots
5658

59+
# Coverage testing affects gas cost, and creates different snapshots.
60+
# Only `lcov.info` is diffed to confirm coverage is checked in. Coverage
61+
# doesn't use the 'comparison' tests.
5762
- name: Confirm coverage
5863
run: |
59-
forge coverage --report lcov
60-
git diff --exit-code lcov.info
61-
id: diff-coverage
64+
forge coverage --report-file ${{ env.FOUNDRY_PROFILE }}.lcov.info \
65+
--report lcov --report summary \
66+
--no-match-path "test/comparison/*" \
67+
--no-match-coverage "test/comparison/*"
68+
git diff --exit-code ${{ env.FOUNDRY_PROFILE }}.lcov.info
69+
id: diff-coverage

foundry.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[profile.default]
2-
src = "src"
3-
out = "out"
4-
libs = ["lib"]
5-
optimize = true
2+
src = "src"
3+
out = "out"
4+
libs = ["lib"]
5+
optimize = true
66
optimizer_runs = 1000000
77

8+
[fmt]
9+
int_types = "preserve"
10+
811
[profile.test-no-ir]
9-
via-ir = false
12+
via-ir = false
13+
snapshots = "snapshots-test-no-ir"
1014

1115
[profile.test-via-ir]
12-
via-ir = true
13-
14-
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
15-
16-
[fmt]
17-
int_types = "preserve"
16+
via-ir = true
17+
snapshots = "snapshots-test-via-ir"

generate-snapshots.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env sh
2+
3+
set -euxo pipefail
4+
5+
unset FORGE_GAS_REPORT
6+
unset FOUNDRY_PROFILE
7+
unset FOUNDRY_VIA_IR
8+
9+
for test_profile in test-no-ir test-via-ir; do
10+
export FOUNDRY_PROFILE=$test_profile
11+
forge coverage --force --report-file $test_profile.lcov.info --report lcov --report summary --no-match-path "test/comparison/*" --no-match-coverage "test/comparison/*"
12+
forge snapshot --force --snap $test_profile.gas-snapshot --match-path "test/comparison/*"
13+
forge test --force -vvv --no-match-path "test/comparison/*"
14+
done

0 commit comments

Comments
 (0)