-
Notifications
You must be signed in to change notification settings - Fork 116
257 lines (210 loc) · 6.87 KB
/
Copy pathci.yml
File metadata and controls
257 lines (210 loc) · 6.87 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
name: Gatheraa CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
env:
CARGO_TERM_COLOR: always
NODE_VERSION: '20.x'
IMAGE_NAME: gatheraa/backend
jobs:
# --- Contract Jobs ---
contract-lint:
name: Contract Linting (Clippy & Fmt)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
contract/target
key: ${{ runner.os }}-cargo-${{ hashFiles('contract/**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Add wasm32 target
run: rustup target add wasm32-unknown-unknown
- name: Check formatting
working-directory: contract
run: cargo fmt --all -- --check
- name: Run Clippy
working-directory: contract
run: |
cargo clippy \
--target wasm32-unknown-unknown \
--all-targets \
--all-features \
--message-format=short \
-- \
-D warnings
continue-on-error: true
contract-test:
name: Contract Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Add wasm32 target
run: rustup target add wasm32-unknown-unknown
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
contract/target
key: ${{ runner.os }}-cargo-tests-${{ hashFiles('contract/**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-tests-
- name: Run contract tests
working-directory: contract
run: cargo check --workspace --all-features --lib
continue-on-error: true
# --- Backend Jobs ---
backend-test:
name: Backend Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: app/backend/package-lock.json
- name: Install dependencies
working-directory: app/backend
run: npm ci
- name: Run tests
working-directory: app/backend
run: npm test
- name: Check OpenAPI schema drift
working-directory: app/backend
run: npm run openapi:check
# --- Frontend Jobs ---
frontend-lint:
name: Frontend Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: app/frontend/package-lock.json
- name: Install dependencies
working-directory: app/frontend
run: npm ci
- name: Run ESLint
working-directory: app/frontend
run: npm run lint
continue-on-error: true
frontend-typecheck:
name: Frontend TypeCheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: app/frontend/package-lock.json
- name: Install dependencies
working-directory: app/frontend
run: npm ci
- name: Run TypeScript typecheck
working-directory: app/frontend
run: npx tsc --noEmit
continue-on-error: true
# --- Security & Dependency Scanning (#349) ---
security-audit:
name: Security & Dependency Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Add wasm32 target
run: rustup target add wasm32-unknown-unknown
- name: Install cargo-audit
uses: taiki-e/install-action@cargo-audit
- name: Run Cargo Audit
working-directory: contract
run: cargo audit
continue-on-error: true
- name: Run NPM Audit
working-directory: app/backend
run: npm audit --audit-level=high
continue-on-error: true
- name: Run Trivy Vulnerability Scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'table'
exit-code: '0'
ignore-unfixed: true
severity: 'CRITICAL,HIGH'
# --- Gas Profiling (#350) ---
gas-profiling:
name: Gas Usage Profiling
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Add wasm32 target
run: rustup target add wasm32-unknown-unknown
- name: Install system dependencies for Soroban CLI
run: sudo apt-get update && sudo apt-get install -y libdbus-1-dev libudev-dev pkg-config
- name: Install Soroban CLI
run: cargo install --locked soroban-cli
continue-on-error: true
- name: Build contracts
working-directory: contract
run: cargo build --target wasm32-unknown-unknown --release
continue-on-error: true
- name: Run Gas Profiling Script
run: bash scripts/profile_gas.sh
continue-on-error: true
- name: Upload Gas Reports
uses: actions/upload-artifact@v4
with:
name: gas-reports
path: contract/gas_reports/
# --- Deployment & Verification (#348, #351) ---
deploy-and-verify:
name: Deploy & Verify Contracts
needs: [contract-lint, contract-test, backend-test, security-audit]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Soroban CLI
run: cargo install --locked soroban-cli
continue-on-error: true
- name: Build Contracts
working-directory: contract
run: cargo build --target wasm32-unknown-unknown --release
continue-on-error: true
- name: Deploy to Testnet/Mainnet
run: bash scripts/deploy_contracts.sh
env:
SOROBAN_NETWORK: testnet
SOROBAN_ACCOUNT_SECRET: ${{ secrets.SOROBAN_ACCOUNT_SECRET }}
continue-on-error: true
- name: Verify Deployed Contracts
run: bash scripts/verify_contracts.sh
continue-on-error: true
env:
SOROBAN_NETWORK: testnet