forked from vercel/pkg
-
-
Notifications
You must be signed in to change notification settings - Fork 61
131 lines (119 loc) · 4.27 KB
/
ci.yml
File metadata and controls
131 lines (119 loc) · 4.27 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
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
# Detect whether anything outside docs-site/ changed. Docs-only PRs still
# trigger the downstream jobs so their required status checks report, but
# every expensive step is skipped via `if:` — the checks appear as success
# in a few seconds without burning CI minutes on the full matrix.
changes:
runs-on: ubuntu-latest
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code:
- '!docs-site/**'
# Single-purpose job that produces the build artifact test jobs consume.
# Non-matrix, Linux only, so tests don't block on the slowest matrix cell
# (Windows build can take 80-150s). Build output is platform-independent
# compiled TS + bundled JS.
build_artifact:
needs: changes
runs-on: ubuntu-latest
steps:
- if: needs.changes.outputs.code == 'true'
uses: actions/checkout@v4
- if: needs.changes.outputs.code == 'true'
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'yarn'
- if: needs.changes.outputs.code == 'true'
run: yarn install
- if: needs.changes.outputs.code == 'true'
run: yarn lint
- if: needs.changes.outputs.code == 'true'
run: yarn build
- if: needs.changes.outputs.code == 'true'
uses: actions/upload-artifact@v4
with:
name: build-output
path: |
lib-es5/
prelude/sea-bootstrap.bundle.js
retention-days: 1
# Coverage upload — unit-suite only on every PR (~2s). E2E coverage is
# uploaded from the canonical Ubuntu cells in `.github/workflows/test.yml`
# with `flags: e2e`; Codecov merges the two flags via carryforward (see
# codecov.yml) so PR reports reflect unit + e2e combined. The `build`
# matrix runs `yarn test:unit` on 3 OS × Node 22/24 to verify platform
# behavior; this is the single canonical unit-coverage upload.
- if: needs.changes.outputs.code == 'true'
run: yarn coverage:unit
- if: needs.changes.outputs.code == 'true'
name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: yao-pkg/pkg
files: coverage/lcov.info
flags: unit
fail_ci_if_error: false
# Sanity check: `yarn build` succeeds on every supported OS + Node combo.
# Runs in parallel with tests (they don't consume this job's output) so
# failures still mark the PR red without gating the test jobs.
build:
needs: changes
strategy:
fail-fast: false # prevent test to stop if one fails
matrix:
node-version: [22.x, 24.x]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- if: needs.changes.outputs.code == 'true'
uses: actions/checkout@v4
- if: needs.changes.outputs.code == 'true'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- if: needs.changes.outputs.code == 'true'
run: yarn install
- if: needs.changes.outputs.code == 'true'
run: yarn build
# Unit suite is in-process (node:test + esbuild-register) and takes
# ~1s, so it rides the existing per-(os,node) build matrix. This gives
# Windows- and Node 24-specific path/runtime coverage for free — both
# matter for common.test.ts's win32 branch.
- if: needs.changes.outputs.code == 'true'
run: yarn test:unit
test_host:
needs: [changes, build_artifact]
uses: ./.github/workflows/test.yml
secrets: inherit
with:
npm_command: test:host
should_run: ${{ needs.changes.outputs.code }}
test_22:
needs: [changes, build_artifact]
uses: ./.github/workflows/test.yml
secrets: inherit
with:
npm_command: test:22
should_run: ${{ needs.changes.outputs.code }}
test_24:
needs: [changes, build_artifact]
uses: ./.github/workflows/test.yml
secrets: inherit
with:
npm_command: test:24
should_run: ${{ needs.changes.outputs.code }}