Skip to content

Commit 9b51f5e

Browse files
authored
rename tests, section snapshots, coverage, both pipelines (#3)
* rename tests * use section snapshots * confirm coverage in workflow * confirm snapshots in workflow * test both standard pipeline and via ir
1 parent 59ddee7 commit 9b51f5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1867
-1121
lines changed

.gas-snapshot

Lines changed: 0 additions & 106 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@ name: CI
22

33
on:
44
push:
5+
branches:
6+
- main
57
pull_request:
68
workflow_dispatch:
79

8-
env:
9-
FOUNDRY_PROFILE: ci
10-
1110
jobs:
1211
check:
1312
strategy:
1413
fail-fast: true
14+
matrix:
15+
foundry_profile: ["test-via-ir", "test-no-ir"]
1516

1617
name: Foundry project
1718
runs-on: ubuntu-latest
19+
env:
20+
FOUNDRY_PROFILE: ${{ matrix.foundry_profile }}
1821
steps:
1922
- uses: actions/checkout@v4
2023
with:
@@ -39,7 +42,30 @@ jobs:
3942
forge build --sizes
4043
id: build
4144

42-
- name: Run Forge tests
45+
# This `forge snapshot` command is only used for CBORDecoder comparison.
46+
# https://book.getfoundry.sh/forge/gas-section-snapshots
47+
- name: Confirm comparison snapshot
48+
run: |
49+
forge snapshot --check ${{ env.FOUNDRY_PROFILE }}.gas-snapshot \
50+
--match-path "test/comparison/*"
51+
id: comparison-snapshot
52+
53+
- name: Run remaining Forge tests, confirm section snapshots
4354
run: |
44-
forge test -vvv
55+
forge test -vvv \
56+
--no-match-path "test/comparison/*"
57+
git diff --exit-code snapshots-${{ env.FOUNDRY_PROFILE }}
4558
id: test
59+
60+
61+
# Coverage testing affects gas cost, and creates different snapshots.
62+
# Only `lcov.info` is diffed to confirm coverage is checked in. Coverage
63+
# doesn't use the 'comparison' tests.
64+
- name: Confirm coverage
65+
run: |
66+
forge coverage --report-file ${{ env.FOUNDRY_PROFILE }}.lcov.info \
67+
--report lcov --report summary \
68+
--no-match-path "test/comparison/*" \
69+
--no-match-coverage "test/comparison/*"
70+
git diff --exit-code ${{ env.FOUNDRY_PROFILE }}.lcov.info
71+
id: diff-coverage

foundry.toml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +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-
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
9-
108
[fmt]
11-
int_types = "preserve"
9+
int_types = "preserve"
10+
11+
[profile.test-no-ir]
12+
via-ir = false
13+
snapshots = "snapshots-test-no-ir"
14+
15+
[profile.test-via-ir]
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)