-
Notifications
You must be signed in to change notification settings - Fork 20
266 lines (214 loc) · 7.19 KB
/
ci.yml
File metadata and controls
266 lines (214 loc) · 7.19 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
name: CI
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
env:
CARGO_TERM_COLOR: always
PYTHON_VERSION: '3.11'
NODE_VERSION: '18'
jobs:
smart-contracts:
name: Smart Contracts (Rust/Soroban)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy, rustfmt
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
smartcontract/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install wasm32 target
run: rustup target add wasm32-unknown-unknown
- name: Check formatting
run: cargo fmt --all -- --check
working-directory: smartcontract
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
working-directory: smartcontract
- name: Build smart contract
run: cargo build --target wasm32-unknown-unknown --release
working-directory: smartcontract
- name: Run tests
run: cargo test --all-features
working-directory: smartcontract
- name: Upload WASM artifact
uses: actions/upload-artifact@v3
with:
name: chainbridge-wasm
path: smartcontract/target/wasm32-unknown-unknown/release/*.wasm
retention-days: 7
backend:
name: Backend (Python/FastAPI)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black mypy pytest pytest-cov
if [ -f backend/requirements.txt ]; then pip install -r backend/requirements.txt; fi
- name: Check formatting with Black
run: black --check backend/
- name: Lint with flake8
run: |
flake8 backend/ --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 backend/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Type check with mypy
run: mypy backend/ --ignore-missing-imports
- name: Run tests with coverage
run: |
pytest backend/ --cov=backend --cov-report=xml --cov-report=html -v
continue-on-error: true
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: backend-coverage
path: htmlcov/
retention-days: 7
frontend:
name: Frontend (Next.js/TypeScript)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
working-directory: frontend
- name: Check formatting
run: npm run format:check
working-directory: frontend
continue-on-error: true
- name: Lint
run: npm run lint
working-directory: frontend
- name: Type check
run: npm run type-check
working-directory: frontend
- name: Build
run: npm run build
working-directory: frontend
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: frontend-build
path: frontend/.next/
retention-days: 7
relayer:
name: Relayer (Rust)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy, rustfmt
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
relayer/target
key: ${{ runner.os }}-cargo-relayer-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-relayer-
- name: Check formatting
run: cargo fmt --all -- --check
working-directory: relayer
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
working-directory: relayer
- name: Build
run: cargo build --release
working-directory: relayer
- name: Run tests
run: cargo test
working-directory: relayer
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: [smart-contracts, backend]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
tests/target
key: ${{ runner.os }}-cargo-tests-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-tests-
- name: Run integration tests
if: ${{ hashFiles('tests/Cargo.toml') != '' }}
run: cargo test --manifest-path tests/Cargo.toml --verbose
- name: Skip missing integration crate
if: ${{ hashFiles('tests/Cargo.toml') == '' }}
run: echo "tests/Cargo.toml not present; skipping integration-tests job."
- name: Run stress tests
if: ${{ hashFiles('tests/Cargo.toml') != '' }}
run: cargo test --manifest-path tests/Cargo.toml -- stress --test-threads=1
code-quality:
name: Code Quality Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run CodeQL Init
uses: github/codeql-action/init@v2
with:
languages: python, javascript, typescript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
coverage-report:
name: Generate Coverage Report
runs-on: ubuntu-latest
needs: [smart-contracts, backend, frontend]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Generate coverage summary
run: |
echo "## Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Coverage reports have been generated and uploaded as artifacts." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- Smart Contracts: Run \`cargo test\` locally for coverage" >> $GITHUB_STEP_SUMMARY
echo "- Backend: Check uploaded artifacts for HTML coverage report" >> $GITHUB_STEP_SUMMARY
echo "- Frontend: Run \`npm test\` locally for coverage" >> $GITHUB_STEP_SUMMARY