Skip to content

feat: improve project quality and user experience #26

feat: improve project quality and user experience

feat: improve project quality and user experience #26

# 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