Skip to content

Commit babda83

Browse files
committed
chore: update GitHub Actions workflow for testing and coverage
1 parent b0257a3 commit babda83

File tree

1 file changed

+111
-26
lines changed

1 file changed

+111
-26
lines changed

Diff for: .github/workflows/test.yml

+111-26
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,128 @@
1-
name: CI
1+
name: "TEST"
22

33
on:
4-
push:
54
pull_request:
6-
workflow_dispatch:
5+
push:
6+
branches:
7+
- "main"
78

89
env:
9-
FOUNDRY_PROFILE: ci
10+
API_KEY_INFURA: ${{secrets.API_KEY_INFURA}}
11+
API_KEY_OPTIMISTIC_ETHERSCAN: ${{secrets.API_KEY_OPTIMISTIC_ETHERSCAN}}
12+
API_KEY_ETHERSCAN: ${{secrets.API_KEY_ETHERSCAN}}
13+
API_KEY_ALCHEMY: ${{secrets.API_KEY_ALCHEMY}}
1014

1115
jobs:
12-
check:
13-
strategy:
14-
fail-fast: true
15-
16-
name: Foundry project
17-
runs-on: ubuntu-latest
16+
build:
17+
runs-on: "ubuntu-latest"
1818
steps:
19-
- uses: actions/checkout@v4
19+
- name: "Check out the repo"
20+
uses: "actions/checkout@v4"
21+
22+
- name: "Install Foundry"
23+
uses: "foundry-rs/foundry-toolchain@v1"
2024
with:
21-
submodules: recursive
25+
version: nightly
2226

23-
- name: Install Foundry
24-
uses: foundry-rs/foundry-toolchain@v1
27+
- name: "Install foundry libs"
28+
run: "forge install"
2529

26-
- name: Show Forge version
27-
run: |
28-
forge --version
30+
- name: "Build the contracts"
31+
run: "forge build"
2932

30-
- name: Run Forge fmt
33+
- name: "Add build summary"
3134
run: |
32-
forge fmt --check
33-
id: fmt
35+
echo "## Build result" >> $GITHUB_STEP_SUMMARY
36+
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
37+
38+
test:
39+
needs: ["build"]
40+
runs-on: "ubuntu-latest"
41+
steps:
42+
- name: "Check out the repo"
43+
uses: "actions/checkout@v4"
44+
45+
- name: "Install Foundry"
46+
uses: "foundry-rs/foundry-toolchain@v1"
47+
with:
48+
version: nightly
49+
50+
- name: "Install pnpm"
51+
uses: "pnpm/action-setup@v4"
52+
with:
53+
version: 9.5.0
54+
run_install: true
55+
56+
- name: "Install pnpm dependencies"
57+
run: "pnpm install"
58+
59+
- name: "Install foundry libs"
60+
run: "forge install"
61+
62+
- name: "Build the contracts"
63+
run: "pnpm build"
64+
65+
- name: "Show the Foundry config"
66+
run: "forge config"
3467

35-
- name: Run Forge build
68+
- name: "Run the fork tests for Optimism"
69+
run: "pnpm test:op -vvv"
70+
71+
- name: "Add test summary"
3672
run: |
37-
forge build --sizes
38-
id: build
73+
echo "## Tests result" >> $GITHUB_STEP_SUMMARY
74+
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
75+
76+
coverage:
77+
needs: ["test"]
78+
runs-on: "ubuntu-latest"
79+
steps:
80+
- name: "Check out the repo"
81+
uses: "actions/checkout@v4"
82+
83+
- name: "Install Foundry"
84+
uses: "foundry-rs/foundry-toolchain@v1"
85+
with:
86+
version: nightly
87+
88+
- name: "Install pnpm"
89+
uses: "pnpm/action-setup@v4"
90+
with:
91+
version: 9.5.0
92+
run_install: true
93+
94+
- name: "Install pnpm dependencies"
95+
run: "pnpm install"
3996

40-
- name: Run Forge tests
97+
- name: "Install foundry libs"
98+
run: "forge install"
99+
100+
- name: "Build the contracts"
101+
run: "pnpm build"
102+
103+
# Generate coverage report
104+
- name: Run coverage
105+
run: pnpm test:coverage --report summary --report lcov
106+
107+
# Adjust the paths in this step to exclude specific directories from coverage analysis.
108+
- name: Filter directories
41109
run: |
42-
forge test -vvv
43-
id: test
110+
sudo apt update && sudo apt install -y lcov
111+
lcov --ignore-errors unused --remove lcov.info 'test/*' 'script/*' --output-file lcov.info --rc branch_coverage=1
112+
113+
# This step automatically publishes a comprehensive coverage report as a comment on each push and
114+
# removes any previous comments.
115+
- name: Post coverage report
116+
if: github.event_name == 'pull_request'
117+
uses: romeovs/[email protected]
118+
with:
119+
delete-old-comments: true
120+
lcov-file: ./lcov.info
121+
github-token: ${{ secrets.GITHUB_TOKEN }} # Adds a coverage summary comment to the PR.
122+
123+
# This step verifies that the minimum coverage threshold is met and fails if it is not.
124+
- name: Verify minimum coverage
125+
uses: zgosalvez/github-actions-report-lcov@v4
126+
with:
127+
coverage-files: ./lcov.info
128+
minimum-coverage: 80 # Set coverage threshold.

0 commit comments

Comments
 (0)