1+ name : CI
2+
3+ on :
4+ pull_request :
5+ branches : [main]
6+ push :
7+ branches : [main]
8+
9+ # Cancel in-progress runs when a new run is triggered on the same branch
10+ concurrency :
11+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+ cancel-in-progress : true
13+
14+ jobs :
15+ typecheck :
16+ name : Type Check
17+ runs-on : ubuntu-latest
18+
19+ steps :
20+ - name : Checkout code
21+ uses : actions/checkout@v4
22+
23+ - name : Setup Node.js
24+ uses : actions/setup-node@v4
25+ with :
26+ node-version : 20
27+ cache : ' npm'
28+
29+ - name : Install dependencies
30+ run : npm ci
31+
32+ - name : Run TypeScript type checking
33+ run : npm run typecheck
34+
35+ test :
36+ name : Test
37+ runs-on : ubuntu-latest
38+
39+ strategy :
40+ matrix :
41+ node-version : [18, 20, 22]
42+
43+ steps :
44+ - name : Checkout code
45+ uses : actions/checkout@v4
46+
47+ - name : Setup Node.js ${{ matrix.node-version }}
48+ uses : actions/setup-node@v4
49+ with :
50+ node-version : ${{ matrix.node-version }}
51+ cache : ' npm'
52+
53+ - name : Install dependencies
54+ run : npm ci
55+
56+ - name : Run tests
57+ run : npm test
58+
59+ - name : Generate coverage report
60+ if : matrix.node-version == 20
61+ run : npm run test:coverage
62+
63+ - name : Upload coverage reports
64+ if : matrix.node-version == 20
65+ uses : actions/upload-artifact@v4
66+ with :
67+ name : coverage-report
68+ path : coverage/
69+
70+ build :
71+ name : Build
72+ runs-on : ubuntu-latest
73+ needs : [typecheck, test]
74+
75+ steps :
76+ - name : Checkout code
77+ uses : actions/checkout@v4
78+
79+ - name : Setup Node.js
80+ uses : actions/setup-node@v4
81+ with :
82+ node-version : 20
83+ cache : ' npm'
84+
85+ - name : Install dependencies
86+ run : npm ci
87+
88+ - name : Build the library
89+ run : npm run build
90+
91+ - name : Verify build outputs
92+ run : |
93+ echo "Checking build outputs..."
94+ ls -la dist/
95+
96+ # Verify expected files exist
97+ if [[ ! -f "dist/index.js" ]]; then
98+ echo "Error: dist/index.js not found"
99+ exit 1
100+ fi
101+
102+ if [[ ! -f "dist/index.cjs" ]]; then
103+ echo "Error: dist/index.cjs not found"
104+ exit 1
105+ fi
106+
107+ if [[ ! -f "dist/index.d.ts" ]]; then
108+ echo "Error: dist/index.d.ts not found"
109+ exit 1
110+ fi
111+
112+ echo "✅ All build outputs verified successfully"
113+
114+ - name : Upload build artifacts
115+ uses : actions/upload-artifact@v4
116+ with :
117+ name : build-artifacts
118+ path : dist/
119+
120+ # Summary job to ensure all checks pass
121+ ci-success :
122+ name : CI Success
123+ runs-on : ubuntu-latest
124+ needs : [typecheck, test, build]
125+ if : always()
126+
127+ steps :
128+ - name : Check all jobs status
129+ run : |
130+ if [[ "${{ needs.typecheck.result }}" != "success" || \
131+ "${{ needs.test.result }}" != "success" || \
132+ "${{ needs.build.result }}" != "success" ]]; then
133+ echo "❌ One or more CI checks failed"
134+ echo "TypeCheck: ${{ needs.typecheck.result }}"
135+ echo "Test: ${{ needs.test.result }}"
136+ echo "Build: ${{ needs.build.result }}"
137+ exit 1
138+ fi
139+ echo "✅ All CI checks passed successfully!"
0 commit comments