ci setup
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped

This commit is contained in:
2026-01-22 19:04:25 +01:00
parent a165ac9b65
commit 5612df2e33
6 changed files with 321 additions and 118 deletions

186
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,186 @@
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
# Job 1: Lint and Typecheck (Fast feedback)
lint-typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
- name: Run Typecheck
run: npm run typecheck
# Job 2: Unit and Integration Tests
tests:
runs-on: ubuntu-latest
needs: lint-typecheck
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run Unit Tests
run: npm run test:unit
- name: Run Integration Tests
run: npm run test:integration
# Job 3: Contract Tests (API/Website compatibility)
contract-tests:
runs-on: ubuntu-latest
needs: lint-typecheck
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run API Contract Validation
run: npm run test:api:contracts
- name: Generate OpenAPI spec
run: npm run api:generate-spec
- name: Generate TypeScript types
run: npm run api:generate-types
- name: Run Contract Compatibility Check
run: npm run test:contract:compatibility
- name: Verify Website Type Checking
run: npm run website:type-check
- name: Upload generated types as artifacts
uses: actions/upload-artifact@v3
with:
name: generated-types
path: apps/website/lib/types/generated/
retention-days: 7
# Job 4: E2E Tests (Only on main/develop push, not on PRs)
e2e-tests:
runs-on: ubuntu-latest
needs: [lint-typecheck, tests, contract-tests]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run E2E Tests
run: npm run test:e2e
# Job 5: Comment PR with results (Only on PRs)
comment-pr:
runs-on: ubuntu-latest
needs: [lint-typecheck, tests, contract-tests]
if: github.event_name == 'pull_request'
steps:
- name: Comment PR with results
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const path = require('path');
// Read any contract change reports
const reportPath = path.join(process.cwd(), 'contract-report.json');
if (fs.existsSync(reportPath)) {
const report = JSON.parse(fs.readFileSync(reportPath, 'utf8'));
const comment = `
## 🔍 CI Results
✅ **All checks passed!**
### Changes Summary:
- Total changes: ${report.totalChanges}
- Breaking changes: ${report.breakingChanges}
- Added: ${report.added}
- Removed: ${report.removed}
- Modified: ${report.modified}
Generated types are available as artifacts.
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}
# Job 6: Commit generated types (Only on main branch push)
commit-types:
runs-on: ubuntu-latest
needs: [lint-typecheck, tests, contract-tests]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Generate and snapshot types
run: |
npm run api:generate-spec
npm run api:generate-types
- name: Commit generated types
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add apps/website/lib/types/generated/
git diff --staged --quiet || git commit -m "chore: update generated API types [skip ci]"
git push

View File

@@ -1,110 +0,0 @@
name: Contract Testing
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
contract-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run API contract validation
run: npm run test:api:contracts
- name: Generate OpenAPI spec
run: npm run api:generate-spec
- name: Generate TypeScript types
run: npm run api:generate-types
- name: Run contract compatibility check
run: npm run test:contract:compatibility
- name: Verify website type checking
run: npm run website:type-check
- name: Upload generated types as artifacts
uses: actions/upload-artifact@v3
with:
name: generated-types
path: apps/website/lib/types/generated/
retention-days: 7
- name: Comment PR with results
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const path = require('path');
// Read any contract change reports
const reportPath = path.join(process.cwd(), 'contract-report.json');
if (fs.existsSync(reportPath)) {
const report = JSON.parse(fs.readFileSync(reportPath, 'utf8'));
const comment = `
## 🔍 Contract Testing Results
✅ **All contract tests passed!**
### Changes Summary:
- Total changes: ${report.totalChanges}
- Breaking changes: ${report.breakingChanges}
- Added: ${report.added}
- Removed: ${report.removed}
- Modified: ${report.modified}
Generated types are available as artifacts.
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}
contract-snapshot:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Generate and snapshot types
run: |
npm run api:generate-spec
npm run api:generate-types
- name: Commit generated types
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add apps/website/lib/types/generated/
git diff --staged --quiet || git commit -m "chore: update generated API types [skip ci]"
git push