-
Notifications
You must be signed in to change notification settings - Fork 0
659 lines (573 loc) · 18.2 KB
/
speccursor.yml
File metadata and controls
659 lines (573 loc) · 18.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
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
name: SpecCursor CI/CD Pipeline
on:
push:
branches: [main, develop]
paths:
- 'apps/**'
- 'packages/**'
- 'workers/**'
- 'scripts/**'
- '.github/workflows/**'
- 'package.json'
- 'pnpm-workspace.yaml'
- 'Cargo.toml'
- 'lakefile.lean'
- 'go.mod'
- 'requirements.txt'
- 'Dockerfile'
pull_request:
branches: [main, develop]
paths:
- 'apps/**'
- 'packages/**'
- 'workers/**'
- 'scripts/**'
- '.github/workflows/**'
- 'package.json'
- 'pnpm-workspace.yaml'
- 'Cargo.toml'
- 'lakefile.lean'
- 'go.mod'
- 'requirements.txt'
- 'Dockerfile'
release:
types: [published]
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
default: 'staging'
type: choice
options:
- staging
- production
force_deploy:
description: 'Force deployment even if tests fail'
required: false
default: false
type: boolean
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# Code Quality & Security
code-quality:
name: Code Quality & Security
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Setup Lean
uses: leanprover/lean4@v2
with:
lean-version: '4.20.0'
- name: Install pnpm
run: npm install -g pnpm@latest
- name: Install dependencies
run: |
pnpm install --frozen-lockfile
if [ -f "Cargo.toml" ]; then cargo fetch; fi
if [ -f "requirements.txt" ]; then pip install -r requirements.txt; fi
if [ -f "go.mod" ]; then go mod download; fi
- name: Run ESLint
run: pnpm lint
- name: Run Prettier check
run: pnpm format:check
- name: Run TypeScript type check
run: pnpm type-check
- name: Run Rust clippy
run: |
if [ -f "Cargo.toml" ]; then
cargo clippy --all-targets --all-features -- -D warnings
fi
- name: Run Go lint
run: |
if [ -f "go.mod" ]; then
golangci-lint run
fi
- name: Run Python lint
run: |
if [ -f "requirements.txt" ]; then
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
black --check .
isort --check-only .
fi
- name: Run Lean check
run: |
if [ -f "lakefile.lean" ]; then
lake build
lake exe cache get
leanchecker lean/speccursor.lean
fi
- name: Run security audit
run: |
pnpm audit --audit-level moderate
if [ -f "Cargo.toml" ]; then cargo audit; fi
if [ -f "requirements.txt" ]; then safety check; fi
- name: Run Snyk security scan
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'
- name: Run Gitleaks
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Unit Tests
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
matrix:
ecosystem: [node, rust, python, go, lean]
include:
- ecosystem: node
test-command: pnpm test
coverage-command: pnpm test:coverage
- ecosystem: rust
test-command: cargo test
coverage-command: cargo tarpaulin --out Html
- ecosystem: python
test-command: python -m pytest
coverage-command: python -m pytest --cov=. --cov-report=html
- ecosystem: go
test-command: go test ./...
coverage-command: go test -coverprofile=coverage.out ./...
- ecosystem: lean
test-command: lake env lean --run lean/test_runner.lean
coverage-command: echo "Lean coverage not supported"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup ${{ matrix.ecosystem }}
uses: actions/setup-node@v4
if: matrix.ecosystem == 'node'
with:
node-version: '20'
cache: 'npm'
- name: Setup ${{ matrix.ecosystem }}
uses: actions-rs/toolchain@v1
if: matrix.ecosystem == 'rust'
with:
toolchain: stable
override: true
- name: Setup ${{ matrix.ecosystem }}
uses: actions/setup-python@v4
if: matrix.ecosystem == 'python'
with:
python-version: '3.11'
- name: Setup ${{ matrix.ecosystem }}
uses: actions/setup-go@v4
if: matrix.ecosystem == 'go'
with:
go-version: '1.21'
- name: Setup ${{ matrix.ecosystem }}
uses: leanprover/lean4@v2
if: matrix.ecosystem == 'lean'
with:
lean-version: '4.20.0'
- name: Install dependencies
run: |
if [ "${{ matrix.ecosystem }}" = "node" ]; then
npm install -g pnpm@latest
pnpm install --frozen-lockfile
elif [ "${{ matrix.ecosystem }}" = "rust" ]; then
cargo fetch
elif [ "${{ matrix.ecosystem }}" = "python" ]; then
pip install -r requirements.txt
elif [ "${{ matrix.ecosystem }}" = "go" ]; then
go mod download
elif [ "${{ matrix.ecosystem }}" = "lean" ]; then
lake build
fi
- name: Run tests
run: ${{ matrix.test-command }}
timeout-minutes: 30
- name: Generate coverage
run: ${{ matrix.coverage-command }}
if: matrix.ecosystem != 'lean'
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.ecosystem != 'lean'
with:
file: ./coverage/lcov.info
flags: ${{ matrix.ecosystem }}
name: ${{ matrix.ecosystem }}-coverage
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.ecosystem }}
path: |
coverage/
test-results.json
*.xml
# Integration Tests
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 60
needs: unit-tests
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: speccursor_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: |
npm install -g pnpm@latest
pnpm install --frozen-lockfile
- name: Run integration tests
run: pnpm test:integration
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/speccursor_test
REDIS_URL: redis://localhost:6379
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
MORPH_API_KEY: ${{ secrets.MORPH_API_KEY }}
- name: Upload integration test results
uses: actions/upload-artifact@v4
if: always()
with:
name: integration-test-results
path: |
integration-test-results/
coverage/
# End-to-End Tests
e2e-tests:
name: End-to-End Tests
runs-on: ubuntu-latest
timeout-minutes: 90
needs: integration-tests
strategy:
matrix:
scenario: [basic-upgrade, ai-patch, formal-proof, full-workflow]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Setup Lean
uses: leanprover/lean4@v2
with:
lean-version: '4.20.0'
- name: Install dependencies
run: |
npm install -g pnpm@latest
pnpm install --frozen-lockfile
if [ -f "Cargo.toml" ]; then cargo fetch; fi
if [ -f "lakefile.lean" ]; then lake build; fi
- name: Run E2E test scenario
run: pnpm test:e2e --scenario ${{ matrix.scenario }}
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
MORPH_API_KEY: ${{ secrets.MORPH_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload E2E test results
uses: actions/upload-artifact@v4
if: always()
with:
name: e2e-test-results-${{ matrix.scenario }}
path: |
e2e-test-results/
screenshots/
# Build & Package
build:
name: Build & Package
runs-on: ubuntu-latest
timeout-minutes: 45
needs: [unit-tests, integration-tests]
strategy:
matrix:
include:
- name: github-app
path: apps/github-app
dockerfile: apps/github-app/Dockerfile
- name: controller
path: apps/controller
dockerfile: apps/controller/Dockerfile
- name: ai-service
path: apps/ai-service
dockerfile: apps/ai-service/Dockerfile
- name: rust-worker
path: workers/rust-worker
dockerfile: workers/rust-worker/Dockerfile
- name: lean-engine
path: workers/lean-engine
dockerfile: workers/lean-engine/Dockerfile
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.name }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{branch}}-
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.path }}
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
- name: Generate SBOM
uses: anchore/sbom-action@v0
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.name }}:${{ github.sha }}
format: spdx-json
output-file: sbom-${{ matrix.name }}.json
- name: Upload SBOM
uses: actions/upload-artifact@v4
with:
name: sbom-${{ matrix.name }}
path: sbom-${{ matrix.name }}.json
- name: Sign image with Sigstore
uses: sigstore/cosign-installer@v3
with:
cosign-release: 'v2.1.1'
- name: Sign the published container image
run: cosign sign --yes ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.name }}@${{ steps.build.outputs.digest }}
# Deploy to Staging
deploy-staging:
name: Deploy to Staging
runs-on: ubuntu-latest
timeout-minutes: 30
needs: build
environment: staging
if: github.ref == 'refs/heads/develop' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: '1.5.0'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Terraform Init
run: |
cd terraform/staging
terraform init
- name: Terraform Plan
run: |
cd terraform/staging
terraform plan -var="image_tag=${{ github.sha }}" -out=tfplan
- name: Terraform Apply
run: |
cd terraform/staging
terraform apply -auto-approve tfplan
- name: Run smoke tests
run: |
# Wait for deployment to be ready
sleep 60
# Run smoke tests against staging environment
pnpm test:smoke --base-url ${{ steps.deploy.outputs.staging_url }}
# Deploy to Production
deploy-production:
name: Deploy to Production
runs-on: ubuntu-latest
timeout-minutes: 45
needs: [build, deploy-staging]
environment: production
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform-version: '1.5.0'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Terraform Init
run: |
cd terraform/production
terraform init
- name: Terraform Plan
run: |
cd terraform/production
terraform plan -var="image_tag=${{ github.sha }}" -out=tfplan
- name: Terraform Apply
run: |
cd terraform/production
terraform apply -auto-approve tfplan
- name: Run production health checks
run: |
# Wait for deployment to be ready
sleep 120
# Run comprehensive health checks
pnpm test:health --base-url ${{ steps.deploy.outputs.production_url }}
- name: Create GitHub Release
uses: actions/create-release@v1
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.run_number }}
release_name: Release v${{ github.run_number }}
body: |
## SpecCursor Release v${{ github.run_number }}
### Changes
- Automated dependency upgrades
- AI patch generation improvements
- Formal verification enhancements
### Artifacts
- Docker images: `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}`
- SBOM files available in artifacts
### Deployment
- Staging: ✅ Deployed
- Production: ✅ Deployed
### Metrics
- Build time: ${{ needs.build.result }}
- Test coverage: Available in Codecov
- Security scan: Passed
draft: false
prerelease: false
# Notifications
notifications:
name: Notifications
runs-on: ubuntu-latest
needs:
[
unit-tests,
integration-tests,
e2e-tests,
build,
deploy-staging,
deploy-production,
]
if: always()
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: |
npm install -g pnpm@latest
pnpm install --frozen-lockfile
- name: Send Slack notification
run: |
pnpm scripts/notify-slack.js \
--status ${{ needs.unit-tests.result }} \
--branch ${{ github.ref_name }} \
--commit ${{ github.sha }} \
--run-url ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Send email notification
if: failure()
run: |
pnpm scripts/notify-email.js \
--status failure \
--branch ${{ github.ref_name }} \
--commit ${{ github.sha }} \
--run-url ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
env:
SMTP_HOST: ${{ secrets.SMTP_HOST }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_USER: ${{ secrets.SMTP_USER }}
SMTP_PASS: ${{ secrets.SMTP_PASS }}
# Required status checks for branch protection
# These must pass before merging PRs to main/develop
# Configure in repository settings > Branches > Branch protection rules