diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 310cf4c4..e8aaa780 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -45,6 +45,7 @@ updates: directories: - "/" - "/actions/**/*" + - "/tests/continuous-integration" - "/tests/npm" - "/tests/pnpm" - "/tests/pnpm-package-manager" diff --git a/.github/workflows/__test-workflow-continuous-integration.yml b/.github/workflows/__test-workflow-continuous-integration.yml index fc54ba29..de2ab7db 100644 --- a/.github/workflows/__test-workflow-continuous-integration.yml +++ b/.github/workflows/__test-workflow-continuous-integration.yml @@ -6,6 +6,82 @@ on: permissions: {} jobs: + act-without-build: + name: Act - Run contract tests without a build + uses: $/.github/workflows/continuous-integration.yml + permissions: + contents: read + id-token: write + packages: read + pull-requests: write + security-events: write + with: + working-directory: tests/continuous-integration + build: "" + lint: "" + code-ql: "" + dependency-review: false + test: '{"coverage":""}' + + act-with-checks-disabled: + name: Act - Disable all application checks without starting a container + uses: $/.github/workflows/continuous-integration.yml + permissions: + contents: read + id-token: write + packages: read + pull-requests: write + security-events: write + with: + checks: false + container: invalid.example.invalid/must-not-be-pulled:latest + working-directory: /unmounted/application + + assert-without-build: + name: Assert - Disabled builds produce no artifact + needs: [act-without-build, act-with-checks-disabled] + runs-on: ubuntu-latest + permissions: {} + steps: + - env: + BUILD_ARTIFACT: ${{ needs.act-without-build.outputs.build-artifact-id }} + DISABLED_ARTIFACT: ${{ needs.act-with-checks-disabled.outputs.build-artifact-id }} + run: | + test -z "$BUILD_ARTIFACT" + test -z "$DISABLED_ARTIFACT" + + act-package-without-build: + name: Act - Validate a source package without a build + uses: $/.github/workflows/continuous-integration.yml + permissions: + contents: read + id-token: write + packages: read + pull-requests: write + security-events: write + with: + working-directory: tests/source-package + build: "" + lint: "" + test: "" + code-ql: "" + dependency-review: false + package: | + {"tests":"test -f \"$PACKAGE_INSTALL_PATH/index.cjs\""} + + assert-package-without-build: + name: Assert - Packaging runs when compilation is omitted + needs: act-package-without-build + runs-on: ubuntu-latest + permissions: {} + steps: + - env: + PACKAGE_ARTIFACT: ${{ needs.act-package-without-build.outputs.package-tarball-artifact-id }} + BUILD_ARTIFACT: ${{ needs.act-package-without-build.outputs.build-artifact-id }} + run: | + test -n "$PACKAGE_ARTIFACT" + test -z "$BUILD_ARTIFACT" + package-configuration: name: Assert - Package configuration runs-on: ubuntu-latest @@ -272,6 +348,24 @@ jobs: test: | {"coverage": "codecov"} + act-with-container-without-build: + name: Act - Run container checks without a build + uses: $/.github/workflows/continuous-integration.yml + needs: arrange-with-container + permissions: + contents: read + id-token: write + packages: read + pull-requests: write + security-events: write + with: + container: ${{ fromJSON(needs.arrange-with-container.outputs.built-images).ci-npm.images[0] }} + working-directory: /usr/src/app/ + build: "" + code-ql: "" + dependency-review: false + test: '{"coverage":""}' + assert-with-container: name: Assert - Ensure build artifact has been uploaded (with container) runs-on: ubuntu-latest diff --git a/.github/workflows/continuous-integration.md b/.github/workflows/continuous-integration.md index ad59b52d..80b07e09 100644 --- a/.github/workflows/continuous-integration.md +++ b/.github/workflows/continuous-integration.md @@ -271,7 +271,8 @@ jobs: | | Explicit commands are unaffected. Does not apply in container mode, which skips installation. | | | | | **`runs-on`** | JSON array of runner(s) to use. | **false** | **string** | `["ubuntu-latest"]` | | | See . | | | | -| **`build`** | Build parameters. Must be a string or a JSON object. | **false** | **string** | `build` | +| **`build`** | Build parameters. Accepts newline-separated commands, a JSON array, or a JSON object. | **false** | **string** | `build` | +| | An empty or whitespace-only string skips the build job; tests and optional packaging can run without it. | | | | | | For string, provide a list of commands to run during the build step, one per line. | | | | | | For JSON object, provide the following properties: | | | | | | | | | | @@ -325,7 +326,9 @@ jobs: | | Example: | | | | | | | | | | | |
{
 "test:ci": "vitest run --reporter=default --reporter=junit --outputFile=junit.xml --coverage.enabled --coverage.reporter=lcov --coverage.reporter=text"
}
| | | | -| **`working-directory`** | Working directory where the dependencies are installed. | **false** | **string** | `.` | +| **`working-directory`** | Working directory where dependencies and application commands run. | **false** | **string** | `.` | +| | Relative paths resolve against the workspace of each application job. | | | | +| | Directory existence and non-container workspace boundaries are validated in those jobs. | | | | | **`container`** | Container configuration to run CI steps in. | **false** | **string** | - | | | Accepts either a string (container image name) or a JSON object with container options. | | | | | | | | | | diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 9ce63ffe..5a711d5d 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -26,7 +26,8 @@ on: required: false build: description: | - Build parameters. Must be a string or a JSON object. + Build parameters. Accepts newline-separated commands, a JSON array, or a JSON object. + An empty or whitespace-only string skips the build job; tests and optional packaging can run without it. For string, provide a list of commands to run during the build step, one per line. For JSON object, provide the following properties: @@ -139,7 +140,10 @@ on: required: false default: "true" working-directory: - description: "Working directory where the dependencies are installed." + description: | + Working directory where dependencies and application commands run. + Relative paths resolve against the workspace of each application job. + Directory existence and non-container workspace boundaries are validated in those jobs. type: string required: false default: "." @@ -242,6 +246,10 @@ jobs: package-directories: ${{ steps.package-config.outputs.directories }} package-tests: ${{ steps.package-config.outputs.tests }} package-test-project: ${{ steps.package-config.outputs.test-project }} + working-directory: ${{ steps.build-variables.outputs.working-directory }} + build-env: ${{ steps.build-variables.outputs.env }} + build-commands: ${{ steps.build-variables.outputs.commands }} + build-artifact: ${{ steps.build-variables.outputs.artifact }} steps: - id: package-config uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 @@ -376,111 +384,23 @@ jobs: return acc; }, "")); - code-ql: - name: ๐Ÿ›ก๏ธ CodeQL Analysis - if: inputs.checks == true && inputs.code-ql != '' - permissions: - security-events: write - runs-on: *ci-runner - steps: - - uses: hoverkraft-tech/ci-github-common/actions/checkout@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0 - - id: code-ql-options - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - env: - CODE_QL: ${{ inputs.code-ql }} - with: - script: | - const input = process.env.CODE_QL.trim(); - let options = { languages: input }; - - if (input.startsWith('{')) { - try { - options = JSON.parse(input); - } catch { - return core.setFailed('code-ql must be a language string or a valid JSON object.'); - } - } - - if (Object.keys(options).some(key => !['languages', 'config-file'].includes(key))) { - return core.setFailed('code-ql supports only languages and config-file.'); - } - if (typeof options.languages !== 'string' || !options.languages.trim()) { - return core.setFailed('code-ql.languages must be a nonempty string.'); - } - if (options['config-file'] !== undefined && typeof options['config-file'] !== 'string') { - return core.setFailed('code-ql.config-file must be a string.'); - } - - core.setOutput('languages', options.languages); - core.setOutput('config-file', options['config-file'] ?? ''); - - uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 - with: - languages: ${{ steps.code-ql-options.outputs.languages }} - config-file: ${{ steps.code-ql-options.outputs.config-file }} - - uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 - - dependency-review: - name: ๐Ÿ›ก๏ธ Dependency Review - if: github.event_name == 'pull_request' && inputs.checks == true && inputs.dependency-review - permissions: - contents: read - runs-on: *ci-runner - steps: - - uses: hoverkraft-tech/ci-github-common/actions/checkout@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0 - - uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0 - - setup: - name: โš™๏ธ Setup - runs-on: *ci-runner - needs: - - prepare - permissions: - contents: read - packages: read - container: &ci-container - image: ${{ needs.prepare.outputs.container-image || '' }} - env: ${{ fromJSON(needs.prepare.outputs.container-env || '{}') }} - options: ${{ needs.prepare.outputs.container-options || ' ' }} - ports: ${{ fromJSON(needs.prepare.outputs.container-ports || '[]') }} - volumes: ${{ fromJSON(needs.prepare.outputs.container-volumes || '[]') }} - credentials: ${{ fromJSON(needs.prepare.outputs.container-username && format('{{"username":{0},"password":{1}}}',toJSON(needs.prepare.outputs.container-username),toJSON(secrets.container-password)) || '{}') }} - outputs: - working-directory: ${{ steps.working-directory.outputs.absolute-path }} - build-env: ${{ steps.build-variables.outputs.env }} - build-commands: ${{ steps.build-variables.outputs.commands }} - build-artifact: ${{ steps.build-variables.outputs.artifact }} - package-directories: ${{ steps.packages.outputs.directories }} - steps: - - name: Checkout repository - if: inputs.container == '' - uses: hoverkraft-tech/ci-github-common/actions/checkout@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0 - - - id: working-directory - uses: hoverkraft-tech/ci-github-common/actions/working-directory@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0 - with: - working-directory: ${{ inputs.working-directory }} - enforce-path-in-workspace: ${{ inputs.container && 'false' || 'true' }} - - - name: Discover public packages - id: packages - if: inputs.checks == true && needs.prepare.outputs.package-enabled == 'true' - uses: $/actions/package/discover - with: - working-directory: ${{ steps.working-directory.outputs.absolute-path }} - directories: ${{ needs.prepare.outputs.package-directories }} - - id: build-variables - if: inputs.build != '' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: - WORKING_DIRECTORY: ${{ steps.working-directory.outputs.absolute-path }} + WORKING_DIRECTORY: ${{ inputs.working-directory }} BUILD_INPUT: ${{ inputs.build }} with: script: | const path = require('node:path'); - const workingDirectory = process.env.WORKING_DIRECTORY; + const workingDirectory = path.normalize(process.env.WORKING_DIRECTORY || '.'); + core.setOutput('working-directory', workingDirectory); const buildInput = process.env.BUILD_INPUT.trim(); + if (!buildInput) { + core.setOutput('commands', ''); + core.setOutput('env', '{}'); + return; + } let commands = []; let env = {}; @@ -508,7 +428,7 @@ jobs: env = build.env ?? {}; if (build.artifact) { - buildArtifact = build.artifact; + let buildArtifact = build.artifact; if (typeof buildArtifact === 'string' || Array.isArray(buildArtifact)) { buildArtifact = { @@ -516,22 +436,21 @@ jobs: }; } + if (!buildArtifact || typeof buildArtifact !== 'object') { + return core.setFailed('Build artifact must be a path, path array or options object'); + } + if (typeof buildArtifact.paths === 'string') { buildArtifact.paths = buildArtifact.paths.split('\n'); - } else if (!Array.isArray(buildArtifact.paths)) { + } + if (!Array.isArray(buildArtifact.paths) || buildArtifact.paths.some(artifact => typeof artifact !== 'string')) { return core.setFailed('Build artifact paths must be a string or an array of strings'); } buildArtifact.paths = buildArtifact.paths .map(artifact => artifact.trim()) .filter(Boolean) - .map(artifact => { - // FIXME: Workaround to preserve full path to artifact - const fullpath = artifact.startsWith('/') ? artifact : path.join(workingDirectory, artifact); - - // Add a wildcard to the first folder of the path - return fullpath.replace(/\/([^/]+)/, '/*$1'); - }).join('\n'); + .join('\n'); if (!buildArtifact.paths) { return core.setFailed('No valid build artifact paths found'); @@ -545,27 +464,89 @@ jobs: } } - if (commands.some(command => typeof command !== 'string')) { + if (!Array.isArray(commands) || commands.some(command => typeof command !== 'string')) { core.setFailed('Build commands array must only contain strings'); return; } + if (!env || typeof env !== 'object' || Array.isArray(env)) { + return core.setFailed('Build env must be an object'); + } + const sanitizedCommands = commands.map(command => command.trim()).filter(Boolean); if (!sanitizedCommands.length) { - core.setFailed('No build commands found'); + return core.setFailed('No build commands found'); } core.setOutput('commands', sanitizedCommands.join('\n')); core.setOutput('env', JSON.stringify(env)); + code-ql: + name: ๐Ÿ›ก๏ธ CodeQL Analysis + if: inputs.checks == true && inputs.code-ql != '' + permissions: + security-events: write + runs-on: *ci-runner + steps: + - uses: hoverkraft-tech/ci-github-common/actions/checkout@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0 + - id: code-ql-options + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + CODE_QL: ${{ inputs.code-ql }} + with: + script: | + const input = process.env.CODE_QL.trim(); + let options = { languages: input }; + + if (input.startsWith('{')) { + try { + options = JSON.parse(input); + } catch { + return core.setFailed('code-ql must be a language string or a valid JSON object.'); + } + } + + if (Object.keys(options).some(key => !['languages', 'config-file'].includes(key))) { + return core.setFailed('code-ql supports only languages and config-file.'); + } + if (typeof options.languages !== 'string' || !options.languages.trim()) { + return core.setFailed('code-ql.languages must be a nonempty string.'); + } + if (options['config-file'] !== undefined && typeof options['config-file'] !== 'string') { + return core.setFailed('code-ql.config-file must be a string.'); + } + + core.setOutput('languages', options.languages); + core.setOutput('config-file', options['config-file'] ?? ''); + - uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 + with: + languages: ${{ steps.code-ql-options.outputs.languages }} + config-file: ${{ steps.code-ql-options.outputs.config-file }} + - uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 + + dependency-review: + name: ๐Ÿ›ก๏ธ Dependency Review + if: github.event_name == 'pull_request' && inputs.checks == true && inputs.dependency-review + permissions: + contents: read + runs-on: *ci-runner + steps: + - uses: hoverkraft-tech/ci-github-common/actions/checkout@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0 + - uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0 + lint: if: inputs.checks == true && inputs.lint name: ๐Ÿ‘• Lint runs-on: *ci-runner - container: *ci-container + container: &ci-container + image: ${{ needs.prepare.outputs.container-image || '' }} + env: ${{ fromJSON(needs.prepare.outputs.container-env || '{}') }} + options: ${{ needs.prepare.outputs.container-options || ' ' }} + ports: ${{ fromJSON(needs.prepare.outputs.container-ports || '[]') }} + volumes: ${{ fromJSON(needs.prepare.outputs.container-volumes || '[]') }} + credentials: ${{ fromJSON(needs.prepare.outputs.container-username && format('{{"username":{0},"password":{1}}}',toJSON(needs.prepare.outputs.container-username),toJSON(secrets.container-password)) || '{}') }} needs: - prepare - - setup permissions: contents: read packages: read @@ -599,20 +580,19 @@ jobs: uses: $/actions/lint with: ignore-scripts: ${{ inputs.ignore-scripts }} - working-directory: ${{ needs.setup.outputs.working-directory }} + working-directory: ${{ needs.prepare.outputs.working-directory }} container: ${{ inputs.container != '' && 'true' || 'false' }} command: ${{ steps.preparel-lint-options.outputs.command }} report-file: ${{ steps.preparel-lint-options.outputs.report-file }} path-mapping: ${{ needs.prepare.outputs.path-mapping || '' }} build: - if: inputs.checks == true + if: inputs.checks == true && needs.prepare.outputs.build-commands != '' name: ๐Ÿ—๏ธ Build runs-on: *ci-runner container: *ci-container needs: - prepare - - setup permissions: contents: read packages: read @@ -620,28 +600,48 @@ jobs: artifact-id: ${{ steps.build.outputs.artifact-id }} steps: - uses: hoverkraft-tech/ci-github-common/actions/checkout@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0 - if: needs.setup.outputs.build-commands && inputs.container == '' + if: inputs.container == '' + + - id: build-artifact + if: needs.prepare.outputs.build-artifact + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + WORKING_DIRECTORY: ${{ needs.prepare.outputs.working-directory }} + BUILD_ARTIFACT: ${{ needs.prepare.outputs.build-artifact }} + with: + script: | + const path = require('node:path'); + const workingDirectory = path.resolve(process.env.GITHUB_WORKSPACE, process.env.WORKING_DIRECTORY); + const artifact = JSON.parse(process.env.BUILD_ARTIFACT); + artifact.paths = artifact.paths.split('\n').map(artifactPath => { + const fullPath = path.resolve(workingDirectory, artifactPath); + // Preserve the full directory layout used by artifact consumers. + return fullPath.replace(/\/([^/]+)/, '/*$1'); + }).join('\n'); + core.setOutput('artifact', JSON.stringify(artifact)); - id: build - if: needs.setup.outputs.build-commands uses: $/actions/build with: ignore-scripts: ${{ inputs.ignore-scripts }} container: ${{ inputs.container != '' && 'true' || 'false' }} - working-directory: ${{ needs.setup.outputs.working-directory }} + working-directory: ${{ needs.prepare.outputs.working-directory }} build-secrets: ${{ secrets.build-secrets }} - build-commands: ${{ needs.setup.outputs.build-commands }} - build-env: ${{ needs.setup.outputs.build-env }} - build-artifact: ${{ needs.setup.outputs.build-artifact }} + build-commands: ${{ needs.prepare.outputs.build-commands }} + build-env: ${{ needs.prepare.outputs.build-env }} + build-artifact: ${{ steps.build-artifact.outputs.artifact }} test: - if: inputs.checks == true && inputs.test + if: >- + ${{ !cancelled() && inputs.checks == true && inputs.test && + needs.prepare.result == 'success' && + (needs.build.result == 'success' || + (needs.build.result == 'skipped' && needs.prepare.outputs.build-commands == '')) }} name: ๐Ÿงช Test runs-on: *ci-runner container: *ci-container needs: - prepare - - setup - build permissions: contents: read @@ -688,7 +688,7 @@ jobs: uses: $/actions/test with: ignore-scripts: ${{ inputs.ignore-scripts }} - working-directory: ${{ needs.setup.outputs.working-directory }} + working-directory: ${{ needs.prepare.outputs.working-directory }} container: ${{ inputs.container != '' && 'true' || 'false' }} command: ${{ steps.prepare-test-options.outputs.command }} coverage: ${{ steps.prepare-test-options.outputs.coverage }} @@ -696,17 +696,44 @@ jobs: path-mapping: ${{ needs.prepare.outputs.path-mapping || '' }} github-token: ${{ secrets.github-token || github.token }} + discover-packages: + name: Discover public packages + if: inputs.checks == true && needs.prepare.outputs.package-enabled == 'true' + needs: prepare + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + directories: ${{ steps.packages.outputs.directories }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - id: working-directory + uses: hoverkraft-tech/ci-github-common/actions/working-directory@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0 + with: + working-directory: ${{ needs.prepare.outputs.working-directory }} + - id: packages + uses: $/actions/package/discover + with: + working-directory: ${{ steps.working-directory.outputs.absolute-path }} + directories: ${{ needs.prepare.outputs.package-directories }} + package: name: Validate package ${{ matrix.directory }} - if: inputs.checks == true && needs.prepare.outputs.package-enabled == 'true' - needs: [prepare, setup, build] + if: >- + ${{ !cancelled() && inputs.checks == true && needs.prepare.outputs.package-enabled == 'true' && + needs.prepare.result == 'success' && needs.discover-packages.result == 'success' && + (needs.build.result == 'success' || + (needs.build.result == 'skipped' && needs.prepare.outputs.build-commands == '')) }} + needs: [prepare, discover-packages, build] runs-on: ubuntu-latest permissions: contents: read strategy: fail-fast: false matrix: - directory: ${{ fromJSON(needs.setup.outputs.package-directories) }} + directory: ${{ fromJSON(needs.discover-packages.outputs.directories) }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -764,8 +791,11 @@ jobs: package-results: name: Collect validated packages - if: inputs.checks == true && needs.prepare.outputs.package-enabled == 'true' - needs: [prepare, setup, package] + if: >- + ${{ !cancelled() && inputs.checks == true && needs.prepare.outputs.package-enabled == 'true' && + needs.prepare.result == 'success' && needs.discover-packages.result == 'success' && + needs.package.result == 'success' }} + needs: [prepare, discover-packages, package] runs-on: ubuntu-latest permissions: contents: read @@ -781,7 +811,7 @@ jobs: - id: collect uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: - DIRECTORIES: ${{ needs.setup.outputs.package-directories }} + DIRECTORIES: ${{ needs.discover-packages.outputs.directories }} PROJECT: ${{ inputs.working-directory }} REPORT_DIRECTORY: ${{ runner.temp }}/package-validation with: diff --git a/actions/build/action.yml b/actions/build/action.yml index 08ee1489..b3698f67 100644 --- a/actions/build/action.yml +++ b/actions/build/action.yml @@ -77,7 +77,7 @@ runs: uses: hoverkraft-tech/ci-github-common/actions/working-directory@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0 with: working-directory: ${{ inputs.working-directory }} - enforce-path-in-workspace: ${{ inputs.container && 'false' || 'true' }} + enforce-path-in-workspace: ${{ inputs.container == 'true' && 'false' || 'true' }} - id: setup-node if: inputs.container != 'true' diff --git a/actions/lint/action.yml b/actions/lint/action.yml index 589763cb..4af8b820 100644 --- a/actions/lint/action.yml +++ b/actions/lint/action.yml @@ -56,7 +56,7 @@ runs: uses: hoverkraft-tech/ci-github-common/actions/working-directory@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0 with: working-directory: ${{ inputs.working-directory }} - enforce-path-in-workspace: ${{ inputs.container && 'false' || 'true' }} + enforce-path-in-workspace: ${{ inputs.container == 'true' && 'false' || 'true' }} - id: setup-node if: inputs.container != 'true' diff --git a/actions/test/action.yml b/actions/test/action.yml index 814f6c27..b3220919 100644 --- a/actions/test/action.yml +++ b/actions/test/action.yml @@ -95,7 +95,7 @@ runs: uses: hoverkraft-tech/ci-github-common/actions/working-directory@5fbb531db839a26ebcc35c4946be279f945f7633 # 1.0.0 with: working-directory: ${{ inputs.working-directory }} - enforce-path-in-workspace: ${{ inputs.container && 'false' || 'true' }} + enforce-path-in-workspace: ${{ inputs.container == 'true' && 'false' || 'true' }} # jscpd:ignore-end - id: setup-node diff --git a/docs/README.md b/docs/README.md index 87b9fd77..323dbdb1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,3 +2,4 @@ - [Maintain dependency updates](development/dependency-updates.md) - [Release orchestration decision](adr/0001-release-orchestration.md) +- [Lightweight CI preparation decision](adr/0002-lightweight-ci-preparation.md) diff --git a/docs/adr/0002-lightweight-ci-preparation.md b/docs/adr/0002-lightweight-ci-preparation.md new file mode 100644 index 00000000..adf3bd79 --- /dev/null +++ b/docs/adr/0002-lightweight-ci-preparation.md @@ -0,0 +1,165 @@ +# ADR 0002: Prepare CI metadata without application containers + +- Status: proposed +- Date: 2026-11-06 +- Consumer: [Pleey CI optimization, P2.1](https://github.com/cloud-native-aixmarseille/pleey/issues/475) + +## Context + +For application callers, CI starts a container only to resolve paths and build +options. An empty build then starts another container before tests can run. These +jobs perform no application validation and delay callers with prebuilt images. + +## Decision + +Normalize the working-directory and build inputs in the existing preparation job, +which needs neither a checkout nor the application image. Keep relative paths +relative: host and container workspaces can differ. Validate existence, access and +the non-container workspace boundary inside the build, lint and test actions. +Resolve artifact paths in the build job's filesystem context, preserving the +uploaded directory layout and existing download behavior. + +An empty build string, including whitespace, omits the build job. Other supported +forms retain their defaults and validation: newline-separated scripts, JSON +arrays, and objects with commands, environment and artifact options. Invalid +command or artifact shapes fail preparation before starting application jobs. + +Tests and optional packaging require successful preparation and either a +successful requested build or a build skipped because its command list is empty. +Use an explicit cancellation-aware condition so an intentional skip does not +propagate to these jobs. A failed, cancelled or unexpectedly skipped requested +build must block them. Lint remains independent of build and test results. + +Public-package discovery needs the checked-out source. Run it in a separate host +job only when packaging is enabled, in parallel with compilation. Package matrix +validation requires successful discovery and the build condition above. Collect +results only after successful package validation. Preserve workspace selection, +consumer tests and artifact outputs without adding discovery to application CI. + +Do not change application commands, report handling, build-secret delivery or +CodeQL/dependency-review policy. Preserve package validation when no compilation +is needed. No additional runtime dependency or public workflow input is needed. + +## Validation and rollout + +Exercise the actual preparation scripts and scheduling expressions, including +malformed inputs, defaults, skipped and failed dependencies, cancellation and +disabled checks. Run host/container integration cases for omitted and requested +builds, workspace validation and artifact transfer. Measure preparation-to-first- +check latency and summed job time with fixed inputs; report timing variation. + +Consumers adopt a reviewed release by SHA. Removing the setup job and skipping +empty build jobs changes emitted check names/statuses: callers requiring those +individual jobs must update their required checks when adopting the release. +Rollback restores the previous workflow pin and corresponding required checks. + +## Initial implementation evidence: 2026-11-06 + +The [implementation CI](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42282825359) +passed on `5bccd49fb33a6c04d5332cb32754b28261b12103`. The 56 contract tests +exercise the actual YAML scripts and GitHub expression evaluator. Integration +cases cover host/container builds, omitted builds, artifact transfer, disabled +checks and package validation without compilation. Eight additional trials +confirmed preparation/build/lint/test failure, missing-directory and workspace +boundary rejection, disabled checks and cancellation. Expected failures are +successful negative tests, not successful workflow conclusions. + +The initial baseline was `aaab44d37f5f675dc6789ea377ffc5b63cc3fe0f` and the +candidate was `5bccd49fb33a6c04d5332cb32754b28261b12103`. After +[priming](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42283024208), +the five measured pairs were +[1](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42284009431), +[2](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42284313836), +[3](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42284695321), +[4](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42285014018) and +[5](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42285335029). + +The benchmark uses the existing preinstalled npm fixture with one test, an empty +build and this immutable image in both series: + +```text +ghcr.io/hoverkraft-tech/ci-github-nodejs/ci-npm@sha256:324a3de0633bb5f7f0d41394ccf902195665fdaf2c23798f6145922161511574 +``` + +Baseline and candidate run together in each dispatch. One priming pair precedes +five consecutive measured pairs; all measured pairs are retained. Measurement +starts after the full implementation CI finishes. + +All five measured pairs passed. All 48 sampled job logs (including priming) used +runner `2.338.2`, Ubuntu image `ubuntu-26.04` version `20261101.186.1`; container +jobs resolved the recorded digest. Both variants passed one suite and one test. + +| Metric | Baseline median (range) | Candidate median (range) | Median change | +| -------------------------------------- | ----------------------- | ------------------------ | ------------- | +| Elapsed from preparation | 101s (99โ€“141s) | 59s (49โ€“118s) | โˆ’41.58% | +| Preparation to first validation action | 64s (53โ€“70s) | 31s (30โ€“47s) | โˆ’51.56% | +| Summed job time | 143s (133โ€“148s) | 87s (74โ€“89s) | โˆ’39.16% | +| Initial queue | 4s (3โ€“7s) | 3s (3โ€“11s) | โˆ’25.00% | + +Elapsed time starts at each variant's preparation job and includes downstream +queues, container pulls and cleanup. Initial queue time is recorded separately. +Validation-action latency ends at the first `Run lint` or `Run tests` composite +step; it does not measure the exact application command start. Summed job time +is not billed time. The candidate runs three jobs instead of five, omitting setup +and empty build; both versions still execute lint and the same test. + +These measurements isolate reusable-workflow overhead. They do not establish a +Pleey end-to-end improvement or a cold-cache guarantee. A reviewed release and +consumer CI remain required before adopting its immutable SHA in Pleey. + +## Upstream integration: 2026-11-06 + +Main advanced to `55afe8ef3c9b59932f87a99cb2620226f18b2062` during review +preparation, adding workspace packaging and updating shared action pins. Retain +that package API and move its source-dependent discovery out of the removed +setup job. The adapted suite has 60 contract tests, including discovery failure +and validation-result collection when compilation is omitted. The existing +source-package integration case also checks the resulting artifact output. + +The initial measurements above retain their exact revisions and are historical +evidence for the pre-integration implementation. Validation against updated main +is recorded separately; do not treat that series as measurements of a later SHA. + +The [integrated CI](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42288071590) +passed at `2f87ce61c0641934d24c39162732660b90451004`, including requested-build +artifact transfer and source packaging without compilation. Its workflow/action +sources equal the measured candidate `540c5f4ea785d853affae704ee5c4c270d96abcd`. +Eight probes matched their expected outcomes: +[preparation failure](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42287006075), +[disabled checks](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42287010624), +[build failure](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42287014811), +[test failure](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42287019554), +[lint failure](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42287024618), +[missing directory](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42287029142), +[workspace boundary](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42287033354) and +[cancellation](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42287037745). + +The preceding [integration run](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42286746512) +exposed duplicate reports when two cases packaged the same project. The no-build +case uses `tests/source-package`, whose build command deliberately fails if invoked, +to isolate it without changing the collector's project-based grouping. + +The same method compared baseline `55afe8ef3c9b59932f87a99cb2620226f18b2062` +with candidate `540c5f4ea785d853affae704ee5c4c270d96abcd`. After +[priming](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42286929531), +all five measured pairs passed: +[1](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42289175642), +[2](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42289482879), +[3](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42289790837), +[4](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42290030964) and +[5](https://github.com/hoverkraft-tech/ci-github-nodejs/actions/runs/42290263969). +The runs retain job timestamps and outcomes. All 48 sampled job logs again used +runner `2.338.2` and Ubuntu image `20261101.186.1`; both variants used the image +above and passed the same one-suite, one-test inventory. + +| Metric | Baseline median (range) | Candidate median (range) | Median change | +| -------------------------------------- | ----------------------- | ------------------------ | ------------- | +| Elapsed from preparation | 101s (89โ€“107s) | 52s (50โ€“58s) | โˆ’48.51% | +| Preparation to first validation action | 61s (58โ€“68s) | 31s (29โ€“36s) | โˆ’49.18% | +| Summed job time | 135s (121โ€“149s) | 90s (77โ€“91s) | โˆ’33.33% | +| Initial queue | 4s (4โ€“4s) | 4s (3โ€“4s) | 0.00% | + +This confirms the reduction for the controlled application fixture against the +workspace-aware upstream implementation. Package-discovery jobs remain skipped +for this caller. The same scope limits apply: Pleey adoption and end-to-end +measurement require a reviewed release. diff --git a/tests/continuous-integration/package-lock.json b/tests/continuous-integration/package-lock.json new file mode 100644 index 00000000..d301737a --- /dev/null +++ b/tests/continuous-integration/package-lock.json @@ -0,0 +1,40 @@ +{ + "name": "continuous-integration-contract-tests", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "continuous-integration-contract-tests", + "devDependencies": { + "@actions/expressions": "0.3.61", + "yaml": "2.9.1" + } + }, + "node_modules/@actions/expressions": { + "version": "0.3.61", + "resolved": "https://registry.npmjs.org/@actions/expressions/-/expressions-0.3.61.tgz", + "integrity": "sha512-Ig+tXELvTjlqxQAWBQnLNn2dPpNraLMdSnT+vDzDPmJtbNUhIAH/Z9kVT8pZ8UtJi9vUGs8hwHE8JFJmbOnLEA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 20" + } + }, + "node_modules/yaml": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz", + "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } + } + } +} diff --git a/tests/continuous-integration/package.json b/tests/continuous-integration/package.json new file mode 100644 index 00000000..26d651e5 --- /dev/null +++ b/tests/continuous-integration/package.json @@ -0,0 +1,13 @@ +{ + "name": "continuous-integration-contract-tests", + "private": true, + "type": "module", + "scripts": { + "test": "node --test", + "test:ci": "node --test" + }, + "devDependencies": { + "@actions/expressions": "0.3.61", + "yaml": "2.9.1" + } +} diff --git a/tests/continuous-integration/workflow.test.js b/tests/continuous-integration/workflow.test.js new file mode 100644 index 00000000..2f017d09 --- /dev/null +++ b/tests/continuous-integration/workflow.test.js @@ -0,0 +1,385 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { createRequire } from "node:module"; +import test from "node:test"; +import { runInNewContext } from "node:vm"; +import { data, Evaluator, Lexer, Parser } from "@actions/expressions"; +import { parse } from "yaml"; + +const repository = new URL("../../", import.meta.url); +const readYaml = (file) => + parse(readFileSync(new URL(file, repository), "utf8")); +const workflow = readYaml(".github/workflows/continuous-integration.yml"); +const defaults = Object.fromEntries( + Object.entries(workflow.on.workflow_call.inputs).map(([name, input]) => [ + name, + input.default, + ]), +); +const require = createRequire(import.meta.url); + +async function runScript(job, stepId, env = {}) { + const step = workflow.jobs[job].steps.find((item) => item.id === stepId); + const outputs = {}; + const errors = []; + await runInNewContext(`(async () => { ${step.with.script} })()`, { + process: { + env: { + GITHUB_WORKSPACE: "/host/work/repository", + GITHUB_JOB: job, + GITHUB_RUN_ID: "123", + WORKING_DIRECTORY: ".", + BUILD_INPUT: defaults.build, + CONTAINER_INPUT: "", + CONTAINER_PASSWORD: "", + PACKAGE_INPUT: defaults.package, + ...env, + }, + }, + require: (name) => { + assert.equal(name, "node:path", "metadata must not inspect a filesystem"); + return require(name); + }, + core: { + debug: () => {}, + setOutput: (name, value) => { + outputs[name] = value; + }, + setFailed: (message) => errors.push(message), + }, + }); + return { outputs, errors }; +} + +function evaluate(expression, context, statuses = {}) { + const functions = new Map( + Object.entries(statuses).map(([name, value]) => [ + name, + { name, minArgs: 0, maxArgs: 0, call: () => new data.BooleanData(value) }, + ]), + ); + const source = expression.replace(/^\s*\$\{\{|\}\}\s*$/g, ""); + const { tokens } = new Lexer(source).lex(); + const parsed = new Parser(tokens, Object.keys(context), [ + ...functions.values(), + ]).parse(); + return new Evaluator( + parsed, + JSON.parse(JSON.stringify(context), data.reviver), + functions, + ).evaluate(); +} + +function canRun( + jobId, + { + inputs = {}, + prepare = "success", + build = "success", + commands = "build", + cancelled = false, + packageEnabled = true, + discovery = "success", + packageResult = "success", + } = {}, +) { + const job = workflow.jobs[jobId]; + const available = { + prepare: { + result: prepare, + outputs: { + "build-commands": commands, + "package-enabled": String(packageEnabled), + }, + }, + build: { result: build, outputs: {} }, + "discover-packages": { + result: discovery, + outputs: { directories: '["."]' }, + }, + package: { result: packageResult, outputs: {} }, + }; + const dependencies = [job.needs ?? []].flat(); + const needs = Object.fromEntries( + dependencies.map((id) => [id, available[id]]), + ); + const success = + !cancelled && dependencies.every((id) => needs[id].result === "success"); + // GitHub adds success() unless the condition contains a status function. + const expression = /\b(?:always|success|failure|cancelled)\s*\(/.test(job.if) + ? job.if + : `success() && (${job.if})`; + const condition = expression.replace(/^\s*\$\{\{|\}\}\s*$/g, ""); + return evaluate( + `!!(${condition})`, + { inputs: { ...defaults, ...inputs }, needs }, + { + success, + cancelled, + }, + ).value; +} + +for (const [input, commands] of [ + [defaults.build, "build"], + [" build \n generate \n", "build\ngenerate"], + ['["build", " generate "]', "build\ngenerate"], + ['{"artifact":"dist"}', "build"], + ["", ""], + [" \n ", ""], +]) { + test(`normalizes supported build input ${JSON.stringify(input)}`, async () => { + const result = await runScript("prepare", "build-variables", { + BUILD_INPUT: input, + }); + assert.deepEqual(result.errors, []); + assert.equal(result.outputs.commands, commands); + assert.equal(result.outputs.env, "{}"); + }); +} + +for (const input of [ + "{bad json", + '["build", 1]', + '{"commands":"build"}', + '{"commands":[]}', + '{"env":[]}', + '{"artifact":true}', + '{"artifact":{"paths":123}}', + '{"artifact":["dist",false]}', + '{"artifact":" \n "}', +]) { + test(`rejects malformed build input ${JSON.stringify(input)}`, async () => { + const result = await runScript("prepare", "build-variables", { + BUILD_INPUT: input, + }); + assert.equal(result.errors.length, 1); + assert.equal(result.outputs.commands, undefined); + }); +} + +test("preserves environment values and artifact options", async () => { + const result = await runScript("prepare", "build-variables", { + BUILD_INPUT: JSON.stringify({ + commands: ["compile"], + env: { NODE_ENV: "test", LABEL: "a=b" }, + artifact: { paths: [" dist/ ", "build/result.json"], custom: "retained" }, + }), + }); + assert.deepEqual(result.errors, []); + assert.deepEqual(JSON.parse(result.outputs.env), { + NODE_ENV: "test", + LABEL: "a=b", + }); + const artifact = JSON.parse(result.outputs.artifact); + assert.equal(artifact.paths, "dist/\nbuild/result.json"); + assert.equal(artifact.custom, "retained"); + assert.match(artifact.name, /^prepare-build-123-\w+$/); +}); + +for (const directory of [ + "apps/frontend", + "/usr/src/app", + "/missing/unmounted/app", + " directory with spaces ", +]) { + test(`prepares ${directory} without inspecting the host filesystem`, async () => { + const result = await runScript("prepare", "build-variables", { + WORKING_DIRECTORY: directory, + }); + assert.deepEqual(result.errors, []); + assert.equal(result.outputs["working-directory"], directory); + }); +} + +for (const [workspace, directory, expected] of [ + [ + "/home/runner/work/repository", + "apps/web", + "/*home/runner/work/repository/apps/web/dist", + ], + [ + "/__w/repository/repository", + "apps/web", + "/*__w/repository/repository/apps/web/dist", + ], + ["/__w/repository/repository", "/usr/src/app", "/*usr/src/app/dist"], +]) { + test(`resolves artifacts in the application job at ${workspace}, ${directory}`, async () => { + const result = await runScript("build", "build-artifact", { + GITHUB_WORKSPACE: workspace, + WORKING_DIRECTORY: directory, + BUILD_ARTIFACT: JSON.stringify({ + name: "artifact", + paths: "dist\n/absolute/file", + }), + }); + assert.deepEqual(JSON.parse(result.outputs.artifact), { + name: "artifact", + paths: `${expected}\n/*absolute/file`, + }); + }); +} + +test("preserves container options, credentials and report path mappings", async () => { + const result = await runScript("prepare", "parse", { + CONTAINER_INPUT: JSON.stringify({ + image: "registry.example/app@sha256:abc", + options: "--cpus 2", + env: { CI: "true" }, + credentials: { username: "user" }, + pathMapping: { "/usr/src/app": "application/frontend" }, + }), + CONTAINER_PASSWORD: "test-password", + }); + assert.deepEqual(result.errors, []); + assert.equal( + result.outputs["container-image"], + "registry.example/app@sha256:abc", + ); + assert.equal( + result.outputs["container-options"], + "--user root:root --cpus 2", + ); + assert.equal(result.outputs["container-username"], "user"); + assert.equal( + result.outputs["path-mapping"], + "/usr/src/app:application/frontend", + ); + assert.equal(JSON.stringify(result.outputs).includes("test-password"), false); +}); + +for (const env of [ + { CONTAINER_INPUT: "{" }, + { CONTAINER_INPUT: '{"options":"--cpus 2"}' }, + { CONTAINER_INPUT: '{"image":"app","credentials":{"username":"user"}}' }, + { CONTAINER_INPUT: "app", CONTAINER_PASSWORD: "test-password" }, +]) { + test(`rejects invalid preparation options ${JSON.stringify(env)}`, async () => { + const result = await runScript("prepare", "parse", env); + assert.equal(result.errors.length, 1); + }); +} + +for (const job of ["test", "package"]) { + for (const [name, options, expected] of [ + ["successful build", {}, true], + ["intentionally omitted build", { build: "skipped", commands: "" }, true], + ["failed build", { build: "failure" }, false], + ["cancelled build", { build: "cancelled" }, false], + ["unexpected skipped build", { build: "skipped" }, false], + [ + "failed preparation", + { prepare: "failure", build: "skipped", commands: "" }, + false, + ], + [ + "cancelled preparation", + { prepare: "cancelled", build: "skipped", commands: "" }, + false, + ], + [ + "skipped preparation", + { prepare: "skipped", build: "skipped", commands: "" }, + false, + ], + [ + "cancelled workflow", + { cancelled: true, build: "skipped", commands: "" }, + false, + ], + ["disabled checks", { inputs: { checks: false } }, false], + ["disabled job", { inputs: { test: "" }, packageEnabled: false }, false], + ]) { + test(`${job} scheduling after ${name}`, () => { + assert.equal( + canRun(job, { + ...options, + inputs: options.inputs, + }), + expected, + ); + }); + } +} + +test("package discovery is optional and independent of compilation", () => { + assert.equal(canRun("discover-packages", { packageEnabled: false }), false); + assert.equal( + canRun("discover-packages", { inputs: { checks: false } }), + false, + ); + assert.equal(canRun("discover-packages", { prepare: "failure" }), false); + assert.equal( + canRun("discover-packages", { build: "skipped", commands: "" }), + true, + ); + assert.equal(canRun("discover-packages", { build: "failure" }), true); +}); + +for (const discovery of ["failure", "cancelled", "skipped"]) { + test(`package validation requires successful discovery: ${discovery}`, () => { + assert.equal(canRun("package", { discovery }), false); + assert.equal(canRun("test", { discovery }), true); + assert.equal(canRun("package-results", { discovery }), false); + }); +} + +test("package results require completed validation even when compilation is omitted", () => { + assert.equal( + canRun("package-results", { build: "skipped", commands: "" }), + true, + ); + for (const packageResult of ["failure", "cancelled", "skipped"]) { + assert.equal(canRun("package-results", { packageResult }), false); + } + assert.equal(canRun("package-results", { packageEnabled: false }), false); + assert.equal(canRun("package-results", { cancelled: true }), false); + assert.equal(canRun("package-results", { prepare: "failure" }), false); +}); + +test("package configuration retains source packaging without a build", async () => { + const disabled = await runScript("prepare", "package-config"); + assert.equal(disabled.outputs.enabled, false); + const enabled = await runScript("prepare", "package-config", { + PACKAGE_INPUT: '{"directories":["."],"tests":"test -f package.json"}', + }); + assert.equal(enabled.outputs.enabled, true); + assert.equal(JSON.stringify(enabled.outputs.directories), '["."]'); + await assert.rejects( + runScript("prepare", "package-config", { + PACKAGE_INPUT: "true", + CONTAINER_INPUT: "app", + }), + /requires non-container CI/, + ); +}); + +test("empty builds skip their job and lint stays independent of build failures", () => { + assert.equal(canRun("build", { commands: "" }), false); + assert.equal(canRun("build"), true); + assert.equal(canRun("build", { prepare: "failure" }), false); + assert.equal(canRun("lint", { build: "failure" }), true); + assert.equal(canRun("lint", { prepare: "failure" }), false); + assert.equal(canRun("lint", { inputs: { lint: "" } }), false); +}); + +for (const action of ["build", "lint", "test"]) { + test(`${action} enforces workspace boundaries outside container mode`, () => { + const definition = readYaml(`actions/${action}/action.yml`); + const guard = definition.runs.steps.find( + (step) => step.id === "working-directory", + ); + for (const [container, expected] of [ + ["false", "true"], + ["true", "false"], + ]) { + assert.equal( + evaluate(guard.with["enforce-path-in-workspace"], { + inputs: { container }, + }).value, + expected, + ); + } + }); +} diff --git a/tests/source-package/.node-version b/tests/source-package/.node-version new file mode 100644 index 00000000..a45fd52c --- /dev/null +++ b/tests/source-package/.node-version @@ -0,0 +1 @@ +24 diff --git a/tests/source-package/index.cjs b/tests/source-package/index.cjs new file mode 100644 index 00000000..2d139887 --- /dev/null +++ b/tests/source-package/index.cjs @@ -0,0 +1 @@ +module.exports = { answer: 42 }; diff --git a/tests/source-package/package-lock.json b/tests/source-package/package-lock.json new file mode 100644 index 00000000..55f643aa --- /dev/null +++ b/tests/source-package/package-lock.json @@ -0,0 +1,12 @@ +{ + "name": "ci-source-package-fixture", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ci-source-package-fixture", + "version": "1.0.0" + } + } +} diff --git a/tests/source-package/package.json b/tests/source-package/package.json new file mode 100644 index 00000000..e59ec633 --- /dev/null +++ b/tests/source-package/package.json @@ -0,0 +1,11 @@ +{ + "name": "ci-source-package-fixture", + "version": "1.0.0", + "main": "index.cjs", + "files": [ + "index.cjs" + ], + "scripts": { + "build": "node -e \"process.exit(1)\"" + } +}