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
51 changes: 10 additions & 41 deletions .github/actions/npm-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<<EOF"
echo "${cache_paths}"
echo "EOF"
} >> "$GITHUB_OUTPUT"

- name: Install NodeJS ${{ inputs.node-version }}
uses: actions/setup-node@v6
with:
Expand All @@ -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 }}
3 changes: 0 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ jobs:
with:
runner: ubuntu-24.04
node-version: 24.x
workspace: "testcontainers"
- name: Code linting
run: npm run lint:ci

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
Loading