diff --git a/.github/actions/npm-setup/action.yml b/.github/actions/npm-setup/action.yml index df34da377..7efedf42f 100644 --- a/.github/actions/npm-setup/action.yml +++ b/.github/actions/npm-setup/action.yml @@ -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<> "$GITHUB_OUTPUT" - - name: Install NodeJS ${{ inputs.node-version }} uses: actions/setup-node@v6 with: @@ -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 }} diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index cf2ba23b3..746dfcddd 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -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: @@ -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' }} @@ -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 @@ -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 diff --git a/.github/workflows/test-template.yml b/.github/workflows/test-template.yml index e7ec83745..95e647aa4 100644 --- a/.github/workflows/test-template.yml +++ b/.github/workflows/test-template.yml @@ -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) }} 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",