Skip to content
Merged
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
45 changes: 10 additions & 35 deletions .github/actions/npm-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,13 @@ 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
workspace:
description: "Workspace to install"
required: true

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 [ "${{ 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<<EOF"
echo "${cache_paths}"
echo "EOF"
} >> "$GITHUB_OUTPUT"

- name: Install NodeJS ${{ inputs.node-version }}
uses: actions/setup-node@v6
with:
Expand All @@ -50,17 +19,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 }}-${{ hashFiles('package-lock.json') }}
path: |
node_modules
packages/testcontainers/node_modules
packages/modules/*/node_modules
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'
shell: bash
run: npm ci --workspace "${WORKSPACE_PATH}" --include-workspace-root
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 }}
29 changes: 1 addition & 28 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,16 @@ 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 }}"
- name: Code linting
env:
WORKSPACE_PATH: ${{ steps.npm-install-modules.outputs.workspace_path }}
run: npm run lint:ci

compile:
Expand All @@ -86,27 +74,16 @@ 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' }}
Expand All @@ -126,9 +103,7 @@ jobs:
- 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
Expand Down Expand Up @@ -160,9 +135,7 @@ jobs:
- name: Install Node and Dependencies
uses: ./.github/actions/npm-setup
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
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ 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) }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading