forked from vercel/pkg
-
-
Notifications
You must be signed in to change notification settings - Fork 66
94 lines (87 loc) · 3.35 KB
/
Copy pathtest.yml
File metadata and controls
94 lines (87 loc) · 3.35 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
name: CI
on:
workflow_call:
inputs:
npm_command:
description: 'NPM command to run'
type: string
required: true
default: 'install'
should_run:
description: "Whether to actually execute the test. When 'false' the job runs but every step is skipped — this preserves the required-status-check contexts on docs-only PRs without burning CI minutes."
type: string
required: false
default: 'true'
jobs:
test:
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: inputs.should_run == 'true'
uses: actions/checkout@v4
- if: inputs.should_run == 'true'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- if: inputs.should_run == 'true'
uses: actions/cache@v4
with:
path: ~/.pkg-cache/
key: pkg-cache-${{ matrix.os }}-${{ matrix.node-version }}
restore-keys: |
pkg-cache-${{ matrix.os }}-
${{ matrix.os }}-${{ matrix.node-version }}
- if: inputs.should_run == 'true'
run: yarn install
# Download pre-built lib-es5/ from the build job instead of rebuilding.
- if: inputs.should_run == 'true'
uses: actions/download-artifact@v4
with:
name: build-output
# Two canonical Ubuntu cells (Node 22 host + test:22 target; Node 24
# host + test:24 target) wrap their e2e run in c8 to capture coverage.
# Every other cell (Windows, macOS, mixed host/target) runs the test
# command plainly — the canonical cells already exercise the same
# lib/ code paths, so extra uploads from them would just duplicate
# data for Codecov to merge and discard.
- name: Canonical cell?
id: cov
shell: bash
if: inputs.should_run == 'true'
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" && \
( ( "${{ inputs.npm_command }}" == "test:22" && "${{ matrix.node-version }}" == "22.x" ) || \
( "${{ inputs.npm_command }}" == "test:24" && "${{ matrix.node-version }}" == "24.x" ) ) ]]; then
echo "coverage=true" >> "$GITHUB_OUTPUT"
else
echo "coverage=false" >> "$GITHUB_OUTPUT"
fi
- if: inputs.should_run == 'true' && steps.cov.outputs.coverage != 'true'
run: yarn ${{ inputs.npm_command }}
env:
CI: true
timeout-minutes: 30
- if: inputs.should_run == 'true' && steps.cov.outputs.coverage == 'true' && inputs.npm_command == 'test:22'
run: yarn coverage:e2e
env:
CI: true
timeout-minutes: 40
- if: inputs.should_run == 'true' && steps.cov.outputs.coverage == 'true' && inputs.npm_command == 'test:24'
run: yarn coverage:e2e:24
env:
CI: true
timeout-minutes: 40
- if: inputs.should_run == 'true' && steps.cov.outputs.coverage == 'true'
name: Upload e2e coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: yao-pkg/pkg
files: coverage/lcov.info
flags: e2e
fail_ci_if_error: false