-
Notifications
You must be signed in to change notification settings - Fork 117
208 lines (173 loc) · 5.62 KB
/
Copy pathci.yml
File metadata and controls
208 lines (173 loc) · 5.62 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
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 \
-- \
-D warnings \
-D clippy::all \
-D clippy::pedantic \
-W clippy::nursery \
-A clippy::module_name_repetitions \
-A clippy::too_many_arguments \
-A clippy::cast_possible_truncation
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: 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 test --workspace --all-features
# --- 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
# --- Security & Dependency Scanning (#349) ---
security-audit:
name: Security & Dependency Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cargo-audit
uses: taiki-e/install-action@cargo-audit
- name: Run Cargo Audit
working-directory: contract
run: cargo audit
- name: Run NPM Audit
working-directory: app/backend
run: npm audit --audit-level=high
- name: Run Trivy Vulnerability Scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'table'
exit-code: '1'
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: Install Soroban CLI
run: cargo install --locked soroban-cli --features opt
- name: Build contracts
working-directory: contract
run: cargo build --target wasm32-unknown-unknown --release
- 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
- name: Build Contracts
working-directory: contract
run: cargo build --target wasm32-unknown-unknown --release
- name: Deploy to Testnet/Mainnet
run: bash scripts/deploy_contracts.sh
env:
SOROBAN_NETWORK: testnet
SOROBAN_ACCOUNT_SECRET: ${{ secrets.SOROBAN_ACCOUNT_SECRET }}
- name: Verify Deployed Contracts
run: bash scripts/verify_contracts.sh
env:
SOROBAN_NETWORK: testnet
build-and-push-docker:
name: Build & Push Docker Image
needs: [deploy-and-verify]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v5
with:
context: ./app/backend
push: true
tags: ${{ env.IMAGE_NAME }}:${{ github.sha }},${{ env.IMAGE_NAME }}:latest