Skip to content

Commit 6f2de5e

Browse files
authored
Merge pull request #2 from xmtp/feat/helpers
feat: helpers and actions
2 parents bef0240 + a34a18c commit 6f2de5e

34 files changed

+2747
-168
lines changed

.github/CODEOWNERS

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Global rule:
2+
* @xmtp/backend
3+
*.md @xmtp/documentation

.github/workflows/solidity.yml

+346
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
name: Solidity
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
10+
env:
11+
ACTIONS_STEP_DEBUG: true
12+
13+
permissions:
14+
actions: write
15+
pull-requests: write
16+
contents: read
17+
18+
concurrency:
19+
group: ci-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
init:
24+
name: Initialize
25+
runs-on: ubuntu-latest
26+
27+
outputs:
28+
cache-key: ${{ steps.set-cache-key.outputs.cache-key }}
29+
30+
strategy:
31+
fail-fast: true
32+
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
with:
37+
submodules: recursive
38+
39+
- name: Install Foundry
40+
uses: foundry-rs/foundry-toolchain@v1
41+
with:
42+
version: v1.0.0
43+
44+
- name: Set cache key
45+
id: set-cache-key
46+
run: echo "cache-key=ci-${{ hashFiles('**/*') }}" >> "$GITHUB_OUTPUT"
47+
48+
- name: Build contracts
49+
run: forge build
50+
51+
- name: Cache data
52+
uses: actions/cache/save@v4
53+
with:
54+
path: |
55+
build
56+
cache
57+
lib
58+
out
59+
key: ${{ steps.set-cache-key.outputs.cache-key }}
60+
61+
- id: forge
62+
run: echo "forge_path=$(which forge)" >> "$GITHUB_OUTPUT"
63+
64+
- name: Upload forge
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: forge
68+
path: ${{ steps.forge.outputs.forge_path }}
69+
70+
sizes:
71+
name: Contacts Sizes
72+
needs: init
73+
runs-on: ubuntu-latest
74+
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@v4
78+
with:
79+
submodules: recursive
80+
81+
- name: Restore cache
82+
uses: actions/cache/restore@v4
83+
with:
84+
path: |
85+
build
86+
cache
87+
lib
88+
out
89+
key: ${{ needs.init.outputs.cache-key }}
90+
91+
- name: Restore forge
92+
uses: actions/download-artifact@v4
93+
with:
94+
name: forge
95+
path: /usr/local/bin
96+
97+
- run: chmod +x /usr/local/bin/forge
98+
99+
- name: Run Forge build with sizes
100+
run: forge build --sizes
101+
102+
test:
103+
name: Tests
104+
needs: init
105+
runs-on: ubuntu-latest
106+
107+
steps:
108+
- name: Checkout
109+
uses: actions/checkout@v4
110+
with:
111+
submodules: recursive
112+
113+
- name: Restore cache
114+
uses: actions/cache/restore@v4
115+
with:
116+
path: |
117+
build
118+
cache
119+
lib
120+
out
121+
key: ${{ needs.init.outputs.cache-key }}
122+
123+
- name: Restore forge
124+
uses: actions/download-artifact@v4
125+
with:
126+
name: forge
127+
path: /usr/local/bin
128+
129+
- run: chmod +x /usr/local/bin/forge
130+
131+
- name: Run Forge tests
132+
run: forge test -vvv
133+
134+
gas:
135+
name: Gas Report
136+
needs: init
137+
runs-on: ubuntu-latest
138+
139+
steps:
140+
- name: Checkout
141+
uses: actions/checkout@v4
142+
with:
143+
submodules: recursive
144+
145+
- name: Restore cache
146+
uses: actions/cache/restore@v4
147+
with:
148+
path: |
149+
build
150+
cache
151+
lib
152+
out
153+
key: ${{ needs.init.outputs.cache-key }}
154+
155+
- name: Restore forge
156+
uses: actions/download-artifact@v4
157+
with:
158+
name: forge
159+
path: /usr/local/bin
160+
161+
- run: chmod +x /usr/local/bin/forge
162+
163+
- name: Run Forge tests with gas report
164+
run: forge test --gas-report --gas-limit 2000000000 > gasreport.ansi
165+
env:
166+
# make fuzzing semi-deterministic to avoid noisy gas cost estimation
167+
# due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds)
168+
FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}
169+
170+
- name: Compare gas reports
171+
uses: Rubilmax/foundry-gas-diff@v3.21
172+
id: gas_diff
173+
174+
- name: Add gas diff to sticky comment
175+
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
176+
uses: marocchino/sticky-pull-request-comment@v2
177+
with:
178+
# delete the comment in case changes no longer impact gas costs
179+
delete: ${{ !steps.gas_diff.outputs.markdown }}
180+
message: ${{ steps.gas_diff.outputs.markdown }}
181+
182+
coverage:
183+
name: Code Coverage
184+
needs: init
185+
runs-on: ubuntu-latest
186+
187+
steps:
188+
- name: Checkout
189+
uses: actions/checkout@v4
190+
with:
191+
submodules: recursive
192+
193+
- name: Restore cache
194+
uses: actions/cache/restore@v4
195+
with:
196+
path: |
197+
build
198+
cache
199+
lib
200+
out
201+
key: ${{ needs.init.outputs.cache-key }}
202+
203+
- name: Restore forge
204+
uses: actions/download-artifact@v4
205+
with:
206+
name: forge
207+
path: /usr/local/bin
208+
209+
- run: chmod +x /usr/local/bin/forge
210+
211+
- name: Install lcov
212+
uses: hrishikesh-kadam/setup-lcov@v1
213+
214+
- name: Run coverage
215+
id: coverage
216+
run: forge coverage --no-match-coverage "(script|test)" --gas-limit 2000000000 --report lcov && lcov --extract lcov.info --rc lcov_branch_coverage=1 --rc derive_function_end_line=0 -o lcov.info 'src/*' && genhtml lcov.info --rc branch_coverage=1 --rc derive_function_end_line=0 -o coverage
217+
218+
- name: Report code coverage
219+
uses: zgosalvez/github-actions-report-lcov@v4
220+
with:
221+
coverage-files: lcov.info
222+
artifact-name: code-coverage-report
223+
minimum-coverage: 95
224+
github-token: ${{ secrets.GITHUB_TOKEN }}
225+
update-comment: true
226+
227+
lint:
228+
name: Lint check
229+
needs: init
230+
runs-on: ubuntu-latest
231+
232+
steps:
233+
- name: Checkout
234+
uses: actions/checkout@v4
235+
with:
236+
submodules: recursive
237+
238+
- name: Restore cache
239+
uses: actions/cache/restore@v4
240+
with:
241+
path: |
242+
build
243+
cache
244+
lib
245+
out
246+
key: ${{ needs.init.outputs.cache-key }}
247+
248+
- name: Restore forge
249+
uses: actions/download-artifact@v4
250+
with:
251+
name: forge
252+
path: /usr/local/bin
253+
254+
- run: chmod +x /usr/local/bin/forge
255+
256+
- name: Node
257+
uses: actions/setup-node@v4
258+
with:
259+
node-version: 23
260+
261+
- name: Install dev dependencies
262+
run: npm ci
263+
264+
- name: Run Solhint check
265+
run: npm run solhint
266+
267+
prettier:
268+
name: Formatting check
269+
needs: init
270+
runs-on: ubuntu-latest
271+
272+
steps:
273+
- name: Checkout
274+
uses: actions/checkout@v4
275+
with:
276+
submodules: recursive
277+
278+
- name: Restore cache
279+
uses: actions/cache/restore@v4
280+
with:
281+
path: |
282+
build
283+
cache
284+
lib
285+
out
286+
key: ${{ needs.init.outputs.cache-key }}
287+
288+
- name: Restore forge
289+
uses: actions/download-artifact@v4
290+
with:
291+
name: forge
292+
path: /usr/local/bin
293+
294+
- run: chmod +x /usr/local/bin/forge
295+
296+
- name: Node
297+
uses: actions/setup-node@v4
298+
with:
299+
node-version: 23
300+
301+
- name: Install dev dependencies
302+
run: npm ci
303+
304+
- name: Run Prettier check
305+
run: npm run prettier-check
306+
307+
slither:
308+
name: Slither
309+
needs: init
310+
runs-on: ubuntu-latest
311+
if: github.actor != 'dependabot[bot]'
312+
313+
steps:
314+
- name: Checkout
315+
uses: actions/checkout@v4
316+
with:
317+
submodules: recursive
318+
319+
- name: Restore cache
320+
uses: actions/cache/restore@v4
321+
with:
322+
path: |
323+
build
324+
cache
325+
lib
326+
out
327+
key: ${{ needs.init.outputs.cache-key }}
328+
329+
- name: Restore forge
330+
uses: actions/download-artifact@v4
331+
with:
332+
name: forge
333+
path: /usr/local/bin
334+
335+
- run: chmod +x /usr/local/bin/forge
336+
337+
- name: Install Slither
338+
run: pip3 install slither-analyzer
339+
340+
- name: Run Slither
341+
run: slither . --sarif output.sarif
342+
343+
- name: Upload SARIF file
344+
uses: github/codeql-action/upload-sarif@v3
345+
with:
346+
sarif_file: output.sarif

.gitignore

+11-10
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,24 @@ cache/
33
out/
44

55
# Ignores development broadcast logs
6-
!/broadcast
7-
/broadcast/*/11155111/
8-
/broadcast/*/241320161/
9-
/broadcast/*/31337/
10-
/broadcast/**/dry-run/
6+
broadcast/**/*run*
117

12-
# Ignores development deployments
13-
contracts/config/anvil_localnet/*
14-
*.tmp.log
8+
# Coverage files
9+
coverage/
10+
lcov.info
1511

1612
# Docs
1713
docs/
1814

1915
# Dotenv file
2016
.env
2117

22-
# Soldeer
23-
/dependencies
18+
# Mac OS files
19+
.DS_Store
20+
21+
# NPM modules
22+
node_modules
23+
24+
gasreport.ansi
2425

2526
.vscode/

0 commit comments

Comments
 (0)