-
-
Notifications
You must be signed in to change notification settings - Fork 10
221 lines (184 loc) · 6.59 KB
/
ci.yml
File metadata and controls
221 lines (184 loc) · 6.59 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
classify:
runs-on: ubuntu-latest
outputs:
full-suite: ${{ steps.check.outputs.full-suite }}
steps:
- id: check
env:
EVENT_NAME: ${{ github.event_name }}
HEAD_REF: ${{ github.head_ref }}
run: |
if [[ "$EVENT_NAME" == "push" ]] || \
[[ "$HEAD_REF" == changeset-release/* ]]; then
echo "full-suite=true" >> "$GITHUB_OUTPUT"
else
echo "full-suite=false" >> "$GITHUB_OUTPUT"
fi
build-and-test-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 2
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: pnpm format:check
- run: pnpm test
build-and-test-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 2
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: pnpm format:check
- run: pnpm test
build-and-test-full:
needs: classify
if: needs.classify.outputs.full-suite == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [20, 22]
exclude:
# These are already covered by the light jobs
- os: ubuntu-latest
node-version: 22
- os: windows-latest
node-version: 22
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 2
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: pnpm format:check
- run: pnpm test
coverage:
needs: classify
if: needs.classify.outputs.full-suite == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
# Exclude server-git: its V8 coverage provider crashes with forked
# pool (ENOENT on coverage temp files). Tests still run in build-and-test.
- run: pnpm turbo run test --filter='!@paretools/git' --continue -- --coverage
- uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm lint
smoke:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: pnpm smoke
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm audit --audit-level=high
ci-gate:
# Always run, even if upstream jobs are skipped
if: always()
needs:
- build-and-test-ubuntu
- build-and-test-windows
- build-and-test-full
- coverage
- lint
- smoke
- audit
runs-on: ubuntu-latest
steps:
- name: Check required jobs
run: |
echo "Checking required jobs..."
if [[ "${{ needs.lint.result }}" != "success" ]]; then
echo "lint failed: ${{ needs.lint.result }}"
exit 1
fi
if [[ "${{ needs.smoke.result }}" != "success" ]]; then
echo "smoke failed: ${{ needs.smoke.result }}"
exit 1
fi
if [[ "${{ needs.build-and-test-ubuntu.result }}" != "success" ]]; then
echo "build-and-test-ubuntu failed: ${{ needs.build-and-test-ubuntu.result }}"
exit 1
fi
if [[ "${{ needs.build-and-test-windows.result }}" != "success" ]]; then
echo "build-and-test-windows failed: ${{ needs.build-and-test-windows.result }}"
exit 1
fi
# Advisory: audit is informational — npm registry outages (HTTP 500) must not block PRs
if [[ "${{ needs.audit.result }}" == "failure" ]]; then
echo "⚠ audit failed (advisory, non-blocking): ${{ needs.audit.result }}"
fi
# Conditional jobs: must pass if they ran, OK to skip
for result in "${{ needs.build-and-test-full.result }}" "${{ needs.coverage.result }}"; do
if [[ "$result" != "success" && "$result" != "skipped" && "$result" != "cancelled" ]]; then
echo "Conditional job failed: $result"
exit 1
fi
if [[ "$result" == "cancelled" ]]; then
echo "⚠ Conditional job was cancelled (non-blocking)"
fi
done
echo "All required checks passed!"