Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/actions/smoke-test-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Smoke Test Setup"
description: "Installs the packed testcontainers package and its production dependencies into an empty project"

outputs:
path:
description: "Directory containing the smoke tests and the installed package"
value: ${{ steps.install.outputs.path }}

runs:
using: "composite"
steps:
- name: Build and pack testcontainers
shell: bash
run: |
npm run build --workspace packages/testcontainers
npm pack --workspace packages/testcontainers --pack-destination "${RUNNER_TEMP}"

- name: Install the package into an empty project
id: install
shell: bash
run: |
project="${RUNNER_TEMP}/smoke-test"
package="${project}/node_modules/testcontainers"

# Production dependencies only, at the versions in package-lock.json.
npm ci --omit=dev --workspace packages/testcontainers

mkdir "${project}"
echo '{ "private": true }' > "${project}/package.json"
cp .npmrc packages/testcontainers/smoke-test.* "${project}"
mv node_modules "${project}/node_modules"

# Replace the workspace link with the files that get published.
rm "${package}"
mkdir "${package}"
tar -xzf "${RUNNER_TEMP}"/testcontainers-*.tgz -C "${package}" --strip-components=1
if [ -d packages/testcontainers/node_modules ]; then
mv packages/testcontainers/node_modules "${package}/node_modules"
fi

echo "path=${project}" >> "$GITHUB_OUTPUT"
27 changes: 15 additions & 12 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,21 @@ jobs:
runner: ubuntu-24.04
node-version: ${{ matrix.node-version }}
workspace: "testcontainers"
- name: Build testcontainers
run: npm run build --workspace packages/testcontainers
- name: Remove dev dependencies
run: npm prune --omit=dev --workspace packages/testcontainers
- name: Install the packed package
id: smoke-test
uses: ./.github/actions/smoke-test-setup
- name: Run CommonJS module smoke test
run: node packages/testcontainers/smoke-test.js
working-directory: ${{ steps.smoke-test.outputs.path }}
run: node ./smoke-test.js
env:
DEBUG: "testcontainers*"
- name: Run ES module smoke test
run: node packages/testcontainers/smoke-test.mjs
working-directory: ${{ steps.smoke-test.outputs.path }}
run: node ./smoke-test.mjs
env:
DEBUG: "testcontainers*"
- name: Run Jest CommonJS runtime smoke test
working-directory: ${{ steps.smoke-test.outputs.path }}
run: npm exec --yes --package jest@30.4.2 -- jest --testMatch "**/smoke-test.jest.js" --runInBand --transform "{}"
env:
DEBUG: "testcontainers*"
Expand All @@ -163,20 +165,21 @@ jobs:
runner: ubuntu-24.04
node-version: 24.x
workspace: "testcontainers"
- name: Build testcontainers
run: npm run build --workspace packages/testcontainers
- name: Remove dev dependencies
run: npm prune --omit=dev --workspace packages/testcontainers
- name: Install the packed package
id: smoke-test
uses: ./.github/actions/smoke-test-setup
- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.2
- name: Run CommonJS module smoke test
run: bun packages/testcontainers/smoke-test.js
working-directory: ${{ steps.smoke-test.outputs.path }}
run: bun ./smoke-test.js
env:
DEBUG: "testcontainers*"
- name: Run ES module smoke test
run: bun packages/testcontainers/smoke-test.mjs
working-directory: ${{ steps.smoke-test.outputs.path }}
run: bun ./smoke-test.mjs
env:
DEBUG: "testcontainers*"

Expand Down
2 changes: 1 addition & 1 deletion packages/testcontainers/smoke-test.jest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { GenericContainer } = require("./build/index");
const { GenericContainer } = require("testcontainers");

jest.setTimeout(120_000);

Expand Down
2 changes: 1 addition & 1 deletion packages/testcontainers/smoke-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { GenericContainer } = require("./build/index");
const { GenericContainer } = require("testcontainers");

(async () => {
const container = await new GenericContainer("alpine:3.12").withCommand(["sleep", "infinity"]).start();
Expand Down
2 changes: 1 addition & 1 deletion packages/testcontainers/smoke-test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GenericContainer } from "./build/index.js";
import { GenericContainer } from "testcontainers";

const container = await new GenericContainer("alpine:3.12").withCommand(["sleep", "infinity"]).start();

Expand Down
Loading