Repository navigation
464 lines (403 loc) · 14.2 KB
/
Copy pathpr-validation.yml
File metadata and controls
464 lines (403 loc) · 14.2 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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
name: PR Validation
on:
pull_request:
branches: [ main, release-* ]
types: [ opened, synchronize, reopened ]
permissions:
contents: read
pull-requests: write
checks: write
security-events: write # Required for uploading SARIF files if we add security scanning
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit-checks:
name: Pre-commit Checks
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Cache Go modules
uses: actions/cache@v5
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install dependencies
run: |
make controller-gen
make envtest
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Setup Helm
uses: azure/setup-helm@v4
with:
version: 'latest'
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
id: pre-commit
run: pre-commit run --all-files --show-diff-on-failure
- name: Post failure comment on PR
if: failure() && steps.pre-commit.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
const body = `⚠️ **Pre-commit checks failed**\n\nPlease run the following locally and commit the fixes:\n\`\`\`bash\npre-commit run --all-files\ngit add -u && git commit\n\`\`\`\nSee [CONTRIBUTING.md](../blob/main/CONTRIBUTING.md#pre-commit-check) for setup instructions.`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
test-and-build:
name: Test and Build (${{ matrix.shard }})
runs-on: ubuntu-latest
# The in-process rollout models are CPU-bound and scale with cores; on a
# four-core runner the whole suite needs several hours, so the heaviest
# packages run in shards of their own (make test-packages).
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
include:
- shard: workload
packages: ./pkg/controller/v1beta1/workload/...
- shard: coordination
packages: ./pkg/controller/v1beta1/inferenceservice/reconcilers/omenative/coordination/...
- shard: canary-scaling
packages: >-
./pkg/controller/v1beta1/inferenceservice/reconcilers/omenative/canary/...
./pkg/controller/v1beta1/inferenceservice/reconcilers/scaling/...
./pkg/controller/v1beta1/inferenceservice/reconcilers/omenative/rolloutrun/...
- shard: rest
packages: ''
env:
# The packages the other shards run, dropped from the rest shard.
HEAVY_PACKAGES: pkg/controller/v1beta1/workload|reconcilers/omenative/coordination|reconcilers/omenative/canary|reconcilers/scaling|reconcilers/omenative/rolloutrun
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache test dependencies
uses: actions/cache@v5
with:
path: |
~/go/pkg/mod
~/.cache/go-build
bin/
~/.cargo/registry
~/.cargo/git
pkg/xet/target
key: ${{ runner.os }}-test-${{ hashFiles('**/go.sum', 'pkg/xet/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-test-
${{ runner.os }}-go-
${{ runner.os }}-rust-
- name: Build the xet library
# The shard vets and builds before it tests; a restored pkg/xet/target
# may hold an archive with LLVM bitcode, which go vet refuses to link,
# so build (and strip) it first.
run: make xet-build
- name: Vet
if: matrix.shard == 'rest'
run: make fmt vet
- name: Run tests
run: |
if [ "${{ matrix.shard }}" = rest ]; then
make test-packages TEST_SHARD=rest TEST_EXCLUDE="$HEAVY_PACKAGES"
else
make test-packages TEST_SHARD="${{ matrix.shard }}" TEST_PACKAGES="${{ matrix.packages }}"
fi
- name: Upload the shard's coverage profile
uses: actions/upload-artifact@v7
if: always()
with:
name: coverage-${{ matrix.shard }}
path: coverage-${{ matrix.shard }}.out
retention-days: 7
- name: Build binaries
if: matrix.shard == 'rest'
run: |
make ome-manager
make model-agent
coverage:
name: Coverage
needs: test-and-build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Download the shard profiles
uses: actions/download-artifact@v8
with:
pattern: coverage-*
path: profiles
merge-multiple: true
- name: Assemble one profile per package group
# The shards test disjoint packages, so their blocks never overlap and
# make coverage reads the three group profiles it always has.
run: |
module="$(go list -m)"
for group in cmd pkg internal; do
{ echo "mode: atomic"; grep -h -v '^mode:' profiles/*.out | grep "^${module}/${group}/" || true; } > "coverage-${group}.out"
done
- name: Check coverage threshold
run: |
echo "::group::Coverage Report"
make coverage
echo "::endgroup::"
- name: Upload test coverage
uses: actions/upload-artifact@v7
if: always()
with:
name: coverage-report
path: |
coverage-cmd.out
coverage-pkg.out
coverage-internal.out
retention-days: 7
cli-cross-compile:
name: CLI cross-compile (CGO_ENABLED=0)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Cross-compile kubectl-ome
run: make kubectl-ome-cross
# Docker builds only validate Dockerfile/build-context breakage —
# test-and-build already compiles and tests the same code natively —
# so they run only when a docker-relevant path actually changed.
docker-changes:
name: Detect Docker-Relevant Changes
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
docker: ${{ steps.filter.outputs.docker }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check changed paths
id: filter
run: |
if git diff --name-only "origin/${{ github.base_ref }}...HEAD" | \
grep -qE '^(dockerfiles/|Makefile|pkg/xet/|scheduler/|go\.(mod|sum)|\.github/workflows/(dev-images\.yaml|pr-validation\.yml))'; then
echo "docker=true" >> "$GITHUB_OUTPUT"
else
echo "docker=false" >> "$GITHUB_OUTPUT"
fi
docker-validation:
name: Docker Build Validation
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [pre-commit-checks, docker-changes]
if: needs.docker-changes.outputs.docker == 'true'
strategy:
matrix:
image: [ome-image, model-agent-image, ome-agent-image, ome-scheduler-image, alfred-image]
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Setup Rust
if: matrix.image == 'ome-agent-image'
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache Rust dependencies
if: matrix.image == 'ome-agent-image'
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
pkg/xet/target
key: ${{ runner.os }}-rust-${{ hashFiles('pkg/xet/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rust-
- name: Strip the cached xet library
if: matrix.image == 'ome-agent-image'
# A restored pkg/xet/target may hold an archive built before the
# Makefile stripped its LLVM bitcode; go vet refuses to link one.
run: make xet-build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image (amd64 only)
run: |
# Build only for amd64 to save time in PR validation
# Multi-arch builds are done during release
make ${{ matrix.image }}
env:
TAG: pr-${{ github.event.pull_request.number }}-${{ github.run_number }}
REGISTRY: local
ARCH: linux/amd64
# Optional multi-arch validation - only runs when 'test-multiarch' label is present
docker-multiarch-validation:
name: Docker Multi-Arch Build Validation
runs-on: ubuntu-latest
timeout-minutes: 30
needs: pre-commit-checks
if: contains(github.event.pull_request.labels.*.name, 'test-multiarch')
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
pkg/xet/target
key: ${{ runner.os }}-rust-${{ hashFiles('pkg/xet/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rust-
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build multi-arch images (no push)
run: |
echo "🌍 Building multi-arch images for validation..."
# Build but don't push - just validate the build works
docker buildx build --platform=linux/amd64,linux/arm64 \
--build-arg VERSION=pr-test \
--build-arg GIT_TAG=pr-${{ github.event.pull_request.number }} \
--build-arg GIT_COMMIT=${{ github.sha }} \
. -f dockerfiles/manager.Dockerfile \
-t local/ome-manager:pr-test
docker buildx build --platform=linux/amd64,linux/arm64 \
--build-arg VERSION=pr-test \
--build-arg GIT_TAG=pr-${{ github.event.pull_request.number }} \
--build-arg GIT_COMMIT=${{ github.sha }} \
. -f dockerfiles/model-agent.Dockerfile \
-t local/model-agent:pr-test
echo "✅ Multi-arch build validation successful"
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Run golangci-lint
run: make ci-lint
generate-drift:
name: Generated Code Drift
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Regenerate manifests and code
run: make manifests generate
- name: Verify no drift
run: |
git diff --exit-code || {
echo "::error::make manifests generate produced changes — regenerate and commit them"
exit 1
}
- name: Vendor optional CRDs
run: make dep-crds
summary:
name: PR Validation Summary
runs-on: ubuntu-latest
needs: [pre-commit-checks, test-and-build, coverage, cli-cross-compile, docker-validation, lint, generate-drift]
if: always()
steps:
- name: PR Status Summary
uses: actions/github-script@v8
with:
script: |
const needs = context.payload.workflow_run ?
context.payload.workflow_run.pull_requests[0].number :
context.issue.number;
const jobs = {
'pre-commit-checks': '${{ needs.pre-commit-checks.result }}',
'test-and-build': '${{ needs.test-and-build.result }}',
'coverage': '${{ needs.coverage.result }}',
'cli-cross-compile': '${{ needs.cli-cross-compile.result }}',
'docker-validation': '${{ needs.docker-validation.result }}',
'lint': '${{ needs.lint.result }}',
'generate-drift': '${{ needs.generate-drift.result }}'
};
let allPassed = true;
let summary = '## 📋 PR Validation Summary\n\n';
for (const [job, status] of Object.entries(jobs)) {
const emoji = status === 'success' ? '✅' : status === 'skipped' ? '⏭️' : '❌';
summary += `${emoji} **${job}**: ${status}\n`;
if (status !== 'success' && status !== 'skipped') {
allPassed = false;
}
}
summary += '\n';
summary += allPassed ?
'### ✅ All checks passed! Ready for review.' :
'### ❌ Some checks failed. Please review the errors above.';
core.summary.addRaw(summary).write();