Quick Answers: Building a Test Matrix for a Published Package

An application runs in one environment you control. A package runs in every environment its users have. A test matrix is how you check a reasonable slice of those environments without testing all of them. Here are short, practical answers to the questions that come up when setting one up.

What goes into the matrix

Which runtime versions should I test?

Every version you claim to support, and no others. If engines in package.json or requires-python in pyproject.toml says you support a range, test at least the lowest and highest versions in it. Testing the lowest is the one people skip, and it is where accidental use of newer syntax or standard-library features is caught.

Do I need several operating systems?

If your package touches the filesystem, spawns processes, handles paths or line endings, or ships native code, yes: include Windows and macOS alongside Linux. For pure computational code, Linux alone is often enough, with an occasional full run.

Should dependency versions be part of the matrix?

For peer dependencies, absolutely: test against each major version your peer range allows. For regular dependencies, one extra job that installs the minimum versions your ranges permit is a valuable sanity check, because day-to-day development always uses the newest.

An example layout

# GitHub Actions, illustrative
strategy:
  fail-fast: false
  matrix:
    os: [ubuntu-latest, windows-latest, macos-latest]
    node: [20, 22]
    include:
      - os: ubuntu-latest
        node: 24
        experimental: true

Setting fail-fast: false lets every combination finish, so one failure does not hide others. The include entry adds a forward-looking job for a newer runtime without multiplying the whole grid.

Keeping it manageable

The matrix is too slow. What do I cut?

Do not run the full cross product on every push. Run a small core (one OS, lowest and highest runtime) on pull requests, and the full matrix on the main branch, on a schedule, and before releases.

Should a job against an unreleased runtime block merges?

Usually not. Mark it as allowed to fail and review its results periodically. It gives early warning without blocking contributors over problems outside your control.

Do lockfiles matter for library tests?

A lockfile keeps your own CI reproducible, but your users will not install from it, since published libraries are resolved fresh in each consumer project. Add at least one job that ignores the lockfile and resolves dependencies from your declared ranges, so you see what users see.

What about testing the published artefact?

Include one job that builds the package, packs it, installs the result into an empty project and imports it. Many packaging bugs only appear there.

When do I drop a matrix entry?

When you drop support for that environment, which is a decision for your versioning policy. Remove the entry in the same release that updates engines or requires-python, and note it in the changelog.