From 4e39d6ae591bbf50a0dbd147ce07e29113bec4dc Mon Sep 17 00:00:00 2001 From: Anilkumar Reddy Date: Wed, 18 Nov 2026 20:10:36 -0600 Subject: [PATCH] fix: verify setup reporting and patch development tooling --- .github/workflows/ci.yml | 8 ++ CONTRIBUTING.md | 22 ++- README.md | 39 +++--- RELEASING.md | 36 ++--- docs/reporting-validation.md | 71 ++++++++-- package.json | 7 +- pnpm-lock.yaml | 206 ++++++++++++++++------------ scripts/assert-reporting.mjs | 27 ++++ scripts/integration.mjs | 22 ++- scripts/verify-action.mjs | 22 +++ tests/reporting-assertions.test.mjs | 136 ++++++++++++++++++ tests/tooling-dependencies.test.mjs | 31 +++++ 12 files changed, 464 insertions(+), 163 deletions(-) create mode 100644 scripts/assert-reporting.mjs create mode 100644 tests/reporting-assertions.test.mjs create mode 100644 tests/tooling-dependencies.test.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e02aa7..4afe2e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,9 @@ jobs: - name: Run quality gate run: pnpm quality + - name: Verify bundled reporting, summaries, and redaction + run: pnpm test:integration + integration: name: Install CLI (${{ matrix.target }}) strategy: @@ -85,6 +88,11 @@ jobs: CK_CACHE_HIT: ${{ steps.setup-again.outputs.cache-hit }} CK_EXPECTED_CACHE_HIT: 'true' CK_EXPECTED_TARGET: ${{ matrix.target }} + CK_FIRST_CACHE_HIT: ${{ steps.setup.outputs.cache-hit }} + CK_FIRST_NOTIFICATION_EVENT: + ${{ steps.setup.outputs.notification-event }} + CK_NOTIFICATION_EVENT: + ${{ steps.setup-again.outputs.notification-event }} CK_PATH: ${{ steps.setup-again.outputs.path }} CK_TARGET: ${{ steps.setup-again.outputs.target }} CK_VERSION: ${{ steps.setup-again.outputs.version }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 80b5513..63e9cce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,10 +16,11 @@ configuration contains no credentials. Trusted CI installation grants `packages: read` only to its quality job. Fork workflows may lack package access; do not use privileged untrusted PR execution to bypass that restriction. -Normal reporting development uses exact published notification-contract 0.0.6. -No source checkout, candidate preparation or file:tarball dependency is needed. -The historical candidate procedure is archived in -`docs/reporting-validation.md`. +Normal reporting development uses the exact published dependency in +`package.json`; no source checkout, candidate preparation or file:tarball +dependency is needed. The +[compatibility and validation record](docs/reporting-validation.md) owns +released-versus-main reporting status and historical candidate evidence. ```bash corepack enable @@ -40,6 +41,7 @@ pnpm lint pnpm typecheck pnpm test pnpm test:coverage +pnpm test:scripts pnpm bundle pnpm bundle:check pnpm audit --prod --audit-level=high @@ -60,6 +62,18 @@ second-invocation cache hit. It does not install into a system directory or modify a shell profile. Latest-stable discovery is covered with synthetic unit fixtures because the current public CLI releases are previews. +CI runs the full bundled reporting integration once in its Linux quality job. +All six native jobs retain their install/cache checks and verify the real event +outputs using the same success assertions. This avoids six additional complete +integration installations. + +The ESLint and typescript-eslint development parents use upstream patched +minimatch releases. `test:scripts` verifies all three installed paths stay at +11.0.1 or newer. This targeted regression complements the existing production +audit; it is not a claim that every development advisory is absent. Review +development audit results separately without lowering the production gate or +adding broad dependency overrides. + ## Committed bundle GitHub executes `dist/index.js` directly. Consumers do not run `pnpm install`, diff --git a/README.md b/README.md index b4faf7e..d6ad195 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # Setup CommerceKit CLI -> **Registry-backed reporting:** consistent notifications and GitHub summaries -> consume exact published notification-contract 0.0.6 and are bundled for -> runtime consumers. See [reporting validation](docs/reporting-validation.md). +> **Released:** `@v1` installs and verifies the CLI. **Unreleased on main:** the +> notification event and consistent job summaries described below. See +> [release compatibility and validation](docs/reporting-validation.md) before +> selecting an immutable commit for those features. Install and verify a requested [CommerceKit CLI](https://github.com/commercekit-tools/cli) version, or the @@ -19,8 +20,8 @@ version are independent. ## Usage -After the first v1 Action release, a workflow can install the current CLI -preview and run project checks in a separate step: +A workflow can use the released v1 Action to install the current CLI preview and +run project checks in a separate step: ```yaml name: CommerceKit @@ -108,18 +109,18 @@ fails. It never falls back to another release, Homebrew, or WinGet. ## Outputs -| Output | Meaning | Example | -| -------------------- | --------------------------------------------------- | ---------------------------------------------- | -| `version` | Exact installed CLI version. | `0.1.0-preview.2` | -| `path` | Absolute path to the verified executable. | Runner tool-cache path ending in `commercekit` | -| `target` | Normalized release target selected for the runner. | `linux-x64` | -| `build-id` | Verified identity from `release-manifest.json`. | 40-character source identity | -| `cache-hit` | Lowercase string for verified tool-cache reuse. | `true` | -| `notification-event` | Validated setup event with safe inputs and outcome. | Bounded JSON for the existing Notify action. | +| Output | Meaning | Example | +| -------------------- | --------------------------------------------------------------------------- | ---------------------------------------------- | +| `version` | Exact installed CLI version. | `0.1.0-preview.2` | +| `path` | Absolute path to the verified executable. | Runner tool-cache path ending in `commercekit` | +| `target` | Normalized release target selected for the runner. | `linux-x64` | +| `build-id` | Verified identity from `release-manifest.json`. | 40-character source identity | +| `cache-hit` | Lowercase string for verified tool-cache reuse. | `true` | +| `notification-event` | **Unreleased on main:** validated setup event with safe inputs and outcome. | Bounded JSON for the existing Notify action. | Installation outputs are set only after the executable passes integrity and -exact-version verification. The Action also emits `notification-event` for -handled failures before the Action reports failure. +exact-version verification. The unreleased reporting implementation also emits +`notification-event` for handled failures before the Action reports failure. ```yaml - name: Show resolved installation @@ -131,10 +132,12 @@ handled failures before the Action reports failure. "$COMMERCEKIT_PATH" --version ``` -## Consistent notifications and job summaries +## Consistent notifications and job summaries (unreleased) -The Action uses the existing shared notification contract and the existing -Notify Action. It does not add a webhook input or delivery code. +These features are available only at reviewed main commits, and are absent from +the current released `v1` alias. See the +[compatibility record](docs/reporting-validation.md#release-compatibility). +Notify handles delivery; Setup does not add a webhook input. `commercekit.setup.completed` reports setup success or failure with the exact `version` input name, effective `latest` when omitted, validation/truncation metadata, verified installed version, target, build identity, cache reuse and diff --git a/RELEASING.md b/RELEASING.md index 6d28412..1b97d9b 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -20,14 +20,12 @@ This repository does not publish an npm package. ## Reporting consistency -The Action consumes exact published notification-contract 0.0.6, with its -registry lockfile and standalone bundle committed. Normal development and -runtime use no candidate dependency or source checkout. The package-only -publication is separate from this Action's release process; it created no Action -tag or Marketplace release. See -[reporting-validation.md](docs/reporting-validation.md) for exact provenance and -normal validation evidence. All quality/security checks and six native runner -jobs must pass on the reviewed release commit. +See the +[release compatibility and validation record](docs/reporting-validation.md) for +the released Action reference, main-only reporting features, exact shared +dependency and publication evidence. Package publication and an Action release +are separate decisions. All quality/security checks and six native runner jobs +must pass on the reviewed release commit. ## Release prerequisites @@ -48,18 +46,20 @@ Before creating a release: Do not create an Action release from an unreviewed branch. -## Initial v1 release +## Next compatible v1 release (owner approval required) -After the implementation pull request is merged and `main` CI passes: +The initial `v1.0.0` already exists. Keep that immutable tag and release intact. +Only after the owner separately authorizes an Action release, a reviewed pull +request is merged and the exact main commit passes all prerequisites: -1. create immutable annotated tag `v1.0.0` at the reviewed release commit; -2. create or update annotated tag `v1` to the same commit; -3. push both tags without rewriting the immutable tag; -4. create a GitHub Release for `v1.0.0` with public release notes; +1. select an unused compatible patch version, such as `v1.0.1`; +2. create its immutable annotated tag and GitHub Release at the reviewed commit; +3. verify the exact tag's committed bundle and public release notes; +4. update the compatible `v1` alias under the versioning policy; 5. verify `commercekit-tools/setup-commercekit@v1` from an independent public test repository; and -6. optionally submit the Action to GitHub Marketplace after confirming the - repository license, metadata, branding, and security guidance. +6. consider Marketplace publication only with separate owner authorization and + after confirming the license, metadata, branding and security guidance. -No tags or Marketplace publication should occur before the implementation is -reviewed and merged. +Normal CI never creates tags, GitHub Releases or Marketplace listings. The +reporting and validation changes do not authorize any of these operations. diff --git a/docs/reporting-validation.md b/docs/reporting-validation.md index 2849dbd..d346918 100644 --- a/docs/reporting-validation.md +++ b/docs/reporting-validation.md @@ -1,5 +1,20 @@ # Reporting consistency validation +## Release compatibility + +| Action reference | Installation | Notification event and consistent summaries | +| --------------------------------------------------------------------------- | ------------ | ------------------------------------------------ | +| Released `v1` / `v1.0.0`, commit `dffa026980479cf96d7a5f4763602d39a7325a7c` | Available | Absent from this release | +| Reviewed main commits since `52a5a098d89f9ef2c42a234b4c3baa5d60a7a896` | Available | Implemented and bundled; unreleased as an Action | + +The +[existing release](https://github.com/commercekit-tools/setup-commercekit/releases/tag/v1.0.0) +is independent of the CLI's Preview maturity. Use the released alias for +installation, or a reviewed immutable main commit when explicitly testing +reporting. Notify must support the same setup event before it receives that +output; use compatible immutable commits rather than an assumed future tag. This +record owns release-state details linked by the README and release guide. + ## Published dependency and provenance The owner-authorized @@ -30,28 +45,33 @@ remain unchanged. Shared APIs own captured input context, bounded redaction, setup event factories/schema validation, safe GitHub context and common summaries. -## Executed normal registry checks +## Recorded registry-adoption checks + +The following records the original registry-backed adoption, rather than +claiming that historical results validate every later commit. Status vocabulary: PASS, FAIL, BLOCKED, NOT RUN. -| Check | Status | Evidence | -| -------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- | -| Frozen installation and public exports | PASS | Exact registry 0.0.6 and required public setup/reporting APIs verified | -| Formatting, lint and strict types | PASS | Normal source passes without candidate switches | -| Unit/integration coverage | PASS | 154 tests/11 files; 94.06% statements, 90.29% branches, 93.54% functions, 94.21% lines; existing thresholds and inclusion unchanged | -| Actual registry-backed bundle integration | PASS | Public CLI preview.2 installed/verified on darwin-arm64, verified cache reuse, success and invalid-input failure events/summaries | -| Normal bundle regeneration | PASS | SHA256 above matches the reviewed candidate exactly | -| Public scan, production audit, workflow lint | PASS | Scan passed; no known vulnerabilities; local actionlint and diff checks passed | -| Final committed bundle check | PASS | Full normal `pnpm quality` passed after committing registry-backed dist; no generated changes | -| Six native runner integration jobs | NOT RUN | Final-head Linux/macOS/Windows x64/ARM64 jobs must pass before merge; earlier baseline-bundle jobs are not feature evidence | -| Live Slack/Teams delivery | NOT RUN | Notify owns this separately authorized capability; no provider send performed | +| Check | Status | Evidence | +| -------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Frozen installation and public exports | PASS | Exact registry 0.0.6 and required public setup/reporting APIs verified | +| Formatting, lint and strict types | PASS | Normal source passes without candidate switches | +| Unit/integration coverage | PASS | 154 tests/11 files; 94.06% statements, 90.29% branches, 93.54% functions, 94.21% lines; existing thresholds and inclusion unchanged | +| Actual registry-backed bundle integration | PASS | Public CLI preview.2 installed/verified on darwin-arm64, verified cache reuse, success and invalid-input failure events/summaries | +| Normal bundle regeneration | PASS | SHA256 above matches the reviewed candidate exactly | +| Public scan, production audit, workflow lint | PASS | Scan passed; no known vulnerabilities; local actionlint and diff checks passed | +| Final committed bundle check | PASS | Full normal `pnpm quality` passed after committing registry-backed dist; no generated changes | +| Six native runner installation/cache jobs | PASS | [Main CI run 43679114996](https://github.com/commercekit-tools/setup-commercekit/actions/runs/43679114996) passed all six targets at `52a5a098d89f9ef2c42a234b4c3baa5d60a7a896`; those checks verified installation/cache outputs, not reporting assertions | +| Live Slack/Teams delivery | NOT RUN | Notify owns this separately authorized capability; no provider send performed | Commands actually executed: `pnpm install --frozen-lockfile`, `pnpm bundle`, public-export assertions, `pnpm format:check`, `pnpm lint`, `pnpm typecheck`, `pnpm test:coverage`, `pnpm test:integration`, `pnpm scan:public`, -`pnpm audit --prod --audit-level=high`, actionlint and `git diff --check`. Full -committed-bundle quality and final hosted checks remain required before merge. -The registry-publication compatibility gate is resolved. +`pnpm audit --prod --audit-level=high`, actionlint and `git diff --check`. The +recorded +[main CodeQL run](https://github.com/commercekit-tools/setup-commercekit/actions/runs/43679114994) +also passed. Every later review still requires checks for its exact head. The +registry-publication compatibility gate is resolved. Tests cover complete input/result projection, workflow reference parity, allowlisted GitHub environment access, safe invalid settings, JWT/URL credential @@ -61,6 +81,27 @@ executes the actual entry point, checks two successful invocations plus invalid input failure, and validates events/summaries in controlled temporary files. No SAP operation is involved. +## Hosted reporting checks + +The Linux quality job now runs the existing `pnpm test:integration` once. It +executes the committed bundle with an isolated tool cache, parses the public +contract schema, checks fresh/cached success events and summaries, and verifies +the handled invalid-input failure and synthetic JWT redaction in events, +summaries and logs. No provider message is sent. + +The six existing native jobs still install and reuse the Action exactly as +before. Their verifier additionally checks both actual notification outputs +against installed version, target, build identity, cache result, bounded input +context and duration, and rejects private executable paths. Shared assertions +are reused by the isolated integration instead of copying reporting policy or +repeating its complete fresh/cache/failure flow on six platforms. Installation +and reporting failures must remain visible; reporting errors do not change the +Action's underlying installation outcome. + +`pnpm test:scripts` covers missing/malformed outputs, mismatched facts, private +paths and the installed patched minimatch resolutions. It is part of `quality`; +the existing unit coverage thresholds and production audit remain unchanged. + ## Historical candidate evidence Before publication, source `475cc4db42f79310240496201f90d7047aa54330` was packed diff --git a/package.json b/package.json index 309456d..6d8f1f4 100644 --- a/package.json +++ b/package.json @@ -15,11 +15,12 @@ "format": "prettier --write .", "format:check": "prettier --check .", "lint": "eslint .", - "quality": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test:coverage && pnpm bundle:check && pnpm scan:public && pnpm audit --prod --audit-level=high", + "quality": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test:coverage && pnpm test:scripts && pnpm bundle:check && pnpm scan:public && pnpm audit --prod --audit-level=high", "scan:public": "node scripts/scan-public-files.mjs", "test": "vitest run", "test:coverage": "vitest run --coverage", "test:integration": "node scripts/integration.mjs", + "test:scripts": "node --test tests/*.test.mjs", "typecheck": "tsc --noEmit" }, "dependencies": { @@ -34,11 +35,11 @@ "@types/semver": "7.8.0", "@vercel/ncc": "0.45.0", "@vitest/coverage-v8": "5.1.0", - "eslint": "10.14.0", + "eslint": "10.15.0", "globals": "17.14.0", "prettier": "3.10.1", "typescript": "6.0.3", - "typescript-eslint": "8.72.2", + "typescript-eslint": "8.73.0", "vitest": "5.1.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 94d35e9..6c927f1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -181,7 +181,7 @@ importers: devDependencies: '@eslint/js': specifier: 10.0.1 - version: 10.0.1(eslint@10.14.0) + version: 10.0.1(eslint@10.15.0) '@types/node': specifier: 26.6.6 version: 26.6.6 @@ -195,8 +195,8 @@ importers: specifier: 5.1.0 version: 5.1.0(vitest@5.1.0) eslint: - specifier: 10.14.0 - version: 10.14.0 + specifier: 10.15.0 + version: 10.15.0 globals: specifier: 17.14.0 version: 17.14.0 @@ -207,8 +207,8 @@ importers: specifier: 6.0.3 version: 6.0.3 typescript-eslint: - specifier: 8.72.2 - version: 8.72.2(eslint@10.14.0)(typescript@6.0.3) + specifier: 8.73.0 + version: 8.73.0(eslint@10.15.0)(typescript@6.0.3) vitest: specifier: 5.1.0 version: 5.1.0(@types/node@26.6.6)(@vitest/coverage-v8@5.1.0)(vite@8.3.4(@types/node@26.6.6)) @@ -271,8 +271,8 @@ packages: resolution: {integrity: sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - '@eslint/config-array@0.23.5': - resolution: {integrity: sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==} + '@eslint/config-array@0.23.6': + resolution: {integrity: sha512-WrTH7nioI9QPY4NZGnsywmecswJdgeq4BCM76qok9VgjTO29ZgUzUvcuJLVPYVQM4uDbaPBU0M33R9DIxI8X3w==} engines: {node: ^20.19.0 || ^22.13.0 || >=24} '@eslint/config-helpers@0.7.0': @@ -320,6 +320,9 @@ packages: resolution: {integrity: sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==} engines: {node: '>=18.18'} + '@isaacs/nonrecursive-glob-match@1.1.0': + resolution: {integrity: sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==} + '@jridgewell/resolve-uri@3.1.2': resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} @@ -462,63 +465,67 @@ packages: '@types/semver@7.8.0': resolution: {integrity: sha512-1mAINjtQCXXeLkJ9ehXkwOcBpqtLxiVtKhpUf83DdRNdQKV0iXZpaHYqRr7nj+wvxuJzoAmAwXI+sCNMv1CzLQ==} - '@typescript-eslint/eslint-plugin@8.72.2': - resolution: {integrity: sha512-222PKFXKihmFpi/pS5njoBgdAqsPhj2/GBmFbrNw8Tq8gEG9Sv+kSlKFy4u2q+mJv9ZzJgM2Gkv/bUzRZwZw5g==} + '@typescript-eslint/eslint-plugin@8.73.0': + resolution: {integrity: sha512-UkygMFer53Yzn29MCYFTHf34hGXf5KJhiDWfIm1tXtXRrym1CS6l5H9Y3yCtPWChpC0/f93H88gdj8tN0dd4kw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - '@typescript-eslint/parser': ^8.72.2 + '@typescript-eslint/parser': ^8.73.0 eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/parser@8.72.2': - resolution: {integrity: sha512-llP+T1YuJOLlxEciP6OyQGtz5SMxyn+9LA2BvZw5RmToGVa1y4beEDVQL6Gje7T5WFYh19WREjDCN9Ev4gm5AA==} + '@typescript-eslint/parser@8.73.0': + resolution: {integrity: sha512-AuL45bVcmssHfZ3Di3cs9Q0l4gBm4ZFVrJOQEE7VpqW+PVgQaEwSwazz4TVIiFabXkk6U51EprYDwqw+HR8ePw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/project-service@8.72.2': - resolution: {integrity: sha512-6y5dLTZdHhI8Eh3yIQ/bfQhRKwn5e+TpJj64o18Cngc0iW/BCrVvrr6zGYqXPnYH31u6YXAYiFh0+qxX5mybJw==} + '@typescript-eslint/project-service@8.73.0': + resolution: {integrity: sha512-/pEf8Rc4Mjk+qJnY0uO1+Gadeal8uv50xpuic+srG2vIVatA0XxvWMUeMtFvs6OCHqftiQ7/+qH4aehG5stzIA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/scope-manager@8.72.2': - resolution: {integrity: sha512-iIoMJ6/8c1/QpFNyFjU0d1YzPco4MsZjQw0k3V+vfzNWAFmUmvhlyMoYEoYYDQZXc+J6Gi1X5XcxlzW2taIIGQ==} + '@typescript-eslint/scope-manager@8.73.0': + resolution: {integrity: sha512-/TjD738Iq2rzj5z0ixVOi+TsvgjAzZPLPaH1yWdDBytR/HTR5gMpyYWZeCe5WTQZLwk3ho8AV7U3muoQCRtXBQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/tsconfig-utils@8.72.2': - resolution: {integrity: sha512-+h3iCgZXuTNtoLXcnnjP12ZUHLMqoUcIHPfQrFEXTUqvb9dF8QK9b5nv5VtSo5fLkdHuks8ehbTzZj3rImAm9w==} + '@typescript-eslint/tsconfig-utils@8.73.0': + resolution: {integrity: sha512-lmtCFOfYaJfpqZywGuXi4FpNtE+NQ+YLe3T0K9rtEDcW8ZuGWvfI++pj8r05sYMI8vWT2CYK4rWyedmD6Rp4og==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/type-utils@8.72.2': - resolution: {integrity: sha512-STfkR38qIdhfkLpgtXnUjAzsNy4xouqiBO0lrVc/Wpk9Kem5/aHXUx1J8dGC16zpdYN1+yc2ILQ28er1kXX7ag==} + '@typescript-eslint/type-utils@8.73.0': + resolution: {integrity: sha512-MOC9i4xy1F7KcDde7Ip8jf1SrRiALb2Km4UWxGNjUE2YlhjIEo1ayE27GHIwIQyfWuHTmEonQT14uyurlyC6aA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/types@8.72.2': - resolution: {integrity: sha512-Xfn37OLZx03+PCU7qWx9DTv2FCRh1E6fk2+wONeNY15HXIwtcwuveaSwVpGAUptkNmPQegRxW5JyRel9T7wrog==} + '@typescript-eslint/types@8.73.0': + resolution: {integrity: sha512-O/1ytYzflF16QDKXx4/qOXg1IuZp+n7hr9t+S0nv7N/2Tl8rJiNCshztV1gcSUvHbPtoX3+zmNbtSAyVbzxVfw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/typescript-estree@8.72.2': - resolution: {integrity: sha512-pQEGqIK/cqEvKivVWaFLYpe7XYejFxfuAOi4mu1oAWFvIo36aRHI9esRFTUxcIy/z8N482RJyH+LpZB0ZIU7Ow==} + '@typescript-eslint/typescript-estree@8.73.0': + resolution: {integrity: sha512-InjlBkSdWceIwIBWSwS3ENUp+i0O02PGX3Zv2wnihWJC1WDVGvG7mTHuf8b57uAaITj94d6tRPDH+sUEtXdRQQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: + '@typescript/native': npm:typescript@>=7.1.0-dev.20261009.1 || >=7.1.0-beta <7.1.0-dev typescript: '>=4.8.4 <6.1.0' + peerDependenciesMeta: + '@typescript/native': + optional: true - '@typescript-eslint/utils@8.72.2': - resolution: {integrity: sha512-hv3eRYbpPbbpezuax1EfGrzpa3C4ySgNZkPUkLOWOAjU8HsOKowEDAr8C7nsNl1C+SBSKDpvno6VKHnlhvp9iA==} + '@typescript-eslint/utils@8.73.0': + resolution: {integrity: sha512-j2SVJJvVkXdUL0WcEzo4vEH1mO1vIi8KlVukcYA2MgMZvYN2LlZR4PmsW+GTSxSW24j6Q/EP7+MOifLtg5hmsA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/visitor-keys@8.72.2': - resolution: {integrity: sha512-NAGrjn0Pitjqzq/GkgMC4kBYm233PQ8GffyQ9+kTA3AlNQYEzOf25EIM02BAHZv5FRJSpHpJk+OGUxVkOB93GQ==} + '@typescript-eslint/visitor-keys@8.73.0': + resolution: {integrity: sha512-k4lsFVpRZICbltkIEEH4hZRkwXkqDF1GHBpClKQOHQY+RkoZAAuyc1ci3I6p+CB6v3U4jaHIUshc4RzzQXZWLg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@vercel/ncc@0.45.0': @@ -641,8 +648,8 @@ packages: resolution: {integrity: sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==} engines: {node: ^20.19.0 || ^22.13.0 || >=24} - eslint@10.14.0: - resolution: {integrity: sha512-T0pNsxkb9IKmtQjhpK3d7nWOpFv+YHuMbTJnSVMoQblF0onvXfErrtp4V1jHtsQPan7dKaGVD0q1WCXnzMF31A==} + eslint@10.15.0: + resolution: {integrity: sha512-+5Wg4p+ze3sG1WErYgUO/3H1IQIfFBymVUA0Fo/XTeBOLS6UQIUekpSJ8sdRkn7O7wjh84b55w/roqavH2aScg==} engines: {node: ^20.19.0 || ^22.13.0 || >=24} hasBin: true peerDependencies: @@ -861,10 +868,14 @@ packages: magicast@0.5.5: resolution: {integrity: sha512-UicdXN8zQ3JHlxVq+28afMXPr1z7WNY6+7EJnzTdQWkTAlMLF5fNCCKxJHBQwGaNGR11581EiQmQzx73+MvszA==} - minimatch@10.2.6: - resolution: {integrity: sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==} + minimatch@11.0.1: + resolution: {integrity: sha512-t+Vn6DX4wPCxS23y03C0uhF7S1jpi1GfqPrnlEipCJaA2ykiNbMkVlDutZtmvLfRcUN6R8AYVlzTsQrT4RZoLQ==} engines: {node: 18 || 20 || >=22} + minimatch@11.0.9: + resolution: {integrity: sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==} + engines: {node: 20 || >=22} + ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -987,8 +998,8 @@ packages: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} - typescript-eslint@8.72.2: - resolution: {integrity: sha512-c/+AKMW1KB81r28Sp0AAdcyXj5dzNmAsZFcsrxKbZTKmcBK2xIwBR31dcSYSDu3bKmzXe8GKrSxO+eDQ401Uzg==} + typescript-eslint@8.73.0: + resolution: {integrity: sha512-+EnKy9rkYPun4l+kG2bDuYWQ6y1tGVgdR/tY1U9AC6h21CjEwOoc7gsjwe0FXB8uWFzk4QiCFbuRWgX758PiAg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 @@ -1169,18 +1180,18 @@ snapshots: ajv: 8.20.0 ajv-formats: 3.0.1(ajv@8.20.0) - '@eslint-community/eslint-utils@4.10.1(eslint@10.14.0)': + '@eslint-community/eslint-utils@4.10.1(eslint@10.15.0)': dependencies: - eslint: 10.14.0 + eslint: 10.15.0 eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.2': {} - '@eslint/config-array@0.23.5': + '@eslint/config-array@0.23.6': dependencies: '@eslint/object-schema': 3.0.5 debug: 4.4.3 - minimatch: 10.2.6 + minimatch: 11.0.9 transitivePeerDependencies: - supports-color @@ -1192,9 +1203,9 @@ snapshots: dependencies: '@types/json-schema': 7.0.15 - '@eslint/js@10.0.1(eslint@10.14.0)': + '@eslint/js@10.0.1(eslint@10.15.0)': optionalDependencies: - eslint: 10.14.0 + eslint: 10.15.0 '@eslint/object-schema@3.0.5': {} @@ -1219,6 +1230,8 @@ snapshots: '@humanwhocodes/retry@0.4.3': {} + '@isaacs/nonrecursive-glob-match@1.1.0': {} + '@jridgewell/resolve-uri@3.1.2': {} '@jridgewell/sourcemap-codec@1.6.0': {} @@ -1304,74 +1317,77 @@ snapshots: '@types/semver@7.8.0': {} - '@typescript-eslint/eslint-plugin@8.72.2(@typescript-eslint/parser@8.72.2(eslint@10.14.0)(typescript@6.0.3))(eslint@10.14.0)(typescript@6.0.3)': + '@typescript-eslint/eslint-plugin@8.73.0(@typescript-eslint/parser@8.73.0(eslint@10.15.0)(typescript@6.0.3))(eslint@10.15.0)(typescript@6.0.3)': dependencies: '@eslint-community/regexpp': 4.12.2 - '@typescript-eslint/parser': 8.72.2(eslint@10.14.0)(typescript@6.0.3) - '@typescript-eslint/scope-manager': 8.72.2 - '@typescript-eslint/type-utils': 8.72.2(eslint@10.14.0)(typescript@6.0.3) - '@typescript-eslint/utils': 8.72.2(eslint@10.14.0)(typescript@6.0.3) - '@typescript-eslint/visitor-keys': 8.72.2 - eslint: 10.14.0 + '@typescript-eslint/parser': 8.73.0(eslint@10.15.0)(typescript@6.0.3) + '@typescript-eslint/scope-manager': 8.73.0 + '@typescript-eslint/type-utils': 8.73.0(eslint@10.15.0)(typescript@6.0.3) + '@typescript-eslint/utils': 8.73.0(eslint@10.15.0)(typescript@6.0.3) + '@typescript-eslint/visitor-keys': 8.73.0 + eslint: 10.15.0 ignore: 7.0.12 natural-compare: 1.4.0 ts-api-utils: 2.5.0(typescript@6.0.3) typescript: 6.0.3 transitivePeerDependencies: + - '@typescript/native' - supports-color - '@typescript-eslint/parser@8.72.2(eslint@10.14.0)(typescript@6.0.3)': + '@typescript-eslint/parser@8.73.0(eslint@10.15.0)(typescript@6.0.3)': dependencies: - '@typescript-eslint/scope-manager': 8.72.2 - '@typescript-eslint/types': 8.72.2 - '@typescript-eslint/typescript-estree': 8.72.2(typescript@6.0.3) - '@typescript-eslint/visitor-keys': 8.72.2 + '@typescript-eslint/scope-manager': 8.73.0 + '@typescript-eslint/types': 8.73.0 + '@typescript-eslint/typescript-estree': 8.73.0(typescript@6.0.3) + '@typescript-eslint/visitor-keys': 8.73.0 debug: 4.4.3 - eslint: 10.14.0 + eslint: 10.15.0 typescript: 6.0.3 transitivePeerDependencies: + - '@typescript/native' - supports-color - '@typescript-eslint/project-service@8.72.2(typescript@6.0.3)': + '@typescript-eslint/project-service@8.73.0(typescript@6.0.3)': dependencies: - '@typescript-eslint/tsconfig-utils': 8.72.2(typescript@6.0.3) - '@typescript-eslint/types': 8.72.2 + '@typescript-eslint/tsconfig-utils': 8.73.0(typescript@6.0.3) + '@typescript-eslint/types': 8.73.0 debug: 4.4.3 typescript: 6.0.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/scope-manager@8.72.2': + '@typescript-eslint/scope-manager@8.73.0': dependencies: - '@typescript-eslint/types': 8.72.2 - '@typescript-eslint/visitor-keys': 8.72.2 + '@typescript-eslint/types': 8.73.0 + '@typescript-eslint/visitor-keys': 8.73.0 - '@typescript-eslint/tsconfig-utils@8.72.2(typescript@6.0.3)': + '@typescript-eslint/tsconfig-utils@8.73.0(typescript@6.0.3)': dependencies: typescript: 6.0.3 - '@typescript-eslint/type-utils@8.72.2(eslint@10.14.0)(typescript@6.0.3)': + '@typescript-eslint/type-utils@8.73.0(eslint@10.15.0)(typescript@6.0.3)': dependencies: - '@typescript-eslint/types': 8.72.2 - '@typescript-eslint/typescript-estree': 8.72.2(typescript@6.0.3) - '@typescript-eslint/utils': 8.72.2(eslint@10.14.0)(typescript@6.0.3) + '@typescript-eslint/types': 8.73.0 + '@typescript-eslint/typescript-estree': 8.73.0(typescript@6.0.3) + '@typescript-eslint/utils': 8.73.0(eslint@10.15.0)(typescript@6.0.3) debug: 4.4.3 - eslint: 10.14.0 + eslint: 10.15.0 ts-api-utils: 2.5.0(typescript@6.0.3) typescript: 6.0.3 transitivePeerDependencies: + - '@typescript/native' - supports-color - '@typescript-eslint/types@8.72.2': {} + '@typescript-eslint/types@8.73.0': {} - '@typescript-eslint/typescript-estree@8.72.2(typescript@6.0.3)': + '@typescript-eslint/typescript-estree@8.73.0(typescript@6.0.3)': dependencies: - '@typescript-eslint/project-service': 8.72.2(typescript@6.0.3) - '@typescript-eslint/tsconfig-utils': 8.72.2(typescript@6.0.3) - '@typescript-eslint/types': 8.72.2 - '@typescript-eslint/visitor-keys': 8.72.2 + '@typescript-eslint/project-service': 8.73.0(typescript@6.0.3) + '@typescript-eslint/tsconfig-utils': 8.73.0(typescript@6.0.3) + '@typescript-eslint/types': 8.73.0 + '@typescript-eslint/visitor-keys': 8.73.0 debug: 4.4.3 - minimatch: 10.2.6 + minimatch: 11.0.1 semver: 7.8.6 tinyglobby: 0.2.17 ts-api-utils: 2.5.0(typescript@6.0.3) @@ -1379,20 +1395,21 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.72.2(eslint@10.14.0)(typescript@6.0.3)': + '@typescript-eslint/utils@8.73.0(eslint@10.15.0)(typescript@6.0.3)': dependencies: - '@eslint-community/eslint-utils': 4.10.1(eslint@10.14.0) - '@typescript-eslint/scope-manager': 8.72.2 - '@typescript-eslint/types': 8.72.2 - '@typescript-eslint/typescript-estree': 8.72.2(typescript@6.0.3) - eslint: 10.14.0 + '@eslint-community/eslint-utils': 4.10.1(eslint@10.15.0) + '@typescript-eslint/scope-manager': 8.73.0 + '@typescript-eslint/types': 8.73.0 + '@typescript-eslint/typescript-estree': 8.73.0(typescript@6.0.3) + eslint: 10.15.0 typescript: 6.0.3 transitivePeerDependencies: + - '@typescript/native' - supports-color - '@typescript-eslint/visitor-keys@8.72.2': + '@typescript-eslint/visitor-keys@8.73.0': dependencies: - '@typescript-eslint/types': 8.72.2 + '@typescript-eslint/types': 8.73.0 eslint-visitor-keys: 5.0.1 '@vercel/ncc@0.45.0': {} @@ -1503,11 +1520,11 @@ snapshots: eslint-visitor-keys@5.0.1: {} - eslint@10.14.0: + eslint@10.15.0: dependencies: - '@eslint-community/eslint-utils': 4.10.1(eslint@10.14.0) + '@eslint-community/eslint-utils': 4.10.1(eslint@10.15.0) '@eslint-community/regexpp': 4.12.2 - '@eslint/config-array': 0.23.5 + '@eslint/config-array': 0.23.6 '@eslint/config-helpers': 0.7.0 '@eslint/core': 1.2.1 '@eslint/plugin-kit': 0.7.3 @@ -1532,7 +1549,7 @@ snapshots: imurmurhash: 0.1.4 is-glob: 4.0.3 json-stable-stringify-without-jsonify: 1.0.1 - minimatch: 10.2.6 + minimatch: 11.0.9 natural-compare: 1.4.0 optionator: 0.9.4 transitivePeerDependencies: @@ -1702,8 +1719,14 @@ snapshots: '@babel/types': 7.29.8 source-map-js: 1.2.2 - minimatch@10.2.6: + minimatch@11.0.1: + dependencies: + '@isaacs/nonrecursive-glob-match': 1.1.0 + brace-expansion: 5.0.12 + + minimatch@11.0.9: dependencies: + '@isaacs/nonrecursive-glob-match': 1.1.0 brace-expansion: 5.0.12 ms@2.1.3: {} @@ -1811,15 +1834,16 @@ snapshots: dependencies: prelude-ls: 1.2.1 - typescript-eslint@8.72.2(eslint@10.14.0)(typescript@6.0.3): + typescript-eslint@8.73.0(eslint@10.15.0)(typescript@6.0.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.72.2(@typescript-eslint/parser@8.72.2(eslint@10.14.0)(typescript@6.0.3))(eslint@10.14.0)(typescript@6.0.3) - '@typescript-eslint/parser': 8.72.2(eslint@10.14.0)(typescript@6.0.3) - '@typescript-eslint/typescript-estree': 8.72.2(typescript@6.0.3) - '@typescript-eslint/utils': 8.72.2(eslint@10.14.0)(typescript@6.0.3) - eslint: 10.14.0 + '@typescript-eslint/eslint-plugin': 8.73.0(@typescript-eslint/parser@8.73.0(eslint@10.15.0)(typescript@6.0.3))(eslint@10.15.0)(typescript@6.0.3) + '@typescript-eslint/parser': 8.73.0(eslint@10.15.0)(typescript@6.0.3) + '@typescript-eslint/typescript-estree': 8.73.0(typescript@6.0.3) + '@typescript-eslint/utils': 8.73.0(eslint@10.15.0)(typescript@6.0.3) + eslint: 10.15.0 typescript: 6.0.3 transitivePeerDependencies: + - '@typescript/native' - supports-color typescript@6.0.3: {} diff --git a/scripts/assert-reporting.mjs b/scripts/assert-reporting.mjs new file mode 100644 index 0000000..85d1b47 --- /dev/null +++ b/scripts/assert-reporting.mjs @@ -0,0 +1,27 @@ +import assert from 'node:assert/strict'; + +/** Shared by the isolated bundle integration and the native hosted verifier. */ +export function assertSuccessfulSetupEvent( + event, + { version, target, buildId, cacheHit, privatePaths = [] }, +) { + assert.equal(event.eventType, 'commercekit.setup.completed'); + assert.equal(event.status, 'success'); + assert.equal(event.source.component, 'setup-commercekit'); + assert.equal(event.data.version, version); + assert.equal(event.data.target, target); + assert.equal(event.data.buildId, buildId); + assert.equal(event.data.cacheHit, cacheHit); + assert.equal(event.data.inputsValidated, true); + assert.equal(event.data.inputsTruncated, false); + assert.deepEqual(event.data.inputs, { version }); + assert( + Number.isSafeInteger(event.data.durationMs) && event.data.durationMs >= 0, + ); + const json = JSON.stringify(event); + for (const path of privatePaths) + assert( + !json.includes(path), + 'Setup event contains a private runtime path.', + ); +} diff --git a/scripts/integration.mjs b/scripts/integration.mjs index 8c5b8f0..f516bf4 100644 --- a/scripts/integration.mjs +++ b/scripts/integration.mjs @@ -4,6 +4,7 @@ import { join } from 'node:path'; import { spawnSync } from 'node:child_process'; import assert from 'node:assert/strict'; import { parseNotificationEventJson } from '@commercekit-tools/notification-contract'; +import { assertSuccessfulSetupEvent } from './assert-reporting.mjs'; const VERSION = '0.1.0-preview.2'; const root = new URL('..', import.meta.url); @@ -113,20 +114,13 @@ try { [second, secondSummary, true], ]) { const event = parseNotificationEventJson(output.get('notification-event')); - assert.equal(event.eventType, 'commercekit.setup.completed'); - assert.equal(event.status, 'success'); - assert.equal(event.source.component, 'setup-commercekit'); - assert.equal(event.data.version, VERSION); - assert.equal(event.data.target, output.get('target')); - assert.equal(event.data.buildId, output.get('build-id')); - assert.equal(event.data.cacheHit, expectedCacheHit); - assert.equal(event.data.inputsValidated, true); - assert.equal(event.data.inputsTruncated, false); - assert.deepEqual(event.data.inputs, { version: VERSION }); - assert( - Number.isSafeInteger(event.data.durationMs) && event.data.durationMs >= 0, - ); - assert(!JSON.stringify(event).includes(directory)); + assertSuccessfulSetupEvent(event, { + version: VERSION, + target: output.get('target'), + buildId: output.get('build-id'), + cacheHit: expectedCacheHit, + privatePaths: [directory], + }); const summary = await readFile(summaryFile, 'utf8'); for (const detail of [ '✅', diff --git a/scripts/verify-action.mjs b/scripts/verify-action.mjs index 8bec8b7..1fb1ca3 100644 --- a/scripts/verify-action.mjs +++ b/scripts/verify-action.mjs @@ -1,6 +1,7 @@ import { existsSync } from 'node:fs'; import { delimiter, dirname } from 'node:path'; import { spawnSync } from 'node:child_process'; +import { assertSuccessfulSetupEvent } from './assert-reporting.mjs'; function requireEnvironment(name) { const value = process.env[name]; @@ -29,6 +30,7 @@ const buildId = requireEnvironment('CK_BUILD_ID'); const cacheHit = requireEnvironment('CK_CACHE_HIT'); const expectedTarget = requireEnvironment('CK_EXPECTED_TARGET'); const expectedCacheHit = requireEnvironment('CK_EXPECTED_CACHE_HIT'); +const firstCacheHit = requireEnvironment('CK_FIRST_CACHE_HIT'); if (!existsSync(executablePath)) throw new Error('Action output path is missing.'); @@ -39,6 +41,26 @@ if (!/^[0-9a-f]{40}$/u.test(buildId)) throw new Error('Invalid build ID output.'); if (cacheHit !== expectedCacheHit) throw new Error('Unexpected cache-hit output.'); +if (!['true', 'false'].includes(firstCacheHit)) + throw new Error('Invalid first cache-hit output.'); +for (const [name, hit] of [ + ['CK_FIRST_NOTIFICATION_EVENT', firstCacheHit], + ['CK_NOTIFICATION_EVENT', cacheHit], +]) { + let event; + try { + event = JSON.parse(requireEnvironment(name)); + } catch { + throw new Error('Setup notification output is missing or invalid JSON.'); + } + assertSuccessfulSetupEvent(event, { + version, + target, + buildId, + cacheHit: hit === 'true', + privatePaths: [executablePath], + }); +} if (!process.env.PATH?.split(delimiter).includes(dirname(executablePath))) { throw new Error('CommerceKit executable directory is missing from PATH.'); } diff --git a/tests/reporting-assertions.test.mjs b/tests/reporting-assertions.test.mjs new file mode 100644 index 0000000..283360c --- /dev/null +++ b/tests/reporting-assertions.test.mjs @@ -0,0 +1,136 @@ +import assert from 'node:assert/strict'; +import { spawnSync } from 'node:child_process'; +import { delimiter, dirname, resolve } from 'node:path'; +import { test } from 'node:test'; +import { assertSuccessfulSetupEvent } from '../scripts/assert-reporting.mjs'; + +const expected = { + version: '0.1.0-preview.2', + target: 'linux-x64', + buildId: 'a'.repeat(40), + cacheHit: false, +}; + +function event(cacheHit = false) { + return { + eventType: 'commercekit.setup.completed', + status: 'success', + source: { component: 'setup-commercekit' }, + data: { + ...expected, + cacheHit, + inputsValidated: true, + inputsTruncated: false, + inputs: { version: expected.version }, + durationMs: 0, + }, + }; +} + +test('native and isolated bundle checks accept both fresh and cached setup reports', () => { + for (const cacheHit of [false, true]) + assert.doesNotThrow(() => + assertSuccessfulSetupEvent(event(cacheHit), { ...expected, cacheHit }), + ); +}); + +test('missing or inconsistent setup facts cannot pass hosted reporting verification', () => { + for (const mutate of [ + (value) => { + value.eventType = 'ccv2.build.completed'; + }, + (value) => { + value.status = 'failure'; + }, + (value) => { + value.source.component = 'another-action'; + }, + (value) => { + delete value.data.version; + }, + (value) => { + value.data.target = 'darwin-arm64'; + }, + (value) => { + value.data.buildId = 'b'.repeat(40); + }, + (value) => { + value.data.cacheHit = true; + }, + (value) => { + value.data.inputsValidated = false; + }, + (value) => { + value.data.inputsTruncated = true; + }, + (value) => { + value.data.inputs.extra = 'unexpected'; + }, + (value) => { + value.data.durationMs = -1; + }, + (value) => { + value.data.durationMs = 0.5; + }, + ]) { + const invalid = event(); + mutate(invalid); + assert.throws(() => assertSuccessfulSetupEvent(invalid, expected)); + } + assert.throws(() => assertSuccessfulSetupEvent({}, expected)); +}); + +test('private runtime paths fail without echoing the private value', () => { + const invalid = event(); + invalid.detail = '/synthetic/private/tool-cache/commercekit'; + assert.throws( + () => + assertSuccessfulSetupEvent(invalid, { + ...expected, + privatePaths: ['/synthetic/private'], + }), + (error) => { + assert.equal( + error.message, + 'Setup event contains a private runtime path.', + ); + assert(!error.message.includes('/synthetic/private')); + return true; + }, + ); +}); + +test('the hosted verifier rejects either missing or malformed output with a safe diagnostic', () => { + for (const [name, raw] of [ + ['CK_FIRST_NOTIFICATION_EVENT', ''], + ['CK_FIRST_NOTIFICATION_EVENT', 'synthetic-private-value-not-json'], + ['CK_NOTIFICATION_EVENT', ''], + ['CK_NOTIFICATION_EVENT', 'synthetic-private-value-not-json'], + ]) { + const result = spawnSync(process.execPath, ['scripts/verify-action.mjs'], { + cwd: resolve(import.meta.dirname, '..'), + encoding: 'utf8', + env: { + ...process.env, + PATH: `${dirname(process.execPath)}${delimiter}${process.env.PATH ?? ''}`, + CK_VERSION: expected.version, + CK_PATH: process.execPath, + CK_TARGET: expected.target, + CK_EXPECTED_TARGET: expected.target, + CK_BUILD_ID: expected.buildId, + CK_CACHE_HIT: 'true', + CK_EXPECTED_CACHE_HIT: 'true', + CK_FIRST_CACHE_HIT: 'false', + CK_FIRST_NOTIFICATION_EVENT: JSON.stringify(event()), + CK_NOTIFICATION_EVENT: JSON.stringify(event(true)), + [name]: raw, + }, + }); + assert.equal(result.status, 1); + assert.match( + result.stderr, + /Setup notification output is missing or invalid JSON/, + ); + assert(!result.stderr.includes('synthetic-private-value-not-json')); + } +}); diff --git a/tests/tooling-dependencies.test.mjs b/tests/tooling-dependencies.test.mjs new file mode 100644 index 0000000..5a68e9f --- /dev/null +++ b/tests/tooling-dependencies.test.mjs @@ -0,0 +1,31 @@ +import assert from 'node:assert/strict'; +import { createRequire } from 'node:module'; +import { test } from 'node:test'; +import semver from 'semver'; + +const require = createRequire(import.meta.url); +const eslint = createRequire(require.resolve('eslint/package.json')); +const configArray = createRequire(eslint.resolve('@eslint/config-array')); +const typescriptEslint = createRequire( + require.resolve('typescript-eslint/package.json'), +); +const parser = createRequire( + typescriptEslint.resolve('@typescript-eslint/parser/package.json'), +); +const estree = createRequire( + parser.resolve('@typescript-eslint/typescript-estree/package.json'), +); + +test('all three development-only minimatch paths resolve the reviewed patched line', () => { + for (const [parent, resolveFrom] of [ + ['eslint', eslint], + ['@eslint/config-array', configArray], + ['@typescript-eslint/typescript-estree', estree], + ]) { + const { version } = resolveFrom('minimatch/package.json'); + assert( + semver.gte(version, '11.0.1'), + `${parent} resolved affected minimatch ${version}`, + ); + } +});