-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (72 loc) · 2.28 KB
/
test-all-versions.yml
File metadata and controls
86 lines (72 loc) · 2.28 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
# Test All Node.js Versions Workflow
#
# This workflow ensures the package works correctly across all supported Node.js versions.
# It runs on every push/PR to master branch.
#
# What it does:
# 1. Builds the package once using Node.js 22.x (latest)
# 2. Creates a tarball package using 'yarn pack'
# 3. Tests the built package on multiple Node.js versions (14.x, 16.x, 18.x, 20.x, 22.x)
# 4. Verifies the package can be installed and used correctly on each version
# 5. Uses artifacts to share the built package between jobs efficiently
#
# This ensures compatibility across different Node.js environments and catches
# version-specific issues early.
name: Test All Node.js Versions
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
registry-url: 'https://registry.npmjs.org'
- name: Install all dependencies
run: yarn install --frozen-lockfile
- name: Build package
run: yarn build
- name: Run project tests
run: yarn test
- name: Pack package
run: yarn pack
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: package-dist
path: |
simple-wcswidth-*.tgz
test/githubActionsTest/package-test.js
dist/
test:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x, 22.x]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: package-dist
- name: Test package
run: |
mkdir test-pkg && cd test-pkg
mv ../simple-wcswidth-*.tgz ./
mv ../test/githubActionsTest/package-test.js ./
yarn init -y
yarn add ./simple-wcswidth-*.tgz
echo "Running tests on Node.js ${{ matrix.node-version }}..."
node package-test.js