Skip to content

Add node 26 to test matrix #845

Add node 26 to test matrix

Add node 26 to test matrix #845

Workflow file for this run

name: Checks
on:
push:
branches: [main]
paths-ignore:
- "mkdocs.yml"
- "docs/**"
- "README.md"
pull_request:
branches: [main]
paths-ignore:
- "mkdocs.yml"
- "docs/**"
- "README.md"
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.sha }}"
cancel-in-progress: true
permissions:
contents: read
jobs:
detect-modules:
name: Detect packages to check
runs-on: ubuntu-24.04
outputs:
modules: ${{ steps.detect.outputs.modules }}
modules_count: ${{ steps.detect.outputs.modules_count }}
has_testcontainers: ${{ steps.detect.outputs.has_testcontainers }}
steps:
- name: Check out code
uses: actions/checkout@v6
with:
fetch-depth: 0
- id: detect
name: Detect changed packages
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
changed_files="${RUNNER_TEMP}/changed-files.txt"
git diff --name-only "${BASE_SHA}...${HEAD_SHA}" > "${changed_files}"
modules="$(node ./.github/scripts/changed-modules.mjs < "${changed_files}")"
modules_count="$(jq 'length' <<< "${modules}")"
has_testcontainers="$(jq 'index("testcontainers") != null' <<< "${modules}")"
echo "modules=${modules}" >> "${GITHUB_OUTPUT}"
echo "modules_count=${modules_count}" >> "${GITHUB_OUTPUT}"
echo "has_testcontainers=${has_testcontainers}" >> "${GITHUB_OUTPUT}"
echo "${modules_count} packages in the build"
echo "${modules}"
lint:
if: ${{ needs.detect-modules.outputs.modules_count != '0' }}
name: "Lint"
needs:
- detect-modules
strategy:
fail-fast: false
matrix:
module: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
runs-on: ubuntu-24.04
steps:
- name: Code checkout
uses: actions/checkout@v6
- name: Install Node and Dependencies
id: npm-install-modules
uses: ./.github/actions/npm-setup
with:
runner: ubuntu-24.04
node-version: 24.x
workspace: "${{ matrix.module }}"
- name: Code linting
env:
WORKSPACE_PATH: ${{ steps.npm-install-modules.outputs.workspace_path }}
run: npm run lint:ci
compile:
if: ${{ needs.detect-modules.outputs.modules_count != '0' }}
name: Compile
needs:
- detect-modules
- lint
strategy:
fail-fast: false
matrix:
module: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
runs-on: ubuntu-24.04
steps:
- name: Code checkout
uses: actions/checkout@v6
- name: Install Node and Dependencies
id: npm-install
uses: ./.github/actions/npm-setup
with:
runner: ubuntu-24.04
node-version: 24.x
workspace: "${{ matrix.module }}"
- name: Compile
run: |
npm run build --ignore-scripts --workspace packages/testcontainers -- --project tsconfig.json
if [ "${{ matrix.module }}" != "testcontainers" ]; then
npm run build --ignore-scripts --workspace ${{ steps.npm-install.outputs.workspace_path }} -- --project tsconfig.json --noEmit
fi
smoke-test:
if: ${{ needs.detect-modules.outputs.has_testcontainers == 'true' }}
needs:
- detect-modules
- lint
- compile
name: Smoke tests
strategy:
fail-fast: false
matrix:
node-version: [22.x, 24.x, 26.x]
runs-on: ubuntu-24.04
steps:
- name: Code checkout
uses: actions/checkout@v6
- name: Install Node ${{ matrix.node-version }} and Dependencies
uses: ./.github/actions/npm-setup
with:
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: Run CommonJS module smoke test
run: node packages/testcontainers/smoke-test.js
env:
DEBUG: "testcontainers*"
- name: Run ES module smoke test
run: node packages/testcontainers/smoke-test.mjs
env:
DEBUG: "testcontainers*"
test:
if: ${{ needs.detect-modules.outputs.modules_count != '0' }}
name: Tests
needs:
- detect-modules
- lint
- compile
strategy:
fail-fast: false
max-parallel: 20
matrix:
module: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
node-version: [22.x, 24.x, 26.x]
container-runtime: [docker, podman]
uses: ./.github/workflows/test-template.yml
with:
runner: ubuntu-24.04
node-version: ${{ matrix.node-version }}
container-runtime: ${{ matrix.container-runtime }}
workspace: "${{ matrix.module }}"
end:
if: ${{ always() && needs.detect-modules.outputs.modules_count != '0' }}
name: Checks complete
needs:
- detect-modules
- lint
- compile
- smoke-test
- test
runs-on: ubuntu-24.04
steps:
- name: Check if any jobs failed
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1
- run: echo "All tests completed successfully!"