Skip to content

test: split unit tests into node:test suite, add c8 coverage #596

test: split unit tests into node:test suite, add c8 coverage

test: split unit tests into node:test suite, add c8 coverage #596

Workflow file for this run

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. The full `yarn coverage` (unit + e2e)
# is 30+ min and not worth paying on every PR; a follow-up can add a
# nightly or labeled job for the merged report. The `build` matrix runs
# `yarn test:unit` on 3 OS × Node 22/24 to verify platform behavior; this
# is the single canonical upload for Codecov.
- 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
with:
npm_command: test:host
should_run: ${{ needs.changes.outputs.code }}
test_22:
needs: [changes, build_artifact]
uses: ./.github/workflows/test.yml
with:
npm_command: test:22
should_run: ${{ needs.changes.outputs.code }}
test_24:
needs: [changes, build_artifact]
uses: ./.github/workflows/test.yml
with:
npm_command: test:24
should_run: ${{ needs.changes.outputs.code }}