-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (159 loc) · 6.42 KB
/
Copy pathci.yml
File metadata and controls
190 lines (159 loc) · 6.42 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
# ──────────────────────────────────────────────────────────────────────────────
# CI — Primary quality gate for all pushes and pull requests
#
# Runs on every push to main/develop and every PR targeting them.
# Matrix: Node 20.x and 22.x on Ubuntu.
#
# Steps: install → typecheck → unit tests (with coverage) → build → e2e tests
# ──────────────────────────────────────────────────────────────────────────────
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_call: # Allow reuse from release workflow
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# ── Typecheck ────────────────────────────────────────────────────────────
typecheck:
name: Typecheck (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: ['20.x', '22.x']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Typecheck
run: npm run typecheck
# ── Unit Tests ───────────────────────────────────────────────────────────
unit-tests:
name: Unit Tests (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
needs: typecheck
strategy:
fail-fast: false
matrix:
node-version: ['20.x', '22.x']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Run unit tests with coverage
run: npm run test:coverage
- name: Upload coverage artifact
if: matrix.node-version == '22.x'
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: coverage/
retention-days: 14
# ── Build ────────────────────────────────────────────────────────────────
build:
name: Build (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
needs: typecheck
strategy:
fail-fast: false
matrix:
node-version: ['20.x', '22.x']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Verify build artifacts exist
run: |
test -f out/dist/index.js || (echo "Missing: out/dist/index.js" && exit 1)
test -f out/dist/cli/server.js || (echo "Missing: out/dist/cli/server.js" && exit 1)
test -f out/tsc/index.d.ts || (echo "Missing: out/tsc/index.d.ts" && exit 1)
echo "All build artifacts verified."
- name: Verify CLI binary has shebang
run: head -1 out/dist/cli/server.js | grep -q '#!/usr/bin/env node'
- name: Upload build artifacts
if: matrix.node-version == '22.x'
uses: actions/upload-artifact@v7
with:
name: build-output
path: |
out/dist/
out/tsc/
retention-days: 7
# ── E2E Tests ────────────────────────────────────────────────────────────
e2e-tests:
name: E2E Tests (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
node-version: ['20.x', '22.x']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Build (required for e2e)
run: npm run build
- name: Run E2E tests
run: npm run test:e2e
# ── Package Dry Run ─────────────────────────────────────────────────────
package-check:
name: Package Dry Run
runs-on: ubuntu-latest
needs: [unit-tests, build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: '22.x'
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Pack dry run
run: npm pack --dry-run 2>&1 | tee pack-output.txt
- name: Verify package contents
run: |
# Ensure critical files are included in the package
grep -q 'out/dist/index.js' pack-output.txt || (echo "Missing: out/dist/index.js in package" && exit 1)
grep -q 'out/dist/cli/server.js' pack-output.txt || (echo "Missing: out/dist/cli/server.js in package" && exit 1)
grep -q 'out/tsc/index.d.ts' pack-output.txt || (echo "Missing: out/tsc/index.d.ts in package" && exit 1)
grep -q 'README.md' pack-output.txt || (echo "Missing: README.md in package" && exit 1)
grep -q 'LICENSE' pack-output.txt || (echo "Missing: LICENSE in package" && exit 1)
grep -q 'POWER.md' pack-output.txt || (echo "Missing: POWER.md in package" && exit 1)
echo "Package contents verified."