Skip to content

Commit

Permalink
ci: simplify contracts bedrock tests job (#11966)
Browse files Browse the repository at this point in the history
Simplifies the contracts-bedrock-tests job so that it takes more
parameters but makes the test command unified. Also replaces the
complex script for checking for modified fuzz tests and simply
heavily fuzzes all tests within any test files that have changed.
  • Loading branch information
smartcontracts authored Sep 18, 2024
1 parent c40dfed commit 7a10c31
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 167 deletions.
47 changes: 31 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,13 @@ jobs:
description: Number of test jobs to run in parallel
type: integer
default: 4
test_command:
test_list:
description: List of test files to run
type: string
test_fuzz_runs:
description: Number of fuzz runs to apply
type: integer
default: 512
test_timeout:
description: Timeout for running tests
type: string
Expand All @@ -599,6 +603,15 @@ jobs:
- checkout
- attach_workspace: { at: "." }
- install-contracts-dependencies
- run:
name: Check if test list is empty
command: |
TEST_FILES=$(<<parameters.test_list>>)
if [ -z "$TEST_FILES" ]; then
echo "No test files to run. Exiting early."
circleci-agent step halt
fi
working_directory: packages/contracts-bedrock
- check-changed:
patterns: contracts-bedrock,op-node
- restore_cache:
Expand All @@ -610,30 +623,36 @@ jobs:
- golang-build-cache-contracts-bedrock-tests-{{ checksum "go.sum" }}
- golang-build-cache-contracts-bedrock-tests-
- run:
name: print dependencies
name: Print dependencies
command: just dep-status
working_directory: packages/contracts-bedrock
- run:
name: print forge version
name: Print forge version
command: forge --version
working_directory: packages/contracts-bedrock
- run:
name: Pull artifacts
command: bash scripts/ops/pull-artifacts.sh
working_directory: packages/contracts-bedrock
- run:
name: build go-ffi
name: Build go-ffi
command: just build-go-ffi
working_directory: packages/contracts-bedrock
- run:
name: run tests
command: <<parameters.test_command>>
name: Run tests
command: |
TEST_FILES=$(<<parameters.test_list>>)
TEST_FILES=$(echo "$TEST_FILES" | circleci tests split --split-by=timings)
TEST_FILES=$(echo "$TEST_FILES" | sed 's|^test/||')
MATCH_PATH="./test/{$(echo "$TEST_FILES" | paste -sd "," -)}"
export FOUNDRY_INVARIANT_RUNS=<<parameters.test_fuzz_runs>>
forge test --deny-warnings --fuzz-runs <<parameters.test_fuzz_runs>> --match-path "$MATCH_PATH"
environment:
FOUNDRY_PROFILE: ci
working_directory: packages/contracts-bedrock
no_output_timeout: <<parameters.test_timeout>>
- run:
name: print failed test traces
name: Print failed test traces
command: just test-rerun
environment:
FOUNDRY_PROFILE: ci
Expand Down Expand Up @@ -1626,23 +1645,19 @@ workflows:
# Test everything except PreimageOracle.t.sol since it's slow.
name: contracts-bedrock-tests
test_parallelism: 4
test_command: |
TEST_FILES=$(find . -name "*.t.sol" -not -name "PreimageOracle.t.sol")
TEST_FILES=$(echo "$TEST_FILES" | circleci tests split --split-by=timings)
TEST_FILES=$(echo "$TEST_FILES" | sed 's|./test/||')
MATCH_PATH="./test/{$(echo "$TEST_FILES" | paste -sd "," -)}"
forge test --deny-warnings --match-path "$MATCH_PATH"
test_list: find test -name "*.t.sol" -not -name "PreimageOracle.t.sol"
- contracts-bedrock-tests:
# PreimageOracle test is slow, run it separately to unblock CI.
name: contracts-bedrock-tests-preimage-oracle
test_parallelism: 1
test_command: forge test --deny-warnings --match-path ./test/cannon/PreimageOracle.t.sol
test_list: find test -name "PreimageOracle.t.sol"
- contracts-bedrock-tests:
# Heavily fuzz any fuzz tests that have been added or modified.
# Heavily fuzz any fuzz tests within added or modified test files.
name: contracts-bedrock-tests-heavy-fuzz-modified
test_parallelism: 1
test_list: git diff origin/develop...HEAD --name-only -- './test/**/*.t.sol' | sed 's|packages/contracts-bedrock/||'
test_timeout: 1h
test_command: just test-heavy-fuzz-modified-tests
test_fuzz_runs: 10000
- contracts-bedrock-coverage
- contracts-bedrock-checks:
requires:
Expand Down
4 changes: 0 additions & 4 deletions packages/contracts-bedrock/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ test-kontrol-no-build:
test-rerun: build-go-ffi
forge test --rerun -vvv

# Run extra fuzz iterations for modified fuzz tests.
test-heavy-fuzz-modified-tests: build-go-ffi
./scripts/testing/test-heavy-fuzz-modified-tests.sh

genesis:
forge script scripts/L2Genesis.s.sol:L2Genesis --sig 'runWithStateDump()'

Expand Down

This file was deleted.

0 comments on commit 7a10c31

Please sign in to comment.