-
Notifications
You must be signed in to change notification settings - Fork 0
328 lines (285 loc) · 8.96 KB
/
ci.yml
File metadata and controls
328 lines (285 loc) · 8.96 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
name: CI Pipeline
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
jobs:
validate_api:
name: Validate API Specifications
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install Redocly CLI
run: npm install -g @redocly/cli@latest
- name: Lint OpenAPI Specifications
run: |
redocly lint api/*.yaml --format summary
generate_api_code:
name: Generate Code from OpenAPI
runs-on: ubuntu-latest
needs: [validate_api]
if: ${{ always() && (needs.validate_api.result == 'success' || needs.validate_api.result == 'skipped') }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.13'
cache: 'pip'
- name: Install OpenAPI Generator
run: |
npm install -g @openapitools/openapi-generator-cli
pip install openapi-python-client
- name: Generate Code
run: |
chmod +x api/scripts/gen-all.sh
./api/scripts/gen-all.sh
# Upload separate artifacts for each service
- name: Upload client artifact
uses: actions/upload-artifact@v4
with:
name: client-code
path: ./client
if-no-files-found: error
- name: Set executable permissions for gradlew files
run: |
chmod +x gateway/gradlew
chmod +x user-svc/gradlew
chmod +x concept-svc/gradlew
ls -la gateway/gradlew
ls -la user-svc/gradlew
ls -la concept-svc/gradlew
- name: Upload gateway artifact
uses: actions/upload-artifact@v4
with:
name: gateway-code
path: |
./gateway
./gateway/gradle/wrapper/
if-no-files-found: error
- name: Upload user-svc artifact
uses: actions/upload-artifact@v4
with:
name: user-svc-code
path: |
./user-svc
./user-svc/gradle/wrapper/
if-no-files-found: error
- name: Upload concept-svc artifact
uses: actions/upload-artifact@v4
with:
name: concept-svc-code
path: |
./concept-svc
./concept-svc/gradle/wrapper/
if-no-files-found: error
- name: Upload genai-svc artifact
uses: actions/upload-artifact@v4
with:
name: genai-svc-code
path: ./genai-svc
if-no-files-found: error
test_java:
name: Run Java Tests
needs: [generate_api_code]
runs-on: ubuntu-latest
strategy:
matrix:
service: [gateway, user-svc, concept-svc]
steps:
- name: Download service artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.service }}-code
path: ./${{ matrix.service }}
- uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Set executable permissions for gradlew
run: |
echo "Setting executable permissions for ${{ matrix.service }}/gradlew"
ls -la ${{ matrix.service }}
chmod +x ${{ matrix.service }}/gradlew
ls -la ${{ matrix.service }}/gradlew
- name: Build and test with Gradle
run: |
cd ${{ matrix.service }}
pwd
ls -la
./gradlew build test
test_python:
name: Run Python Tests
needs: [generate_api_code]
runs-on: ubuntu-latest
steps:
- name: Download genai-svc artifact
uses: actions/download-artifact@v4
with:
name: genai-svc-code
path: ./genai-svc
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install dependencies
run: |
cd genai-svc
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Run Python tests
run: |
export SKIP_WEAVIATE=true
export SKIP_MINIO=true
export SKIP_OPENWEBUI=true
cd genai-svc
python -m pytest tests/ -v
test_client:
name: Run Client Unit Tests
needs: [generate_api_code]
runs-on: ubuntu-latest
steps:
- name: Download client artifact
uses: actions/download-artifact@v4
with:
name: client-code
path: ./client
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: './client/package-lock.json'
- name: Install dependencies
run: |
cd client
npm ci
- name: Run Angular tests
run: |
cd client
npm test -- --watch=false --browsers=ChromeHeadless
build_docs:
name: Build API Documentation
runs-on: ubuntu-latest
needs: [validate_api]
if: ${{ always() && (needs.validate_api.result == 'success' || needs.validate_api.result == 'skipped') }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install Redoc CLI
run: npm install -g redoc-cli
- name: Build Documentation
run: |
mkdir -p docs/api
for spec in api/*.yaml; do
filename=$(basename "$spec" .yaml)
redoc-cli bundle "$spec" -o "docs/api/$filename.html"
done
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs
branch: gh-pages
build_images:
name: Build Docker Images
needs: [test_java, test_python, test_client]
runs-on: ubuntu-latest
strategy:
matrix:
service: [client, gateway, user-svc, concept-svc, genai-svc]
steps:
- name: Download service artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.service }}-code
path: ./${{ matrix.service }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Install Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.service }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Set build arguments for client
id: build-args
run: |
if [[ "${{ matrix.service }}" == "client" ]]; then
# Detect target branch for push or pull_request
TARGET_BRANCH="${{ github.ref }}"
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
TARGET_BRANCH="${{ github.base_ref }}"
fi
if [[ "$TARGET_BRANCH" == "refs/heads/main" || "$TARGET_BRANCH" == "main" ]]; then
echo "build_env=production" >> $GITHUB_OUTPUT
elif [[ "$TARGET_BRANCH" == "refs/heads/dev" || "$TARGET_BRANCH" == "dev" ]]; then
echo "build_env=staging" >> $GITHUB_OUTPUT
else
echo "build_env=development" >> $GITHUB_OUTPUT
fi
fi
- name: Build and push Docker Image
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: ./${{ matrix.service }}
file: ./${{ matrix.service }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
${{ matrix.service == 'client' && format('BUILD_ENV={0}', steps.build-args.outputs.build_env) || '' }}
cache-from: type=gha
cache-to: type=gha,mode=max
complete_ci:
name: CI Pipeline Complete
needs: [build_images, build_docs]
runs-on: ubuntu-latest
steps:
- name: CI Pipeline Complete
run: echo "CI Pipeline completed successfully"