-
Notifications
You must be signed in to change notification settings - Fork 93
422 lines (347 loc) · 13.1 KB
/
Copy pathci.yml
File metadata and controls
422 lines (347 loc) · 13.1 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
name: CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
ci:
name: Continuous Integration
strategy:
matrix:
# Pruned to Linux for reliability; cross-OS Rust build is covered by rust.yml.
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install stable Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install WASM target
run: rustup target add wasm32-unknown-unknown
- name: Cache cargo registry & build artifacts
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install Z3 (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libz3-dev
- name: Install Z3 (macOS)
if: runner.os == 'macOS'
run: |
brew install z3 llvm
echo "Z3_SYS_Z3_HEADER=$(brew --prefix z3)/include/z3.h" >> $GITHUB_ENV
echo "LIBRARY_PATH=$(brew --prefix z3)/lib:$LIBRARY_PATH" >> $GITHUB_ENV
echo "CPATH=$(brew --prefix z3)/include:$CPATH" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config" >> $GITHUB_ENV
- name: Install Z3 (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$z3Version = "4.13.3"
$url = "https://github.com/Z3Prover/z3/releases/download/z3-$z3Version/z3-$z3Version-x64-win.zip"
Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\z3.zip"
Expand-Archive "$env:TEMP\z3.zip" -DestinationPath "C:\z3"
$z3Dir = (Get-ChildItem "C:\z3" -Directory | Select-Object -First 1).FullName
echo "Z3_SYS_Z3_HEADER=$z3Dir\include\z3.h" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "LIB=$z3Dir\bin;$env:LIB" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "CPATH=$z3Dir\include;$env:CPATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "LIBCLANG_PATH=C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install system dependencies (Linux only)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libdbus-1-dev libudev-dev pkg-config
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
- name: Install dependencies and Lint (make lint smoke test)
run: |
npm ci
make lint
- name: Check formatting
run: cargo fmt --all --check
- name: Run Clippy (workspace)
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: Run Clippy (runtime guard wasm target)
run: cargo clippy -p runtime-guard-wrapper --target wasm32-unknown-unknown -- -D warnings
- name: Build All (Debug)
run: |
cargo build -p sanctifier-core --all-features
cd tooling/sanctifier-cli && cargo build
- name: Run All Tests
run: |
cargo test -p sanctifier-core --all-features
cargo test -p sanctifier-cli
- name: Run action unit tests
run: |
python -m unittest discover -s tests/action -p "test_*.py"
python -m unittest discover -s tests/vulnerability_db -p "test_*.py"
- name: Code coverage (Linux only)
if: runner.os == 'Linux'
continue-on-error: true
run: |
command -v cargo-tarpaulin >/dev/null || cargo install cargo-tarpaulin --locked --quiet
cargo tarpaulin --workspace --out Xml --output-dir coverage/
- name: Upload coverage to Codecov (Linux only)
if: runner.os == 'Linux'
continue-on-error: true
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/cobertura.xml
fail_ci_if_error: false
slug: HyperSafeD/Sanctifier
- name: Build Release CLI
run: cd tooling/sanctifier-cli && cargo build --release
frontend-test:
name: Frontend Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Build WASM stub
run: |
mkdir -p tooling/sanctifier-wasm/pkg
echo '{"name":"@sanctifier/wasm","version":"0.0.0","main":"index.js"}' > tooling/sanctifier-wasm/pkg/package.json
echo 'module.exports = {};' > tooling/sanctifier-wasm/pkg/index.js
- name: Install frontend dependencies
run: cd frontend && npm install
- name: Run unit tests
run: cd frontend && npm test
- name: Generate coverage report
run: cd frontend && npm run test:coverage
continue-on-error: true
- name: Upload coverage artifact
uses: actions/upload-artifact@v6
with:
name: frontend-coverage
path: frontend/coverage/
retention-days: 7
docs-specs-integration:
name: Docs/specs integration coverage
runs-on: ubuntu-latest
# Documentation/spec coverage is informative; do not block core CI on it.
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- name: Validate docs/specs coverage
run: npm run docs:specs:check
contracts-sep41-fixtures:
name: Contracts SEP-41 Fixture Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install stable Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build Sanctifier CLI
run: cargo build -p sanctifier-cli
- name: Run SEP-41 fixture contract tests
run: cargo test -p my-contract
- name: Validate S012 fixture output via CLI
run: |
cargo run --quiet --bin sanctifier -- analyze contracts/fixtures/finding-codes/s012_token_interface.rs --format json > /tmp/s012-report.json
grep -q '"S012"' /tmp/s012-report.json
frontend-e2e:
name: Frontend E2E Tests (Playwright)
runs-on: ubuntu-latest
# Browser E2E is flaky under CI containers; keep it running but non-blocking.
continue-on-error: true
container:
image: mcr.microsoft.com/playwright:v1.59.1-jammy
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Build WASM stub
run: |
mkdir -p tooling/sanctifier-wasm/pkg
echo '{"name":"@sanctifier/wasm","version":"0.0.0","main":"index.js"}' > tooling/sanctifier-wasm/pkg/package.json
echo 'module.exports = {};' > tooling/sanctifier-wasm/pkg/index.js
- name: Install frontend dependencies
run: cd frontend && npm install
- name: Run e2e tests
continue-on-error: true
run: cd frontend && npm run test:e2e
- name: Upload Playwright artifacts
if: always()
uses: actions/upload-artifact@v6
with:
name: playwright-artifacts
path: |
frontend/playwright-report/
frontend/test-results/
retention-days: 7
frontend-schema-e2e:
name: Frontend Schema Rendering E2E
runs-on: ubuntu-latest
# Browser E2E is flaky under CI containers; keep it running but non-blocking.
continue-on-error: true
container:
image: mcr.microsoft.com/playwright:v1.59.1-jammy
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Build WASM stub
run: |
mkdir -p tooling/sanctifier-wasm/pkg
echo '{"name":"@sanctifier/wasm","version":"0.0.0","main":"index.js"}' > tooling/sanctifier-wasm/pkg/package.json
echo 'module.exports = {};' > tooling/sanctifier-wasm/pkg/index.js
- name: Install frontend dependencies
run: cd frontend && npm install
- name: Run schema rendering e2e suite
continue-on-error: true
run: cd frontend && npm run test:e2e:schema
contract-docs:
name: Contract ABI / Interface Docs
runs-on: ubuntu-latest
continue-on-error: true # non-blocking: cargo doc can fail on transient crates.io network errors
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install stable Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry & build artifacts
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-contract-docs-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-contract-docs-
- name: Generate contract docs and interface summary
run: make contract-docs
- name: Verify interface summary is up-to-date
run: |
# Run extraction-only check (rustdoc already generated above)
SKIP_RUSTDOC=1 bash scripts/gen-contract-docs.sh --check
- name: Run ABI surface stability tests (amm-pool)
run: cargo test -p amm-pool --test integration_tests abi_ -- --nocapture
- name: Upload rustdoc artifact
uses: actions/upload-artifact@v6
with:
name: contract-rustdoc
path: target/doc/
retention-days: 14
- name: Upload interface JSON artifact
uses: actions/upload-artifact@v6
with:
name: contract-interfaces-json
path: docs/generated/contract-interfaces.json
retention-days: 14
commitlint:
name: Lint Commit Messages
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
- name: Install commitlint
run: |
cd frontend
npm install --save-dev @commitlint/cli @commitlint/config-conventional
- name: Validate PR commits
run: |
cd frontend
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
wasm:
name: Build WASM Package
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install stable Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Cache cargo registry & build artifacts
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
tooling/sanctifier-wasm/target/
key: ${{ runner.os }}-wasm-${{ hashFiles('tooling/sanctifier-wasm/Cargo.lock', 'tooling/sanctifier-core/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-wasm-
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build WASM package
run: |
cd tooling/sanctifier-wasm
wasm-pack build --target web --out-dir pkg --out-name sanctifier_wasm
# Inject the npm package name expected by the frontend
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('pkg/package.json', 'utf8'));
pkg.name = '@sanctifier/wasm';
fs.writeFileSync('pkg/package.json', JSON.stringify(pkg, null, 2));
"
- name: Verify CSP Compliance
run: |
cd tooling/sanctifier-wasm
node scripts/verify-csp-compliance.js
- name: Upload WASM artifact
uses: actions/upload-artifact@v6
with:
name: sanctifier-wasm-pkg
path: tooling/sanctifier-wasm/pkg/
retention-days: 7