-
Notifications
You must be signed in to change notification settings - Fork 15
101 lines (83 loc) · 2.84 KB
/
ci.yml
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: CI
env:
FOUNDRY_PROFILE: "ci"
on:
pull_request:
push:
branches:
- "main"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-0d8302880b79fa9c3c4aa52ab446583dece19a34 # 2024-08-29 release
- name: Check formatting
run: forge fmt --check
- name: "Add lint summary"
run: |
echo "## Lint result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-0d8302880b79fa9c3c4aa52ab446583dece19a34 # 2024-08-29 release
- name: Install dependencies
run: forge install
- name: Compile contracts
run: forge build
- name: Check contract sizes
run: |
forge build && \
for file in out/*.sol/*.json; do
# Skip test files and script files
if [[ "$file" == *".t.sol"* || "$file" == *".s.sol"* ]]; then
continue
fi
# Extract contract name from the file path
contract_name=$(basename $(dirname $file))
# Check if the source file for the contract exists anywhere within src/contracts/
if ! find src/contracts/ -type f -name "${contract_name}.sol" | grep -q .; then
continue
fi
# Calculate the size of the deployed bytecode
size=$(cat "$file" | jq '.deployedBytecode.object' | wc -c | awk '{print int(($1-2)/2)}')
# Check if size exceeds the limit
if [ $size -gt 24576 ]; then
echo "Contract in $file exceeds max size of 24576 bytes (Size: $size bytes)"
exit 1
fi
done
- name: "Add build summary"
run: |
echo "## Build result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
tests:
needs: ["build"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-0d8302880b79fa9c3c4aa52ab446583dece19a34 # 2024-08-29 release
- name: Install dependencies
run: forge install
- name: Compile contracts
run: forge build
- name: Run tests
run: forge test
env:
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
- name: Add test summary
run: |
echo "## Tests result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY