forked from opendatahub-io/odh-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
408 lines (386 loc) · 14.5 KB
/
test.yml
File metadata and controls
408 lines (386 loc) · 14.5 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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
name: Test
on: [push, pull_request]
# Concurrency control: Only run latest tests for each PR/branch
# Cancel in-progress runs when new commits are pushed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: 22.x
DO_NOT_TRACK: 1
NODE_MODULES_CACHE_VERSION: 1
jobs:
Setup:
runs-on: ubuntu-latest
outputs:
modules-cache-key: ${{ steps.key.outputs.modules-cache-key }}
steps:
- uses: actions/checkout@v4
- name: Validate all package-lock.json files
run: ./scripts/check-package-lock.sh --all
- name: Generate modules cache key
id: key
run: |
echo "modules-cache-key=${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ env.NODE_MODULES_CACHE_VERSION }}-${{ hashFiles('**/package-lock.json') }}" >> $GITHUB_OUTPUT
- name: Node.js modules cache
uses: actions/cache@v4
id: modules-cache
with:
path: |
~/.cache/Cypress
**/node_modules
key: ${{ steps.key.outputs.modules-cache-key }}
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4.3.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm install
- name: Validate module federation ports
run: npm run validate:ports
- name: Check for uncommitted changes
run: git diff --exit-code
Type-Check:
needs: Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4.3.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: |
~/.cache/Cypress
**/node_modules
key: ${{ needs.Setup.outputs.modules-cache-key }}
- name: Cache turbo
uses: actions/cache@v4
with:
path: |
**/.turbo
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-turbo-${{ github.sha }}-type-check
restore-keys: |
${{ runner.os }}-${{ env.NODE_VERSION }}-turbo-
- name: Run type checks
run: npm run type-check
Lint:
needs: Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4.3.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: |
~/.cache/Cypress
**/node_modules
key: ${{ needs.Setup.outputs.modules-cache-key }}
- name: Cache turbo
uses: actions/cache@v4
with:
path: |
**/.turbo
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-turbo-${{ github.sha }}-lint
restore-keys: |
${{ runner.os }}-${{ env.NODE_VERSION }}-turbo-
- name: Run linting and formatting checks
run: NODE_OPTIONS="--max-old-space-size=8192" npm run lint
Unit-Tests:
needs: [Setup, Lint, Type-Check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4.3.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: |
~/.cache/Cypress
**/node_modules
key: ${{ needs.Setup.outputs.modules-cache-key }}
- name: Cache turbo
uses: actions/cache@v4
with:
path: |
**/.turbo
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-turbo-${{ github.sha }}-unit-tests
restore-keys: |
${{ runner.os }}-${{ env.NODE_VERSION }}-turbo-
- name: Unit tests with coverage
run: |
npm run test-unit-coverage
- name: Upload unit test coverage
uses: actions/upload-artifact@v4
with:
name: unit-coverage
path: ./jest-coverage
if-no-files-found: error
Get-Test-Groups:
needs: Setup
runs-on: ubuntu-latest
outputs:
test-groups: ${{ steps.set-groups.outputs.test-groups }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4.3.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: |
~/.cache/Cypress
**/node_modules
key: ${{ needs.Setup.outputs.modules-cache-key }}
- id: set-groups
shell: bash
run: |
set -x # Enable debug mode to see each command
TEST_GROUPS="[]"
# 1. Discover central cypress test groups
if [ -d "packages/cypress/cypress/tests/mocked" ]; then
echo "Found mocked tests directory"
# Get directories and create JSON objects with name and spec
# spec includes "cypress/" prefix so all specs are relative to packages/
CENTRAL_GROUPS=$(cd packages/cypress/cypress/tests/mocked && \
find . -name "*.cy.*" -printf "%h\n" | sed 's|^\./||' | sort -u | \
jq -R '{"name": ., "spec": ("cypress/cypress/tests/mocked/" + . + "/*")}' | jq -c -s .)
TEST_GROUPS=$(echo "$TEST_GROUPS" | jq -c --argjson central "$CENTRAL_GROUPS" '. + $central')
echo "Central test groups: $CENTRAL_GROUPS"
fi
# 2. Discover package-based cypress tests using npm query
echo "Discovering package-based cypress tests..."
# spec includes package name so all specs are relative to packages/
PKG_GROUPS=$(npm query '.workspace' --json | jq -c '
[.[] | select(.cypress.mocked != null and .name != "@odh-dashboard/cypress") |
{
"name": ("pkg-" + (.name | split("/") | .[-1])),
"spec": ((.name | split("/") | .[-1]) + "/" + .cypress.mocked)
}
]
')
if [ "$PKG_GROUPS" != "[]" ]; then
# Verify each package has actual test files before adding
for row in $(echo "$PKG_GROUPS" | jq -c '.[]'); do
PKG_NAME=$(echo "$row" | jq -r '.name' | sed 's/^pkg-//')
if find "packages/$PKG_NAME" -name "*.cy.ts" 2>/dev/null | grep -q .; then
TEST_GROUPS=$(echo "$TEST_GROUPS" | jq -c --argjson row "$row" '. + [$row]')
echo "Added package test group: $row"
fi
done
fi
# Fallback if no groups found
if [ "$TEST_GROUPS" == "[]" ]; then
echo "No test groups found, using default"
TEST_GROUPS='[{"name": "default", "spec": "cypress/cypress/tests/mocked/**/*.cy.ts"}]'
fi
# Output in the correct format for GitHub Actions
echo "test-groups=$TEST_GROUPS" >> "$GITHUB_OUTPUT"
echo "Generated test groups:"
echo "$TEST_GROUPS" | jq .
Contract-Tests:
needs: [Setup, Lint, Type-Check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4.3.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
cache-dependency-path: |
packages/model-registry/upstream/bff/go.sum
packages/gen-ai/bff/go.sum
packages/mlflow/bff/go.sum
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: |
~/.cache/Cypress
**/node_modules
key: ${{ needs.Setup.outputs.modules-cache-key }}
- name: Run contract tests
run: |
export GITHUB_RUN_ID="$GITHUB_RUN_ID"
export CI="true"
npm run test:contract
env:
GITHUB_RUN_ID: ${{ github.run_id }}
CI: true
- name: Upload contract test results
if: always()
run: |
# Find and upload the most recent contract test results
LATEST_DIR=$(find packages/*/contract-tests/contract-test-results -name "ci-*" -type d 2>/dev/null | head -1)
if [ -n "$LATEST_DIR" ] && [ -d "$LATEST_DIR" ]; then
echo "Uploading from: $LATEST_DIR" && echo "results-dir=$LATEST_DIR" >> $GITHUB_OUTPUT
else
echo "No results found" && echo "results-dir=" >> $GITHUB_OUTPUT
fi
id: upload-results
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: steps.upload-results.outputs.results-dir != ''
with:
name: contract-test-results
path: ${{ steps.upload-results.outputs.results-dir }}
Cypress-Setup:
needs: [Setup]
runs-on: ubuntu-latest
outputs:
cypress-cache-key: ${{ steps.key.outputs.cypress-cache-key }}
steps:
- uses: actions/checkout@v4
- name: Generate cypress cache key
id: key
run: |
echo "cypress-cache-key=${{ runner.os }}-${{ env.NODE_VERSION }}-cypress-build-${{ github.sha }}" >> $GITHUB_OUTPUT
- name: Cypress build cache
uses: actions/cache@v4
id: cypress-build-cache
with:
lookup-only: true
path: |
**/public-cypress
key: ${{ steps.key.outputs.cypress-cache-key }}
- name: Restore cache
if: steps.cypress-build-cache.outputs.cache-hit != 'true'
uses: actions/cache/restore@v4
with:
path: |
~/.cache/Cypress
**/node_modules
key: ${{ needs.Setup.outputs.modules-cache-key }}
- name: Setup Node.js ${{ env.NODE_VERSION }}
if: steps.cypress-build-cache.outputs.cache-hit != 'true'
uses: actions/setup-node@v4.3.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Build for cypress
if: steps.cypress-build-cache.outputs.cache-hit != 'true'
run: npm run cypress:server:build:coverage -- --concurrency=4
Cypress-Mock-Tests:
needs: [Setup, Lint, Type-Check, Cypress-Setup, Get-Test-Groups]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test-group: ${{ fromJson(needs.Get-Test-Groups.outputs.test-groups) }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4.3.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore cache
uses: actions/cache/restore@v4
with:
path: |
~/.cache/Cypress
**/node_modules
key: ${{ needs.Setup.outputs.modules-cache-key }}
- name: Restore Cypress build cache
uses: actions/cache/restore@v4
with:
path: |
**/public-cypress
key: ${{ needs.Cypress-Setup.outputs.cypress-cache-key }}
- name: Run Cypress Mock tests
run: |
npm run test:cypress-ci:coverage:nobuild -- --spec "../packages/${{ matrix.test-group.spec }}"
working-directory: ./frontend
- name: Test group name
if: ${{ always() }}
run: echo "TEST_GROUP_NAME=$(echo '${{ matrix.test-group.name }}' | tr '/-' '_')" >> $GITHUB_ENV
- name: Upload Cypress Mock results
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: cypress-results-${{ env.TEST_GROUP_NAME }}
path: ./packages/cypress/results/mocked
- name: Upload Cypress coverage
uses: actions/upload-artifact@v4
with:
name: cypress-coverage-${{ env.TEST_GROUP_NAME }}
path: ./packages/cypress/coverage
Combine-Results-and-Upload:
needs: [Unit-Tests, Cypress-Mock-Tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4.3.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all-artifacts
- name: Install dependencies
run: npm install nyc --no-save
- name: Combine coverage reports
run: |
mkdir -p ./coverage
cp all-artifacts/unit-coverage/coverage-final.json ./coverage/unit-coverage-final.json || true
find all-artifacts -name "cypress-coverage-*" -type d | while read dir; do
group_name=$(basename "$dir")
cp "$dir/coverage-final.json" "./coverage/${group_name}-coverage-final.json" || true
done
echo "Combined coverage files:"
ls -R ./coverage
- name: Merge coverage reports
run: |
npx nyc merge ./coverage ./coverage/merged-coverage.json
echo "Cleaning up merged coverage file..."
jq 'del(.[] | select(.statementMap == {}))' ./coverage/merged-coverage.json > ./coverage/cleaned-coverage.json
mv ./coverage/cleaned-coverage.json ./coverage/merged-coverage.json
- name: Generate coverage report
run: |
mkdir -p ./coverage/report
npx nyc report --reporter=html --reporter=text-summary --temp-directory ./coverage -t ./coverage --report-dir ./coverage/report
cp ./coverage/unit-coverage-final.json ./coverage/combined-coverage-final.json || true
- name: Upload combined results
uses: actions/upload-artifact@v4
with:
name: combined-coverage-results
path: ./coverage/combined-coverage-final.json
- name: Cleanup interim coverage files
run: |
rm -rf ./coverage/unit-coverage-final.json
find ./coverage -name "*-coverage-final.json" -type f -delete
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.6.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
name: frontend-and-backend
file: ./coverage/merged-coverage.json
disable_search: true
directory: ./coverage
verbose: true
Tests:
runs-on: ubuntu-latest
needs:
- Lint
- Type-Check
- Unit-Tests
- Contract-Tests
- Cypress-Mock-Tests
- Combine-Results-and-Upload
steps:
- name: Verify all jobs succeeded
run: echo "All required jobs have successfully completed for Node.js ${{ env.NODE_VERSION }}."