Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 0 additions & 106 deletions .gas-snapshot

This file was deleted.

36 changes: 31 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ name: CI

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true
matrix:
foundry_profile: ["test-via-ir", "test-no-ir"]

name: Foundry project
runs-on: ubuntu-latest
env:
FOUNDRY_PROFILE: ${{ matrix.foundry_profile }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -39,7 +42,30 @@ jobs:
forge build --sizes
id: build

- name: Run Forge tests
# This `forge snapshot` command is only used for CBORDecoder comparison.
# https://book.getfoundry.sh/forge/gas-section-snapshots
- name: Confirm comparison snapshot
run: |
forge snapshot --check ${{ env.FOUNDRY_PROFILE }}.gas-snapshot \
--match-path "test/comparison/*"
id: comparison-snapshot

- name: Run remaining Forge tests, confirm section snapshots
run: |
forge test -vvv
forge test -vvv \
--no-match-path "test/comparison/*"
git diff --exit-code snapshots-${{ env.FOUNDRY_PROFILE }}
id: test


# Coverage testing affects gas cost, and creates different snapshots.
# Only `lcov.info` is diffed to confirm coverage is checked in. Coverage
# doesn't use the 'comparison' tests.
- name: Confirm coverage
run: |
forge coverage --report-file ${{ env.FOUNDRY_PROFILE }}.lcov.info \
--report lcov --report summary \
--no-match-path "test/comparison/*" \
--no-match-coverage "test/comparison/*"
git diff --exit-code ${{ env.FOUNDRY_PROFILE }}.lcov.info
id: diff-coverage
20 changes: 13 additions & 7 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
optimize = true
src = "src"
out = "out"
libs = ["lib"]
optimize = true
optimizer_runs = 1000000

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

[fmt]
int_types = "preserve"
int_types = "preserve"

[profile.test-no-ir]
via-ir = false
snapshots = "snapshots-test-no-ir"

[profile.test-via-ir]
via-ir = true
snapshots = "snapshots-test-via-ir"
14 changes: 14 additions & 0 deletions generate-snapshots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env sh

set -euxo pipefail

unset FORGE_GAS_REPORT
unset FOUNDRY_PROFILE
unset FOUNDRY_VIA_IR

for test_profile in test-no-ir test-via-ir; do
export FOUNDRY_PROFILE=$test_profile
forge coverage --force --report-file $test_profile.lcov.info --report lcov --report summary --no-match-path "test/comparison/*" --no-match-coverage "test/comparison/*"
forge snapshot --force --snap $test_profile.gas-snapshot --match-path "test/comparison/*"
forge test --force -vvv --no-match-path "test/comparison/*"
done
Loading
Loading