From ad7c93bcd6fc5023c67d45da21dbd79c88638c62 Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Sun, 11 Oct 2026 19:14:51 +0100 Subject: [PATCH 1/5] Run lint once for the whole repository Replace the per-module lint matrix with one job that runs Biome over the whole repository. --- .github/workflows/checks.yml | 12 +----------- package.json | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index cf2ba23b3..a0d5ad398 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -56,28 +56,18 @@ jobs: 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@v7 - 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 }}" + workspace: "testcontainers" - name: Code linting - env: - WORKSPACE_PATH: ${{ steps.npm-install-modules.outputs.workspace_path }} run: npm run lint:ci compile: diff --git a/package.json b/package.json index 83f57584f..37325a415 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "test:ci": "npm run test -- --coverage", "format": "biome format --write .", "lint": "biome check --write .", - "lint:ci": "biome ci --error-on-warnings package.json \"${WORKSPACE_PATH}\"", + "lint:ci": "biome ci --error-on-warnings .", "update-deps": "npm-check-updates --workspaces --root -u", "check-engines:root": "npm exec --yes --package=ls-engines@0.10.1 -- ls-engines --mode ideal --dev --no-current", "check-engines:testcontainers": "npm exec --yes --workspace=testcontainers --package=ls-engines@0.10.1 -- ls-engines --mode ideal --no-current", From a93d9241a9638f93081dd1b7fba530d2d070648d Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Sun, 11 Oct 2026 19:15:09 +0100 Subject: [PATCH 2/5] Compile once for the whole repository Replace the per-module compile matrix with one job that runs `npm run check-compiles`, a project-references build of every package. npm-setup installs every workspace when it isn't given one. --- .github/actions/npm-setup/action.yml | 19 ++++++++++++++----- .github/workflows/checks.yml | 12 +----------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/actions/npm-setup/action.yml b/.github/actions/npm-setup/action.yml index df34da377..df787100c 100644 --- a/.github/actions/npm-setup/action.yml +++ b/.github/actions/npm-setup/action.yml @@ -9,8 +9,9 @@ inputs: description: "Node.js version to use" required: true workspace: - description: "Workspace to install" - required: true + description: "Workspace to install. Leave empty to install every workspace" + required: false + default: "" outputs: workspace_path: @@ -24,7 +25,10 @@ runs: shell: bash id: set-workspace run: | - if [ "${{ inputs.workspace }}" = "testcontainers" ]; then + if [ -z "${{ inputs.workspace }}" ]; then + workspace_path="" + cache_paths=$'node_modules\npackages/testcontainers/node_modules\npackages/modules/*/node_modules' + elif [ "${{ inputs.workspace }}" = "testcontainers" ]; then workspace_path="packages/testcontainers" cache_paths=$'node_modules\npackages/testcontainers/node_modules' else @@ -51,12 +55,17 @@ runs: id: npm-cache with: path: ${{ steps.set-workspace.outputs.cache_paths }} - key: npm-v2-${{ inputs.runner }}-node-${{ inputs.node-version }}-${{ inputs.workspace }}-${{ hashFiles('package-lock.json') }} + key: npm-v2-${{ inputs.runner }}-node-${{ inputs.node-version }}-${{ inputs.workspace || 'all-workspaces' }}-${{ hashFiles('package-lock.json') }} - name: Install dependencies if: steps.npm-cache.outputs.cache-hit != 'true' shell: bash - run: npm ci --workspace "${WORKSPACE_PATH}" --include-workspace-root + run: | + if [ -n "${WORKSPACE_PATH}" ]; then + npm ci --workspace "${WORKSPACE_PATH}" --include-workspace-root + else + npm ci + fi - name: Save dependencies cache if: steps.npm-cache.outputs.cache-hit != 'true' diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a0d5ad398..f8c1b9811 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -76,27 +76,17 @@ jobs: 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@v7 - 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 + run: npm run check-compiles smoke-test: if: ${{ needs.detect-modules.outputs.has_testcontainers == 'true' }} From 534d2ede7adc5d3343166f09a7ca56597fc82832 Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Sun, 11 Oct 2026 19:15:10 +0100 Subject: [PATCH 3/5] Share one dependency cache across CI jobs Make npm-setup always install every workspace, so every job restores the same cache per Node version instead of one per package. The test jobs resolve the path of the package under test themselves. --- .github/actions/npm-setup/action.yml | 51 ++++++---------------------- .github/workflows/checks.yml | 3 -- .github/workflows/test-template.yml | 5 ++- 3 files changed, 12 insertions(+), 47 deletions(-) diff --git a/.github/actions/npm-setup/action.yml b/.github/actions/npm-setup/action.yml index df787100c..bdf12913d 100644 --- a/.github/actions/npm-setup/action.yml +++ b/.github/actions/npm-setup/action.yml @@ -8,42 +8,10 @@ inputs: node-version: description: "Node.js version to use" required: true - workspace: - description: "Workspace to install. Leave empty to install every workspace" - required: false - default: "" - -outputs: - workspace_path: - description: "Full path to the workspace directory" - value: ${{ steps.set-workspace.outputs.workspace_path }} runs: using: "composite" steps: - - name: Set workspace path - shell: bash - id: set-workspace - run: | - if [ -z "${{ inputs.workspace }}" ]; then - workspace_path="" - cache_paths=$'node_modules\npackages/testcontainers/node_modules\npackages/modules/*/node_modules' - elif [ "${{ inputs.workspace }}" = "testcontainers" ]; then - workspace_path="packages/testcontainers" - cache_paths=$'node_modules\npackages/testcontainers/node_modules' - else - workspace_path="packages/modules/${{ inputs.workspace }}" - cache_paths=$'node_modules\npackages/testcontainers/node_modules\n'"${workspace_path}/node_modules" - fi - - echo "WORKSPACE_PATH=${workspace_path}" >> "$GITHUB_ENV" - echo "workspace_path=${workspace_path}" >> "$GITHUB_OUTPUT" - { - echo "cache_paths<> "$GITHUB_OUTPUT" - - name: Install NodeJS ${{ inputs.node-version }} uses: actions/setup-node@v6 with: @@ -54,22 +22,23 @@ runs: uses: actions/cache/restore@v4 id: npm-cache with: - path: ${{ steps.set-workspace.outputs.cache_paths }} - key: npm-v2-${{ inputs.runner }}-node-${{ inputs.node-version }}-${{ inputs.workspace || 'all-workspaces' }}-${{ hashFiles('package-lock.json') }} + path: | + node_modules + packages/testcontainers/node_modules + packages/modules/*/node_modules + key: npm-v2-${{ inputs.runner }}-node-${{ inputs.node-version }}-all-workspaces-${{ hashFiles('package-lock.json') }} - name: Install dependencies if: steps.npm-cache.outputs.cache-hit != 'true' shell: bash - run: | - if [ -n "${WORKSPACE_PATH}" ]; then - npm ci --workspace "${WORKSPACE_PATH}" --include-workspace-root - else - npm ci - fi + run: npm ci - name: Save dependencies cache if: steps.npm-cache.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: - path: ${{ steps.set-workspace.outputs.cache_paths }} + path: | + node_modules + packages/testcontainers/node_modules + packages/modules/*/node_modules key: ${{ steps.npm-cache.outputs.cache-primary-key }} diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f8c1b9811..099caf2c3 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -66,7 +66,6 @@ jobs: with: runner: ubuntu-24.04 node-version: 24.x - workspace: "testcontainers" - name: Code linting run: npm run lint:ci @@ -108,7 +107,6 @@ jobs: 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 @@ -142,7 +140,6 @@ jobs: with: runner: ubuntu-24.04 node-version: 24.x - workspace: "testcontainers" - name: Build testcontainers run: npm run build --workspace packages/testcontainers - name: Remove dev dependencies diff --git a/.github/workflows/test-template.yml b/.github/workflows/test-template.yml index e7ec83745..5d7bd149e 100644 --- a/.github/workflows/test-template.yml +++ b/.github/workflows/test-template.yml @@ -27,14 +27,13 @@ jobs: uses: ./.github/actions/podman-setup - name: Install Node ${{ inputs.node-version }} and Dependencies - id: npm-install uses: ./.github/actions/npm-setup with: runner: ${{ inputs.runner }} node-version: ${{ inputs.node-version }} - workspace: "${{ inputs.workspace }}" - name: Run tests - run: npm run test:ci -- --coverage.include="${{ steps.npm-install.outputs.workspace_path }}/**/*.ts" ${{ steps.npm-install.outputs.workspace_path }} + run: npm run test:ci -- --coverage.include="${TEST_PATH}/**/*.ts" "${TEST_PATH}" env: CI: true + TEST_PATH: ${{ inputs.workspace == 'testcontainers' && 'packages/testcontainers' || format('packages/modules/{0}', inputs.workspace) }} From a2c7ffa2c302ad0d728bdbe5cb4a0b74da2121aa Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Sun, 11 Oct 2026 19:27:56 +0100 Subject: [PATCH 4/5] Simplify the dependency cache key There is only one kind of install now, so the key no longer needs a segment to tell them apart. --- .github/actions/npm-setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/npm-setup/action.yml b/.github/actions/npm-setup/action.yml index bdf12913d..911cc1342 100644 --- a/.github/actions/npm-setup/action.yml +++ b/.github/actions/npm-setup/action.yml @@ -26,7 +26,7 @@ runs: node_modules packages/testcontainers/node_modules packages/modules/*/node_modules - key: npm-v2-${{ inputs.runner }}-node-${{ inputs.node-version }}-all-workspaces-${{ hashFiles('package-lock.json') }} + key: npm-v3-${{ inputs.runner }}-node-${{ inputs.node-version }}-${{ hashFiles('package-lock.json') }} - name: Install dependencies if: steps.npm-cache.outputs.cache-hit != 'true' From d80ee1f9bc962494381935270ea904570ed2d176 Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Sun, 11 Oct 2026 19:29:33 +0100 Subject: [PATCH 5/5] Key the dependency cache on the runner's OS and architecture Use the built-in runner context instead of a `runner` input, so callers only pass the Node version. --- .github/actions/npm-setup/action.yml | 5 +---- .github/workflows/checks.yml | 4 ---- .github/workflows/test-template.yml | 1 - 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/actions/npm-setup/action.yml b/.github/actions/npm-setup/action.yml index 911cc1342..7efedf42f 100644 --- a/.github/actions/npm-setup/action.yml +++ b/.github/actions/npm-setup/action.yml @@ -2,9 +2,6 @@ name: "NPM Setup" description: "Sets up Node.js and installs NPM dependencies with caching" inputs: - runner: - description: "Runner to use" - required: true node-version: description: "Node.js version to use" required: true @@ -26,7 +23,7 @@ runs: node_modules packages/testcontainers/node_modules packages/modules/*/node_modules - key: npm-v3-${{ inputs.runner }}-node-${{ inputs.node-version }}-${{ hashFiles('package-lock.json') }} + key: npm-v3-${{ runner.os }}-${{ runner.arch }}-node-${{ inputs.node-version }}-${{ hashFiles('package-lock.json') }} - name: Install dependencies if: steps.npm-cache.outputs.cache-hit != 'true' diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 099caf2c3..746dfcddd 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -64,7 +64,6 @@ jobs: - name: Install Node and Dependencies uses: ./.github/actions/npm-setup with: - runner: ubuntu-24.04 node-version: 24.x - name: Code linting run: npm run lint:ci @@ -82,7 +81,6 @@ jobs: - name: Install Node and Dependencies uses: ./.github/actions/npm-setup with: - runner: ubuntu-24.04 node-version: 24.x - name: Compile run: npm run check-compiles @@ -105,7 +103,6 @@ jobs: - name: Install Node ${{ matrix.node-version }} and Dependencies uses: ./.github/actions/npm-setup with: - runner: ubuntu-24.04 node-version: ${{ matrix.node-version }} - name: Build testcontainers run: npm run build --workspace packages/testcontainers @@ -138,7 +135,6 @@ jobs: - name: Install Node and Dependencies uses: ./.github/actions/npm-setup with: - runner: ubuntu-24.04 node-version: 24.x - name: Build testcontainers run: npm run build --workspace packages/testcontainers diff --git a/.github/workflows/test-template.yml b/.github/workflows/test-template.yml index 5d7bd149e..95e647aa4 100644 --- a/.github/workflows/test-template.yml +++ b/.github/workflows/test-template.yml @@ -29,7 +29,6 @@ jobs: - name: Install Node ${{ inputs.node-version }} and Dependencies uses: ./.github/actions/npm-setup with: - runner: ${{ inputs.runner }} node-version: ${{ inputs.node-version }} - name: Run tests