Repository navigation
Run the smoke tests against the packed package - #1499
Draft
cristianrgreco wants to merge 2 commits into
Draft
cristianrgreco wants to merge 2 commits into
cristianrgreco wants to merge 2 commits into
Conversation
Pack the built package and install the tarball into an empty project, then run the smoke tests there. They now import "testcontainers" by name, so they exercise the published files, the `main` entry and only the declared production dependencies.
Install the production dependencies with `npm ci --omit=dev` so the smoke tests use the versions in package-lock.json, then swap the workspace link for the unpacked tarball. Both jobs now share this through a smoke-test-setup action.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The smoke tests now run against the package as it is published, with only its production dependencies installed.
A new
smoke-test-setupaction does the setup for both smoke-test jobs:packages/testcontainers.npm ci --omit=dev --workspace packages/testcontainers, which installs only the package's production dependencies, at the versions inpackage-lock.json.node_modulesinto an empty project in the runner's temp directory and replaces the workspace link with the unpacked tarball.pathoutput.The jobs then run the smoke tests from that directory. Other changes:
smoke-test.js,smoke-test.mjsandsmoke-test.jest.jsimporttestcontainersby name instead of./build/index. They still run from the repository after a build, because the workspace link resolves the name tobuild/index.js.npm prune --omit=devstep is removed.Why
The prune step never produced a production-only environment. Measured locally, it removes 11 packages (the package's
@types/*dev dependencies) and leaves about 325 installed, including vitest, TypeScript and Biome from the root. And because the tests imported./build/indexfrom inside the repository, they never went through the package'smainentry or itsfileslist.Dependency versions are unchanged: they still come from
package-lock.json, so a run is reproducible and can't fail because of a new upstream release.Verification
The action's two scripts were run locally, verbatim, in a copy of the repository installed the way the job installs it:
package-lock.jsonversion and none is dev-only. vitest, TypeScript, Biome and shx are absent.node_modules/testcontainersis a real directory holding the tarball's files (build,package.json,README.md,LICENSE), plus the two dependencies the lockfile nests under the package (undici,get-port).node ./smoke-test.jsandnode ./smoke-test.mjsexit 0, and the Jest smoke test passes (1 test)."main"pointed at a missing file: fails withPlease verify that the package.json has a valid "main" entry. The old test's import of./build/indexstill loads in that state.byline) removed: fails withCannot find module 'byline'.npm run format,npm run lint: no fixes applied.Related PRs
knip.jsoncentry forpackages/testcontainersneeds to change fromsmoke-test.jest.jstosmoke-test.*, because the workflow no longer references the other two files by their repository path. Checked locally with Detect unused code and dependencies with knip #1492's config: with that entry, knip reports nothing for the smoke tests.Why this isn't breaking
CI and smoke-test files only. The smoke-test files aren't published (
filesis["build"]), and no package source or dependency changes.