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) }}