Skip to content

Commit

Permalink
refactor: move forge test intense workflow into separate file (#391)
Browse files Browse the repository at this point in the history
* refactor: move forge intense workflow into separate file

* refactor: remove and modify some small details
  • Loading branch information
nadir-akhtar authored Feb 8, 2025
1 parent 419952c commit c9abbe4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 50 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/forge-test-intense.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Forge Test (Intense)

on:
workflow_dispatch:
push:
branches:
- mainnet
- testnet-holesky
- dev

env:
FOUNDRY_PROFILE: ci
RPC_MAINNET: ${{ secrets.RPC_MAINNET }}
RPC_HOLESKY: ${{ secrets.RPC_HOLESKY }}
CHAIN_ID: ${{ secrets.CHAIN_ID }}

jobs:
# -----------------------------------------------------------------------
# Forge Test (Intense)
# -----------------------------------------------------------------------

forge-test-intense:
name: Test (Intense)
runs-on: ubuntu-latest
steps:
# Check out repository with all submodules for complete codebase access.
- uses: actions/checkout@v4
with:
submodules: recursive

# Install the Foundry toolchain.
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable

# Build the project and display contract sizes.
- name: Forge Build
run: |
forge --version
forge build --sizes
id: build

# Run Forge Test (Intense)
- name: Forge Test (Intense)
run: |
echo -e "\033[1;33mWarning: This workflow may take several hours to complete.\033[0m"
echo -e "\033[1;33mThis intense fuzzing workflow is optional but helps catch edge cases through extended testing.\033[0m"
FOUNDRY_PROFILE=intense forge test -vvv
60 changes: 10 additions & 50 deletions .github/workflows/foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ on:
workflow_dispatch:
push:
branches:
- master
- mainnet
- testnet-goerli
- testnet-holesky
- dev
pull_request:

Expand All @@ -24,93 +23,54 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
# Check out repository with all submodules for complete codebase access.
- uses: actions/checkout@v4
with:
submodules: recursive

# Install the Foundry toolchain.
- name: "Install Foundry"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable

# Run Forge's formatting checker to ensure consistent code style.
- name: "Forge Fmt"
- name: Forge Fmt
run: |
forge fmt --check
id: fmt

# Build the project and display contract sizes.
- name: "Forge Build"
- name: Forge Build
run: |
forge --version
forge build --sizes
id: build

# Run local tests (unit and integration).
- name: "Forge Test (Local)"
- name: Forge Test (Local)
run: forge test -vvv

# Run integration tests using a mainnet fork.
- name: "Forge Test Integration (Fork)"
- name: Forge Test Integration (Fork)
run: FOUNDRY_PROFILE=forktest forge test --match-contract Integration -vvv

# -----------------------------------------------------------------------
# Forge Test (Intense)
# -----------------------------------------------------------------------

continuous-fuzzing:
name: Test (Intense)
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
# Check out repository with all submodules for complete codebase access.
- uses: actions/checkout@v4
with:
submodules: recursive

# Install the Foundry toolchain.
- name: "Install Foundry"
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable

# Build the project and display contract sizes.
- name: "Forge Build"
run: |
forge --version
forge build --sizes
id: build

# Run Forge Test (Intense)
- name: Forge Test (Intense)
run: |
echo -e "\033[1;33mWarning: This workflow may take several hours to complete.\033[0m"
echo -e "\033[1;33mThis intense fuzzing workflow is optional but helps catch edge cases through extended testing.\033[0m"
FOUNDRY_PROFILE=intense forge test -vvv
# -----------------------------------------------------------------------
# Forge Coverage
# -----------------------------------------------------------------------

run-coverage:
name: Coverage
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
# Check out repository with all submodules for complete codebase access.
- uses: actions/checkout@v4
with:
submodules: recursive

# Install the Foundry toolchain.
- name: "Install Foundry"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable
Expand All @@ -122,7 +82,7 @@ jobs:
id: lcov

# Build the project and display contract sizes.
- name: "Forge Build"
- name: Forge Build
run: |
forge --version
forge build --sizes
Expand All @@ -142,7 +102,7 @@ jobs:
path: report/*

# Check coverage threshold after uploading report
- name: Check Coverage Threshold
- name: Check Coverage Threshold for >=90%
run: |
LINES_PCT=$(lcov --summary lcov.info | grep "lines" | cut -d ':' -f 2 | cut -d '%' -f 1 | tr -d '[:space:]')
FUNCTIONS_PCT=$(lcov --summary lcov.info | grep "functions" | cut -d ':' -f 2 | cut -d '%' -f 1 | tr -d '[:space:]')
Expand Down Expand Up @@ -180,7 +140,7 @@ jobs:
submodules: recursive

# Install the Foundry toolchain.
- name: "Install Foundry"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable
Expand Down

0 comments on commit c9abbe4

Please sign in to comment.