-
Notifications
You must be signed in to change notification settings - Fork 56
309 lines (255 loc) · 8.93 KB
/
Copy pathci.yml
File metadata and controls
309 lines (255 loc) · 8.93 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
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
env:
CARGO_TERM_COLOR: always
NODE_VERSION: '18'
jobs:
# ─── Smart Contracts ─────────────────────────────────────────────
contracts:
name: Contracts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.85.0
- name: Build contracts
continue-on-error: true
run: cd contracts && cargo build --lib
- name: Run contract tests
continue-on-error: true
run: cd contracts && cargo test
- name: Run gas benchmarks
run: cd contracts && cargo test bench_ -- --nocapture
- name: Generate gas report artifact
if: always()
run: |
echo "=== StarkEd Contracts Gas Report ===" > contracts/gas-report.txt
echo "Generated: $(date -u)" >> contracts/gas-report.txt
echo "Commit: ${{ github.sha }}" >> contracts/gas-report.txt
cd contracts && cargo test bench_gas_report -- --nocapture 2>&1 | tee -a gas-report.txt
continue-on-error: true
- name: Upload gas report
if: always()
uses: actions/upload-artifact@v4
with:
name: gas-report
path: contracts/gas-report.txt
continue-on-error: true
# ─── Backend ─────────────────────────────────────────────────────
backend:
name: Backend
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: starked_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 2
retry_on: error
command: cd backend && npm ci
- name: Type check
run: cd backend && npx tsc --noEmit
- name: Lint
continue-on-error: true
run: cd backend && npm run lint
- name: Test
continue-on-error: true
timeout-minutes: 10
run: cd backend && npm run test:ci
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/starked_test
REDIS_URL: redis://localhost:6379
JWT_SECRET: test_secret
- name: Build
run: cd backend && npm run build
# ─── Frontend ────────────────────────────────────────────────────
frontend:
name: Frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 2
retry_on: error
command: cd frontend && npm install --legacy-peer-deps
- name: Type check
continue-on-error: true
run: cd frontend && npx tsc --noEmit
- name: Lint
continue-on-error: true
run: cd frontend && npm run lint
- name: Test
continue-on-error: true
timeout-minutes: 10
run: cd frontend && npm run test:ci
- name: Build
continue-on-error: true
timeout-minutes: 15
run: cd frontend && NODE_OPTIONS="--max-old-space-size=4096" npm run build
- name: Start server for E2E tests
run: |
cd frontend
npm run build 2>/dev/null || true
npx next start -p 3000 &
sleep 5
env:
NODE_OPTIONS: "--max-old-space-size=4096"
- name: E2E Tests (Playwright)
continue-on-error: true
timeout-minutes: 20
run: |
cd frontend
npx playwright install --with-deps chromium
npm run test:e2e
env:
PLAYWRIGHT_BASE_URL: http://localhost:3000
- name: Upload Playwright report
if: always()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: frontend/playwright-report/
retention-days: 7
# ─── Dependency Audit ────────────────────────────────────────────
dependency-audit:
name: Dependency Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Audit backend dependencies (high/critical)
continue-on-error: true
run: cd backend && npm audit --audit-level=high
- name: Audit frontend dependencies (high/critical)
continue-on-error: true
run: cd frontend && npm audit --audit-level=high
# ─── Cargo Audit (contracts) ─────────────────────────────────────
cargo-audit:
name: Cargo Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.85.0
- name: Install cargo-audit
run: cargo install cargo-audit --version 0.21.1 --locked
- name: Audit contract dependencies
continue-on-error: true
run: cd contracts && cargo audit
# ─── Gas Comparison (PR vs main) ─────────────────────────────────
gas-comparison:
name: Gas Comparison
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
- uses: actions/checkout@v4
with:
path: pr
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Run benchmarks on base (main)
run: |
cd base/contracts
cargo test bench_ -- --nocapture 2>&1 | tee ../base-gas.txt
continue-on-error: true
- name: Run benchmarks on PR
run: |
cd pr/contracts
cargo test bench_ -- --nocapture 2>&1 | tee ../pr-gas.txt
continue-on-error: true
- name: Compare gas reports
run: |
echo "### Gas Comparison Report" >> $GITHUB_STEP_SUMMARY
echo "| Operation | Base (main) | PR | Change |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|-------------|-----|--------|" >> $GITHUB_STEP_SUMMARY
echo "| (see artifacts) | - | - | - |" >> $GITHUB_STEP_SUMMARY
continue-on-error: true
- name: Upload base gas report
if: always()
uses: actions/upload-artifact@v4
with:
name: gas-report-base
path: base/contracts/base-gas.txt
continue-on-error: true
- name: Upload PR gas report
if: always()
uses: actions/upload-artifact@v4
with:
name: gas-report-pr
path: pr/contracts/pr-gas.txt
continue-on-error: true
# ─── Security Scan ───────────────────────────────────────────────
security-scan:
name: Security Scan
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- name: Run Trivy vulnerability scan
uses: aquasecurity/trivy-action@master
continue-on-error: true
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
ignore-unfixed: true
- name: Upload scan results
# Only upload SARIF on push so code-scanning results
# do not block pull requests with pre-existing deps.
if: always() && github.event_name == 'push'
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'