1+ name : CI
2+
3+ on :
4+ pull_request :
5+ branches : [main]
6+ push :
7+ branches : [main]
8+ workflow_dispatch :
9+
10+ permissions :
11+ contents : read
12+
13+ concurrency :
14+ group : ci-${{ github.ref }}
15+ cancel-in-progress : true
16+
17+ jobs :
18+ test :
19+ name : Test (Node ${{ matrix.node-version }})
20+ runs-on : ${{ matrix.os }}
21+ strategy :
22+ fail-fast : false
23+ matrix :
24+ node-version : ['18', '20', '22']
25+ os : [ubuntu-latest]
26+ include :
27+ # Test on other OS with latest Node only
28+ - node-version : ' 20'
29+ os : macos-latest
30+ - node-version : ' 20'
31+ os : windows-latest
32+
33+ steps :
34+ - name : Checkout code
35+ uses : actions/checkout@v4
36+ with :
37+ fetch-depth : 0
38+
39+ - name : Setup pnpm
40+ uses : pnpm/action-setup@v4
41+ with :
42+ version : 9
43+
44+ - name : Setup Node.js ${{ matrix.node-version }}
45+ uses : actions/setup-node@v4
46+ with :
47+ node-version : ${{ matrix.node-version }}
48+ cache : ' pnpm'
49+
50+ - name : Install dependencies
51+ run : pnpm install --frozen-lockfile
52+
53+ - name : Build project
54+ run : pnpm run build
55+
56+ - name : Run tests
57+ run : pnpm test
58+
59+ - name : Upload test coverage
60+ if : matrix.node-version == '20' && matrix.os == 'ubuntu-latest'
61+ uses : actions/upload-artifact@v4
62+ with :
63+ name : coverage-report
64+ path : coverage/
65+ retention-days : 7
66+
67+ lint :
68+ name : Lint & Type Check
69+ runs-on : ubuntu-latest
70+ steps :
71+ - name : Checkout code
72+ uses : actions/checkout@v4
73+
74+ - name : Setup pnpm
75+ uses : pnpm/action-setup@v4
76+ with :
77+ version : 9
78+
79+ - name : Setup Node.js
80+ uses : actions/setup-node@v4
81+ with :
82+ node-version : ' 20'
83+ cache : ' pnpm'
84+
85+ - name : Install dependencies
86+ run : pnpm install --frozen-lockfile
87+
88+ - name : Build project
89+ run : pnpm run build
90+
91+ - name : Type check
92+ run : pnpm exec tsc --noEmit
93+
94+ - name : Check for build artifacts
95+ run : |
96+ if [ ! -d "dist" ]; then
97+ echo "Error: dist directory not found after build"
98+ exit 1
99+ fi
100+ if [ ! -f "dist/cli/index.js" ]; then
101+ echo "Error: CLI entry point not found"
102+ exit 1
103+ fi
104+
105+ validate-changesets :
106+ name : Validate Changesets
107+ runs-on : ubuntu-latest
108+ if : github.event_name == 'pull_request'
109+ steps :
110+ - name : Checkout code
111+ uses : actions/checkout@v4
112+ with :
113+ fetch-depth : 0
114+
115+ - name : Setup pnpm
116+ uses : pnpm/action-setup@v4
117+ with :
118+ version : 9
119+
120+ - name : Setup Node.js
121+ uses : actions/setup-node@v4
122+ with :
123+ node-version : ' 20'
124+ cache : ' pnpm'
125+
126+ - name : Install dependencies
127+ run : pnpm install --frozen-lockfile
128+
129+ - name : Validate changesets
130+ run : |
131+ if command -v changeset &> /dev/null; then
132+ pnpm exec changeset status --since=origin/main
133+ else
134+ echo "Changesets not configured, skipping validation"
135+ fi
136+
137+ required-checks :
138+ name : All checks passed
139+ runs-on : ubuntu-latest
140+ needs : [test, lint]
141+ if : always()
142+ steps :
143+ - name : Verify all checks passed
144+ run : |
145+ if [[ "${{ needs.test.result }}" != "success" ]]; then
146+ echo "Test job failed"
147+ exit 1
148+ fi
149+ if [[ "${{ needs.lint.result }}" != "success" ]]; then
150+ echo "Lint job failed"
151+ exit 1
152+ fi
153+ echo "All required checks passed!"
0 commit comments