-
Notifications
You must be signed in to change notification settings - Fork 1
733 lines (619 loc) · 22.4 KB
/
Copy pathci.yml
File metadata and controls
733 lines (619 loc) · 22.4 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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
name: CI
on:
push:
branches:
- main
- master
- 'hotfix/**'
- 'emergency/**'
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
env:
NODE_VERSION_DEFAULT: '20'
jobs:
# ============================================================================
# TIER 1: CLASSIFICATION
# Determine which CI tier to run based on change characteristics
# ============================================================================
tier-classification:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
tier: ${{ steps.classifier.outputs.tier }}
json: ${{ steps.classifier.outputs.json }}
is_fast_track: ${{ steps.classifier.outputs.tier == 'fast' }}
is_standard: ${{ steps.classifier.outputs.tier == 'standard' }}
is_emergency: ${{ steps.classifier.outputs.tier == 'emergency' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
- name: Determine CI Tier
id: classifier
env:
GITHUB_BASE_REF: ${{ github.event.pull_request.base.ref }}
GITHUB_HEAD_REF: ${{ github.event.pull_request.head.ref }}
GITHUB_REF_NAME: ${{ github.ref_name }}
PR_LABELS: ${{ toJson(github.event.pull_request.labels) }}
PLAN_PATH: docs/plans/plan.md
run: node scripts/ci-tier-classifier.js
- name: Comment Tier Decision
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const tier = '${{ steps.classifier.outputs.tier }}';
const json = JSON.parse(${{ steps.classifier.outputs.json }});
const reasons = json.reasons.join('\n- ');
const body = `## CI Tier Classification
**Selected Tier:** \`${tier}\`
**Reasoning:**
- ${reasons}
<details>
<summary>Classification Details</summary>
\`\`\`json
${JSON.stringify(json.metadata, null, 2)}
\`\`\`
</details>
---
*This classification was automatically determined. To override, add a label or update plan.md.*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
# ============================================================================
# TIER 2: FAST-TRACK LANE (~8-12 minutes)
# For: Small changes (<50 lines), low-risk, 100% coverage on changed lines
# Skips: DTU harness, golden regression, maturity gates, flake replay,
# coverage gate (keeps upload), heavy validation
# ============================================================================
fast-track-verify:
needs: tier-classification
if: needs.tier-classification.outputs.is_fast_track == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Typecheck
run: npm run typecheck
- name: Test (Fast-Track)
run: npm run test:run
- name: Coverage (Fast-Track - Changed Lines Only)
run: npm run test:coverage
- name: Verify Changed Line Coverage
env:
GITHUB_BASE_REF: ${{ github.event.pull_request.base.ref }}
GITHUB_HEAD_REF: ${{ github.event.pull_request.head.ref }}
COVERAGE_PATH: ./coverage/coverage-final.json
run: node scripts/fast-track-coverage.js
- name: Worktree Parity
env:
WORKTREE_PARITY_REQUIRE_HEAD: "1"
run: npm run test:worktree
- name: Upload Coverage Artifact
uses: actions/upload-artifact@v4
with:
name: fast-track-coverage-report
path: coverage
# ============================================================================
# TIER 2: STANDARD-TRACK LANE (~90-100 minutes)
# For: Medium/high-risk changes, >50 lines, security-critical files
# Full gate matrix: all 12+ jobs
# ============================================================================
pr-compound-compliance:
needs: tier-classification
if: |
github.event_name == 'pull_request' &&
needs.tier-classification.outputs.is_standard == 'true'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
- name: Validate PR compound artifacts
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: npm run check:pr-compound
verify:
needs: tier-classification
if: needs.tier-classification.outputs.is_standard == 'true'
strategy:
fail-fast: false
matrix:
node-version: [20, 22]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Typecheck
run: npm run typecheck
- name: Test
run: npm run test:run
- name: DTU Scenario Harness
if: ${{ matrix.node-version == 20 }}
run: npm run dtu:run
- name: Coverage Gate
if: ${{ matrix.node-version == 20 }}
run: npm run test:coverage
- name: Upload Coverage Artifact
if: ${{ matrix.node-version == 20 }}
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage
golden-regression:
needs: tier-classification
if: needs.tier-classification.outputs.is_standard == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Golden Regression
run: npm run test:golden
self-host-maturity:
needs: tier-classification
if: needs.tier-classification.outputs.is_standard == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Evaluate Self-host Maturity (deterministic-local gate)
run: |
npm run self-host:maturity -- \
--logs-root ./logs/self_host_maturity_ci \
--report ./logs/self_host_maturity_ci/report.json \
--markdown ./logs/self_host_maturity_ci/report.md \
--require-level deterministic-local
- name: Upload Self-host Maturity Artifact
uses: actions/upload-artifact@v4
with:
name: self-host-maturity-report
path: |
logs/self_host_maturity_ci/report.json
logs/self_host_maturity_ci/report.md
claims-consistency:
needs: tier-classification
if: needs.tier-classification.outputs.is_standard == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Evaluate Claims Consistency Gate
run: |
npm run claims:audit -- \
--report ./logs/claims_consistency_ci/report.json
- name: Upload Claims Consistency Artifact
uses: actions/upload-artifact@v4
with:
name: claims-consistency-report
path: logs/claims_consistency_ci/report.json
docs-freshness:
needs: tier-classification
if: needs.tier-classification.outputs.is_standard == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Evaluate Docs Freshness Gate
run: |
npm run docs:freshness -- \
--report ./logs/docs_freshness_ci/report.json
- name: Upload Docs Freshness Artifact
uses: actions/upload-artifact@v4
with:
name: docs-freshness-report
path: logs/docs_freshness_ci/report.json
self-host-flake:
needs: tier-classification
if: needs.tier-classification.outputs.is_standard == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Evaluate Deterministic Flake Replay Gate
run: |
npm run self-host:flake -- \
--replay-count 2 \
--min-pass-rate 1 \
--report ./logs/self_host_flake_ci/report.json
- name: Upload Self-host Flake Artifact
uses: actions/upload-artifact@v4
with:
name: self-host-flake-report
path: logs/self_host_flake_ci/report.json
release-hardening:
needs: tier-classification
if: needs.tier-classification.outputs.is_standard == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Evaluate Release Hardening Gates
env:
RELEASE_SIGNING_KEY: ci-deterministic-signing-key
run: |
npm run release:hardening -- \
--strict-signing \
--signing-key-env RELEASE_SIGNING_KEY \
--report ./logs/release_hardening_ci/report.json \
--sbom ./logs/release_hardening_ci/sbom.json \
--signature ./logs/release_hardening_ci/signature.json \
--release-workflow ./.github/workflows/release.yml
- name: Upload Release Hardening Artifacts
uses: actions/upload-artifact@v4
with:
name: release-hardening-report
path: |
logs/release_hardening_ci/report.json
logs/release_hardening_ci/sbom.json
logs/release_hardening_ci/signature.json
reliability-slo:
needs: tier-classification
if: needs.tier-classification.outputs.is_standard == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Evaluate Reliability SLO Gate
run: |
npm run reliability:slo -- \
--report ./logs/reliability_slo_ci/report.json
- name: Upload Reliability SLO Artifact
uses: actions/upload-artifact@v4
with:
name: reliability-slo-report
path: logs/reliability_slo_ci/report.json
self-host-unattended-telemetry:
needs: tier-classification
if: needs.tier-classification.outputs.is_standard == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Evaluate Unattended Telemetry Contract
run: |
npm run self-host:unattended-telemetry -- \
--source ./docs/metrics/reports/self-host-unattended-telemetry-source-latest.json \
--report ./logs/self_host_unattended_telemetry_ci/report.json
- name: Upload Unattended Telemetry Artifact
uses: actions/upload-artifact@v4
with:
name: self-host-unattended-telemetry-report
path: logs/self_host_unattended_telemetry_ci/report.json
worktree-parity:
needs: tier-classification
if: needs.tier-classification.outputs.is_standard == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Worktree Parity
env:
WORKTREE_PARITY_REQUIRE_HEAD: "1"
run: npm run test:worktree
evidence-freshness:
needs: tier-classification
if: needs.tier-classification.outputs.is_standard == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Check Evidence Freshness
run: |
npm run evidence:freshness -- \
--max-age-hours 168 \
--report ./logs/evidence_freshness_ci/report.json
- name: Upload Evidence Freshness Artifact
uses: actions/upload-artifact@v4
with:
name: evidence-freshness-report
path: logs/evidence_freshness_ci/report.json
# ============================================================================
# AGENT-GENERATED TOOLS
# Run generated tools for code quality enforcement
# ============================================================================
generated-tools:
needs: tier-classification
if: needs.tier-classification.outputs.is_standard == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Run Date Linter
run: |
npm run tool:date-lint -- \
--report ./logs/tools/date_linter_ci/report.json
continue-on-error: true
- name: Run Cross-Doc Validator
run: |
npm run tool:cross-doc-validate -- \
--report ./logs/tools/cross_doc_validator_ci/report.json
continue-on-error: true
- name: Run Drift Detector
run: |
npm run tool:drift-check -- \
--report ./logs/tools/drift_detector_ci/report.json
continue-on-error: true
- name: Upload Generated Tools Artifacts
uses: actions/upload-artifact@v4
with:
name: generated-tools-reports
path: |
logs/tools/*/report.json
# ============================================================================
# TIER 3: EMERGENCY-FIX LANE (~5-8 minutes)
# For: hotfix/* or emergency/* branches, production issues
# Minimal gates: lint, typecheck, unit tests only
# Auto-merge capability with tracking issue
# ============================================================================
emergency-verify:
needs: tier-classification
if: needs.tier-classification.outputs.is_emergency == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
tracking_issue_url: ${{ steps.tracking.outputs.issue_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION_DEFAULT }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Typecheck
run: npm run typecheck
- name: Test
run: npm run test:run
- name: Create Tracking Issue
id: tracking
if: github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}
run: node scripts/emergency-tracker.js
- name: Update PR with Tracking Issue
if: steps.tracking.outputs.issue_url && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const issueUrl = '${{ steps.tracking.outputs.issue_url }}';
const body = context.payload.pull_request.body || '';
if (!body.includes(issueUrl)) {
const updatedBody = body + '\n\n---\n\n**Emergency Fix Tracking:** ' + issueUrl;
github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
body: updatedBody
});
}
# ============================================================================
# CI COMPLETION AGGREGATOR
# Ensures all required jobs pass based on tier
# ============================================================================
ci-complete:
needs:
- tier-classification
- fast-track-verify
- emergency-verify
- pr-compound-compliance
- verify
- golden-regression
- self-host-maturity
- claims-consistency
- docs-freshness
- self-host-flake
- release-hardening
- reliability-slo
- self-host-unattended-telemetry
- worktree-parity
- evidence-freshness
- generated-tools
if: always()
runs-on: ubuntu-latest
steps:
- name: Check CI Results
run: |
TIER="${{ needs.tier-classification.outputs.tier }}"
echo "CI Tier: $TIER"
# Check tier-specific requirements
case "$TIER" in
fast)
echo "Fast-track lane - checking required jobs..."
FAST_TRACK_RESULT="${{ needs.fast-track-verify.result }}"
if [ "$FAST_TRACK_RESULT" != "success" ]; then
echo "✗ Fast-track verification failed"
exit 1
fi
;;
emergency)
echo "Emergency lane - checking required jobs..."
EMERGENCY_RESULT="${{ needs.emergency-verify.result }}"
if [ "$EMERGENCY_RESULT" != "success" ]; then
echo "✗ Emergency verification failed"
exit 1
fi
;;
standard|*)
echo "Standard lane - checking all jobs..."
# List of required standard-track jobs
JOBS="pr-compound-compliance verify golden-regression self-host-maturity claims-consistency docs-freshness self-host-flake release-hardening reliability-slo self-host-unattended-telemetry worktree-parity evidence-freshness generated-tools"
FAILED=0
for job in $JOBS; do
RESULT=$(eval echo "\${{ needs.$job.result }}")
if [ "$RESULT" != "success" ] && [ "$RESULT" != "skipped" ]; then
echo "✗ Job $job failed with result: $RESULT"
FAILED=1
fi
done
if [ $FAILED -eq 1 ]; then
exit 1
fi
;;
esac
echo "✓ All required CI checks passed for tier: $TIER"
# ============================================================================
# METRICS COLLECTION
# Track velocity vs reliability metrics
# ============================================================================
metrics-collection:
needs: ci-complete
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Collect CI Metrics
uses: actions/github-script@v7
with:
script: |
const tier = '${{ needs.tier-classification.outputs.tier }}';
const startTime = '${{ github.event.pull_request.created_at }}';
const endTime = new Date().toISOString();
const metrics = {
tier: tier,
pr_number: context.issue.number,
pr_title: context.payload.pull_request.title,
author: context.payload.pull_request.user.login,
start_time: startTime,
end_time: endTime,
duration_minutes: Math.round((new Date(endTime) - new Date(startTime)) / 60000),
conclusion: '${{ needs.ci-complete.result }}',
timestamp: endTime
};
console.log('CI Metrics:', metrics);
// In a production environment, you would send this to your metrics system
// For now, we just log it
// Create metrics artifact
const fs = require('fs');
fs.writeFileSync('ci-metrics.json', JSON.stringify(metrics, null, 2));
- name: Upload Metrics Artifact
uses: actions/upload-artifact@v4
with:
name: ci-metrics-${{ github.run_id }}
path: ci-metrics.json