-
Notifications
You must be signed in to change notification settings - Fork 0
250 lines (209 loc) · 6.49 KB
/
ci.yml
File metadata and controls
250 lines (209 loc) · 6.49 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
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
lint-backend:
name: Lint Backend (Go)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
working-directory: backend
args: --timeout=5m
build-backend:
name: Build Backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Build backend
working-directory: ./backend
run: go build -v -o sidechain-backend ./cmd/server
- name: Upload backend artifact
uses: actions/upload-artifact@v4
with:
name: sidechain-backend
path: backend/sidechain-backend
retention-days: 5
test-backend:
name: Test Backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Start Docker Compose Services
run: |
cd backend
docker compose up -d
# Wait for all services to be healthy (30 second timeout)
echo "Waiting for services to be healthy..."
for i in {1..30}; do
HEALTHY=$(docker compose ps | grep -c "healthy" || true)
if [ "$HEALTHY" -ge 4 ]; then
echo "✅ Services are healthy"
break
fi
echo "Waiting... ($i/30)"
sleep 1
done
# List running services
echo ""
echo "Running services:"
docker compose ps
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Run Backend Tests
working-directory: ./backend
run: |
# Fix vendor directory if it exists
if [ -d "vendor" ]; then
go mod vendor
fi
go test ./... -v -race -coverprofile=coverage.out -covermode=atomic
- name: Stop Docker Compose Services
if: always()
run: |
cd backend
docker compose down -v
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v5
if: always()
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: backend/coverage.out
flags: backend
name: backend-coverage
fail_ci_if_error: false
verbose: true
build-plugin-debug:
name: Build Plugin (Debug)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Dependencies
uses: ./.github/actions/install-deps
- name: Restore Build Cache
uses: ./.github/actions/restore-build-cache
with:
arch: x86_64
- name: Configure CMake
run: cmake -S plugin -B plugin/build -G Ninja -DCMAKE_BUILD_TYPE=Debug
- name: Build Plugin
run: |
# Limit parallel jobs on Linux to avoid OOM
cmake --build plugin/build --config Debug --parallel 2
- name: Save Build Cache
if: always()
uses: ./.github/actions/save-build-cache
with:
arch: x86_64
static-analysis-cpp:
name: Static Analysis (C++)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cppcheck
run: sudo apt-get install -y cppcheck
- name: Run cppcheck
run: |
cppcheck --version
cppcheck plugin/src \
--enable=all \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--error-exitcode=1
continue-on-error: true
code-quality:
name: Code Quality Checks
runs-on: ubuntu-latest
needs: [test-backend, build-backend]
steps:
- uses: actions/checkout@v4
- name: Check for large files
run: |
# Warn if any file is larger than 1MB
find . -type f -size +1M \
! -path "./.git/*" \
! -path "./.github/*" \
! -path "./plugin/build/*" \
! -path "./backend/build/*" \
! -path "./vendor/*" \
! -path "./node_modules/*" \
-exec echo "Large file: {}" \;
continue-on-error: true
- name: Check for TODO comments
working-directory: ./
run: |
echo "=== TODO comments in code ==="
grep -r "TODO\|FIXME\|HACK" plugin/src/ backend/internal backend/cmd web/src cli/internal cli/pkg || echo "None found"
continue-on-error: true
- name: Check for hardcoded secrets
run: |
if grep -r "password\s*=" . --include="*.go" --include="*.cpp" --include="*.h" | \
grep -v ".env.example" | grep -v "vendor/" | grep -v "test"; then
echo "Warning: Potential hardcoded secrets found"
exit 1
fi
continue-on-error: true
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
continue-on-error: true
- name: Upload Trivy results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
continue-on-error: true
# Final status check
ci-status:
name: CI Status
runs-on: ubuntu-latest
needs: [test-backend, lint-backend, build-backend, build-plugin-debug]
if: always()
steps:
- name: Check CI Status
run: |
if [ "${{ needs.test-backend.result }}" != "success" ]; then
echo "❌ Backend tests failed"
exit 1
fi
if [ "${{ needs.lint-backend.result }}" != "success" ]; then
echo "❌ Linting failed"
exit 1
fi
if [ "${{ needs.build-backend.result }}" != "success" ]; then
echo "❌ Backend build failed"
exit 1
fi
if [ "${{ needs.build-plugin-debug.result }}" != "success" ]; then
echo "❌ Plugin build failed"
exit 1
fi
echo "✅ All CI checks passed"