-
Notifications
You must be signed in to change notification settings - Fork 44
197 lines (161 loc) · 5.86 KB
/
Copy pathci.yml
File metadata and controls
197 lines (161 loc) · 5.86 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
name: CI
# ---------------------------------------------------------------------------
# Triggers
# ---------------------------------------------------------------------------
on:
push:
branches: [main]
pull_request:
branches: [main]
# Cancel in-progress runs for the same branch/PR when a new push arrives,
# saving minutes on superseded commits.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
# ---------------------------------------------------------------------------
# Jobs
# ---------------------------------------------------------------------------
jobs:
# -------------------------------------------------------------------------
# 1. Server — type-check + build
# -------------------------------------------------------------------------
server:
name: Server (TypeScript)
runs-on: ubuntu-latest
defaults:
run:
working-directory: server
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: server/package-lock.json
- name: Install dependencies
run: npm ci
# Type-check without emitting files — catches type errors fast
- name: Type-check
run: npx tsc --noEmit
# Full compile to dist/ — confirms the build artefact is valid
- name: Build
run: npm run build
# Upload the compiled artefact so other jobs / releases can use it
- name: Upload server build
uses: actions/upload-artifact@v4
with:
name: server-dist
path: server/dist/
retention-days: 7
# -------------------------------------------------------------------------
# 2. Frontend — type-check + Next.js build
# -------------------------------------------------------------------------
frontend:
name: Frontend (Next.js)
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
# Type-check across the entire Next.js app
- name: Type-check
run: npx tsc --noEmit
# Build the Next.js app — catches import errors, missing env vars
# flagged as required, and invalid page exports.
# NEXT_PUBLIC_API_URL is set to a placeholder so the build doesn't fail
# on a missing env var; the real value is only needed at runtime.
- name: Build
env:
NEXT_PUBLIC_API_URL: http://localhost:3001
run: npm run build
- name: Upload frontend build
uses: actions/upload-artifact@v4
with:
name: frontend-build
path: frontend/.next/
retention-days: 7
# -------------------------------------------------------------------------
# 3. Soroban contract — format check, clippy, tests
# -------------------------------------------------------------------------
contracts:
name: Contracts (Rust / Soroban)
runs-on: ubuntu-latest
defaults:
run:
working-directory: contracts
steps:
- name: Checkout
uses: actions/checkout@v4
# Rust toolchain pinned to match the Soroban SDK requirement.
# The `wasm32v1-none` target is required for `stellar contract build`.
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32v1-none
components: rustfmt, clippy
# Cache the Cargo registry and build artifacts to speed up runs.
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
contracts/target
key: cargo-${{ hashFiles('contracts/Cargo.lock') }}
restore-keys: cargo-
# Enforce consistent formatting (fails on any diff)
- name: Check formatting
run: cargo fmt --all -- --check
# Lint with all Soroban-relevant warnings treated as errors
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
# Run the in-contract unit tests (uses soroban-sdk testutils)
- name: Test
run: cargo test --all-features
# Build the release WASM to confirm it compiles to a deployable artefact.
# This uses the workspace release profile (opt-level=z, LTO, etc.)
- name: Build WASM
run: cargo build --release --target wasm32v1-none
- name: Upload WASM artefact
uses: actions/upload-artifact@v4
with:
name: escrow-wasm
path: contracts/target/wasm32v1-none/release/airflex_escrow.wasm
retention-days: 7
# -------------------------------------------------------------------------
# 4. Security audit — only on pushes to main (not every PR draft)
# -------------------------------------------------------------------------
audit:
name: Dependency Audit
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Audit server dependencies
working-directory: server
# `npm audit` exits non-zero on high/critical vulns
run: npm audit --audit-level=high
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-audit
run: cargo install cargo-audit --locked
- name: Audit Rust dependencies
working-directory: contracts
run: cargo audit