Repository navigation
295 lines (280 loc) · 11.3 KB
/
Copy pathci.yml
File metadata and controls
295 lines (280 loc) · 11.3 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master, 'release/**']
workflow_dispatch:
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CI: true
jobs:
quality:
name: Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 22.13.0
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run format:check
- run: pnpm run lint
- run: pnpm run typecheck
- run: pnpm run test:release
- name: Validate release metadata
if: startsWith(github.head_ref, 'release/v')
env:
RELEASE_BRANCH: ${{ github.head_ref }}
run: node scripts/validate-release.mjs "${RELEASE_BRANCH#release/}"
test:
name: Test / Node ${{ matrix.node }}
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
node: [22.13.0, 24.x]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run test:coverage
- name: Upload coverage
if: matrix.node == '22.13.0'
uses: codecov/codecov-action@v5
with:
files: coverage/lcov.info
fail_ci_if_error: true
use_oidc: true
package:
name: Package artifact
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 22.13.0
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run build
- run: pnpm run package:check
- name: Create immutable candidate tarball
run: |
mkdir -p artifacts
pnpm pack --pack-destination artifacts
mv artifacts/*.tgz artifacts/fleetbase-sdk.tgz
- uses: actions/upload-artifact@v4
with:
name: npm-package
path: artifacts/*.tgz
if-no-files-found: error
retention-days: 14
cross-platform:
name: Smoke / ${{ matrix.os }} / Node ${{ matrix.node }}
needs: package
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [20.19.4, 22.13.0, 24.x]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: npm-package
path: artifacts
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install exact candidate
run: node -e "const fs=require('fs'); fs.mkdirSync('consumer'); fs.writeFileSync('consumer/package.json', JSON.stringify({name:'sdk-consumer',private:true,type:'module'}))"
- run: npm install ../artifacts/fleetbase-sdk.tgz
working-directory: consumer
- run: node --input-type=module -e "import Fleetbase from '@fleetbase/sdk'; if (typeof Fleetbase !== 'function') process.exit(1)"
working-directory: consumer
- run: node -e "const sdk = require('@fleetbase/sdk'); if (typeof sdk.default !== 'function') process.exit(1)"
working-directory: consumer
- run: node ../scripts/verify-runtime.mjs
working-directory: consumer
package-manager:
name: Install / ${{ matrix.manager }}
needs: package
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
manager: [npm, pnpm, yarn, bun]
steps:
- uses: actions/download-artifact@v4
with:
name: npm-package
path: artifacts
- uses: actions/setup-node@v4
with:
node-version: 22.13.0
- uses: pnpm/action-setup@v4
if: matrix.manager == 'pnpm'
with:
version: 11.24.0
- uses: oven-sh/setup-bun@v2
if: matrix.manager == 'bun'
with:
bun-version: 1.3.14
- name: Prepare consumer
run: mkdir -p consumer && echo '{"name":"sdk-consumer","private":true,"type":"module"}' > consumer/package.json
- name: Install with npm
if: matrix.manager == 'npm'
working-directory: consumer
run: npm install ../artifacts/fleetbase-sdk.tgz && node --input-type=module -e "import Fleetbase from '@fleetbase/sdk'; if (typeof Fleetbase !== 'function') process.exit(1)" && node -e "if (typeof require('@fleetbase/sdk').default !== 'function') process.exit(1)"
- name: Install with pnpm
if: matrix.manager == 'pnpm'
working-directory: consumer
run: pnpm add ../artifacts/fleetbase-sdk.tgz && node --input-type=module -e "import Fleetbase from '@fleetbase/sdk'; if (typeof Fleetbase !== 'function') process.exit(1)" && node -e "if (typeof require('@fleetbase/sdk').default !== 'function') process.exit(1)"
- name: Install with Yarn Berry
if: matrix.manager == 'yarn'
working-directory: consumer
run: corepack prepare yarn@4.18.0 --activate && yarn add ../artifacts/fleetbase-sdk.tgz && yarn node --input-type=module -e "import Fleetbase from '@fleetbase/sdk'; if (typeof Fleetbase !== 'function') process.exit(1)" && yarn node -e "if (typeof require('@fleetbase/sdk').default !== 'function') process.exit(1)"
- name: Install with Bun
if: matrix.manager == 'bun'
working-directory: consumer
run: bun add ../artifacts/fleetbase-sdk.tgz && bun --eval "import Fleetbase from '@fleetbase/sdk'; if (typeof Fleetbase !== 'function') process.exit(1)"
type-consumer:
name: Types / ${{ matrix.resolution }} / TS ${{ matrix.typescript }}
needs: package
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
resolution: [node16, nodenext, bundler]
typescript: [5.0.4, 6.0.2]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: npm-package
path: artifacts
- uses: actions/setup-node@v4
with:
node-version: 22.13.0
- name: Install exact candidate and TypeScript
working-directory: fixtures/types
run: npm install ../../artifacts/fleetbase-sdk.tgz typescript@${{ matrix.typescript }}
- name: Compile strict consumer
working-directory: fixtures/types
run: npx tsc -p tsconfig.${{ matrix.resolution }}.json
compatibility:
name: Build / ${{ matrix.fixture }}
needs: package
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
fixture: [vite, webpack, esbuild, react, vue, svelte, angular, ember, next, nuxt, expo, edge]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: npm-package
path: artifacts
- uses: actions/setup-node@v4
with:
node-version: 24.15.0
- uses: pnpm/action-setup@v4
with:
version: 11.24.0
- name: Install pinned fixture dependencies
working-directory: fixtures/compat/${{ matrix.fixture }}
run: pnpm install --no-frozen-lockfile
- name: Install exact SDK candidate
working-directory: fixtures/compat/${{ matrix.fixture }}
run: pnpm add --save-dev ../../../artifacts/fleetbase-sdk.tgz
- name: Build production fixture
working-directory: fixtures/compat/${{ matrix.fixture }}
run: pnpm run build
browser:
name: Browser / Playwright engines
needs: package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: npm-package
path: artifacts
- uses: actions/setup-node@v4
with:
node-version: 24.15.0
- uses: pnpm/action-setup@v4
with:
version: 11.24.0
- name: Install pinned browser dependencies
working-directory: fixtures/browser
run: pnpm install --no-frozen-lockfile
- name: Install exact SDK candidate
working-directory: fixtures/browser
run: pnpm add --save-dev ../../artifacts/fleetbase-sdk.tgz
- name: Install browser engines
working-directory: fixtures/browser
run: pnpm exec playwright install --with-deps chromium firefox webkit
- name: Build and execute browser fixture
working-directory: fixtures/browser
run: pnpm run build && pnpm run test:browser
dependency-review:
name: Dependency review
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/dependency-review-action@v4
with:
fail-on-severity: high
security:
name: Dependency audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 22.13.0
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm audit --prod --audit-level high
- run: pnpm audit --audit-level high
ci-success:
name: CI success
if: always()
needs: [quality, test, package, cross-platform, package-manager, type-consumer, compatibility, browser, dependency-review, security]
runs-on: ubuntu-latest
steps:
- name: Require successful jobs
env:
RESULTS: ${{ join(needs.*.result, ',') }}
run: |
case "$RESULTS" in
*failure*|*cancelled*) exit 1 ;;
*) exit 0 ;;
esac