Repository navigation
259 lines (232 loc) · 7.58 KB
/
Copy pathci.yml
File metadata and controls
259 lines (232 loc) · 7.58 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
name: ci
on:
pull_request:
branches: [production, development]
push:
branches: [production, development]
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
build-test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7.0.0
with:
go-version: '1.26.10'
cache-dependency-path: |
backend/libs/pkg/go.sum
backend/services/*/go.sum
- run: (cd backend && go work sync)
- run: make build
- run: make test
web:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '24'
- run: npm install -g pnpm@12.6.0
- run: make web-check
- run: make web-build
exam-v1:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '24'
- run: npm install -g pnpm@12.6.0
- run: make exam-check
- run: make exam-build
integration-test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7.0.0
with:
go-version: '1.26.10'
cache-dependency-path: |
backend/libs/pkg/go.sum
backend/services/*/go.sum
- run: (cd backend && go work sync)
- run: make test-integration
migration-verification:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7.0.0
with:
go-version: '1.26.10'
cache-dependency-path: backend/libs/pkg/go.sum
- run: make test-migrations
- name: Validate Soft Delete Implementation
run: ./backend/scripts/validate-soft-delete.sh
lint-contracts:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7.0.0
with:
go-version: '1.26.10'
cache-dependency-path: backend/libs/pkg/go.sum
- run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2
- run: go install github.com/bufbuild/buf/cmd/buf@v1.72.0
- run: make fmt-check
- run: make vet
- run: make lint
- run: (cd backend/libs/proto && buf lint)
vulnerability-scan:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7.0.0
with:
go-version: '1.26.10'
cache-dependency-path: |
backend/libs/pkg/go.sum
backend/services/*/go.sum
- run: go install golang.org/x/vuln/cmd/govulncheck@v1.1.4
- run: make vuln
build-images:
needs: [build-test]
if: github.event_name == 'push'
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
id-token: write
strategy:
fail-fast: false
matrix:
service:
- gateway
- identity
- tenant
- user
- question-bank
- assessment
- submission
- judge
- seb
- notification
- analytics
include:
- service: frontend
context: frontend
file: frontend/Dockerfile
- service: tools
context: .
file: deploy/single-server/Dockerfile.tools
steps:
- uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GitHub Container Registry
if: github.ref == 'refs/heads/production'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build (and push on production)
id: build
uses: docker/build-push-action@v7
with:
context: ${{ matrix.context || 'backend' }}
file: ${{ matrix.file || format('backend/services/{0}/Dockerfile', matrix.service) }}
push: ${{ github.ref == 'refs/heads/production' }}
tags: |
ghcr.io/${{ github.repository_owner }}/aethercode-${{ matrix.service }}:latest
ghcr.io/${{ github.repository_owner }}/aethercode-${{ matrix.service }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
- name: Install cosign
if: github.ref == 'refs/heads/production'
uses: sigstore/cosign-installer@v3
- name: Sign image (keyless)
if: github.ref == 'refs/heads/production'
run: |
cosign sign --yes \
ghcr.io/${{ github.repository_owner }}/aethercode-${{ matrix.service }}@${{ steps.build.outputs.digest }}
- name: Generate SBOM
if: github.ref == 'refs/heads/production'
uses: anchore/sbom-action@v0
with:
image: ghcr.io/${{ github.repository_owner }}/aethercode-${{ matrix.service }}@${{ steps.build.outputs.digest }}
format: spdx-json
output-file: sbom-${{ matrix.service }}.spdx.json
artifact-name: sbom-${{ matrix.service }}
- name: Attach SBOM to image
if: github.ref == 'refs/heads/production'
run: |
cosign attach sbom \
--sbom sbom-${{ matrix.service }}.spdx.json \
ghcr.io/${{ github.repository_owner }}/aethercode-${{ matrix.service }}@${{ steps.build.outputs.digest }}
helm-lint:
needs: [build-test]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- name: Install Helm
uses: azure/setup-helm@v5
- name: Lint and render all charts
run: deploy/helm/lint.sh
deploy:
needs:
- build-test
- web
- exam-v1
- integration-test
- migration-verification
- lint-contracts
- vulnerability-scan
- build-images
- helm-lint
if: github.event_name == 'push' && github.ref == 'refs/heads/production'
runs-on: ubuntu-24.04
timeout-minutes: 150
environment: production
steps:
- uses: actions/checkout@v7
- uses: azure/setup-helm@v5
- uses: azure/setup-kubectl@v4
- name: Configure kubeconfig
env:
KUBECONFIG_CONTENT: ${{ secrets.KUBECONFIG }}
run: |
set -euo pipefail
test -n "$KUBECONFIG_CONTENT"
mkdir -p "$HOME/.kube"
chmod 700 "$HOME/.kube"
printf '%s\n' "$KUBECONFIG_CONTENT" > "$HOME/.kube/config"
chmod 600 "$HOME/.kube/config"
- name: Run migrations and deploy production images
env:
IMAGE_TAG: ${{ github.sha }}
run: |
set -euo pipefail
namespace=aethercode
chart=deploy/helm/platform-service
services=(gateway identity tenant user question-bank assessment submission judge seb notification analytics frontend)
helm upgrade migrations deploy/helm/platform-migrations \
--namespace "$namespace" \
--reuse-values \
--set image.tag="$IMAGE_TAG" \
--wait --atomic --timeout 15m
for service in "${services[@]}"; do
helm upgrade "$service" "$chart" \
--namespace "$namespace" \
--reuse-values \
--values "deploy/helm/platform-service/values-$service.yaml" \
--set image.tag="$IMAGE_TAG" \
--wait --atomic --timeout 10m
done
- name: Show production workload status
if: always()
run: kubectl get deployments,pods -n aethercode