-
Notifications
You must be signed in to change notification settings - Fork 6
80 lines (68 loc) · 1.95 KB
/
test.yml
File metadata and controls
80 lines (68 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: CI
on:
push:
pull_request:
workflow_dispatch:
env:
FOUNDRY_PROFILE: ci
jobs:
test:
name: Foundry Test Suite
runs-on: ubuntu-latest
strategy:
matrix:
suite: [Unit]
steps:
# Check out repository with all submodules for complete codebase access.
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: yarn install
# Restore Forge cache
- name: Cache Forge Build
uses: actions/cache@v4
with:
path: |
cache/
out/
key: ${{ runner.os }}-forge-${{ hashFiles('**/foundry.toml', '**/remappings.txt', 'src/**/*.sol', 'lib/**/*.sol') }}
restore-keys: |
${{ runner.os }}-forge-
# Install the Foundry toolchain.
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable
# Show Forge version
- name: Show Forge version
run: |
forge --version
# Run Forge's formatting checker to ensure consistent code style.
- name: Run Forge fmt
run: |
forge fmt --check
FOUNDRY_PROFILE=test forge fmt --check
id: fmt
# Build the project and display contract sizes.
- name: Run Forge build
run: |
forge build --sizes
id: build
# Run the test suite excluding script directory.
- name: Run ${{ matrix.suite }} tests
run: |
# check if there are test files
if find test -name "*.sol" -type f | grep -q .; then
echo "Found test files, running tests..."
forge test --no-match-path "script/**" -vvv
else
echo "No test files found, skipping tests"
exit 0
fi
env:
FOUNDRY_PROFILE: medium