Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/actions/cleanup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run and validate cleanup dry-run
description: Exercise the pinned Cleanup Action with zero target mutations and validate its published event.
inputs:
attempt:
description: first or repeat; records must match across both invocations
required: true
runs:
using: composite
steps:
- name: Execute cleanup dry-run
id: action
continue-on-error: true
uses: commercekit-tools/ccv2-build-cleanup@4ab51d33ded51a360e8223e686bb46918cf7863f
with:
token-endpoint: ${{ env.CCV2_TOKEN_ENDPOINT }}
client-id: ${{ env.CCV2_CLIENT_ID }}
client-secret: ${{ env.CCV2_CLIENT_SECRET }}
resource: ${{ env.CCV2_RESOURCE }}
subscription-code: '131762872233634f29fdeb7d50983aa4'
application-code: commerce
api-base-url: https://ccv2.sandbox.commercekit.tools
retention-days: '30'
keep-latest: '10'
max-deletions: '20'
exclude-build-codes: cleanup-006
dry-run: 'true'
timeout-minutes: '2'
continue-on-delete-error: 'false'
- name: Validate cleanup outputs, event and observed mutation count
if: ${{ always() }}
shell: bash
run: node scripts/runner.mjs record-cleanup
env:
CLEANUP_ATTEMPT: ${{ inputs.attempt }}
OUTPUTS_JSON: ${{ toJSON(steps.action.outputs) }}
ACTION_OUTCOME: ${{ steps.action.outcome }}
140 changes: 140 additions & 0 deletions .github/workflows/build-approve-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Build, check and approve Sandbox deploy
on:
workflow_dispatch:
inputs:
confirmation:
description: Type RUN-COMMERCEKIT-SANDBOX-TESTS to create disposable Sandbox runs
type: string
required: true
permissions:
contents: read
packages: read
concurrency:
group: commercekit-action-integration
cancel-in-progress: false
jobs:
repository-build:
if: >-
github.repository == 'commercekit-tools/action-integration-tests' &&
github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' &&
inputs.confirmation == 'RUN-COMMERCEKIT-SANDBOX-TESTS'
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
packages: read
actions: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version-file: .node-version
registry-url: https://npm.pkg.github.com
scope: '@commercekit-tools'
- run: corepack enable
- run: pnpm install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build and validate the integration repository
run: pnpm quality
- name: Verify deployment approval is configured before any Sandbox run
run: node scripts/approval.mjs verify-environment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
commerce-check:
needs: repository-build
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Install verified CommerceKit CLI
uses: commercekit-tools/setup-commercekit@7f650f3162ab027bfd784cf879832f44d3248584
with:
version: '0.1.0-preview.2'
- name: Check the supported synthetic Commerce files
run: commercekit check fixtures/commerce --format github
cloud-build:
needs: commerce-check
runs-on: ubuntu-24.04
timeout-minutes: 10
outputs:
build-code: ${{ steps.handoff.outputs.build-code }}
env:
SCENARIO: rolling-success
PROVIDER: none
CONFIRMATION: ${{ inputs.confirmation }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Set private state directory for this job
run: printf 'STATE_DIRECTORY=%s/commercekit-integration\n' "$RUNNER_TEMP" >> "$GITHUB_ENV"
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version-file: .node-version
registry-url: https://npm.pkg.github.com
scope: '@commercekit-tools'
- run: corepack enable
- run: pnpm install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create disposable Sandbox build run
id: prepare
run: node scripts/runner.mjs prepare
- name: Execute and validate CCv2 Build Action
if: steps.prepare.outcome == 'success'
uses: ./.github/actions/build
- name: Export only the validated build identifier
id: handoff
run: node scripts/runner.mjs handoff-build
- name: Delete the completed build run and verify cleanup
if: ${{ always() }}
run: node scripts/runner.mjs cleanup
env:
STATE_DIRECTORY: ${{ runner.temp }}/commercekit-integration
deploy:
needs: cloud-build
runs-on: ubuntu-24.04
timeout-minutes: 10
environment: sandbox-deploy-approval
permissions:
contents: read
packages: read
actions: read
env:
SCENARIO: rolling-success
PROVIDER: none
CONFIRMATION: ${{ inputs.confirmation }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Set private state directory for this approved job
run: printf 'STATE_DIRECTORY=%s/commercekit-integration\n' "$RUNNER_TEMP" >> "$GITHUB_ENV"
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version-file: .node-version
registry-url: https://npm.pkg.github.com
scope: '@commercekit-tools'
- run: corepack enable
- run: pnpm install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Recheck approval protection before creating the deployment run
run: node scripts/approval.mjs verify-environment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Recreate the approved synthetic build in a fresh isolated run
id: prepare
run: node scripts/runner.mjs prepare-approved-deploy
env:
BUILT_BUILD_CODE: ${{ needs.cloud-build.outputs.build-code }}
- name: Deploy the approved synthetic build
if: steps.prepare.outcome == 'success'
uses: ./.github/actions/deploy
with:
phase: initial
- name: Assert approved deployment, its real result and event
if: ${{ always() && steps.prepare.outcome == 'success' }}
run: node scripts/runner.mjs assert-approved-deployment
- name: Delete the approved deployment run and verify cleanup
if: ${{ always() }}
run: node scripts/runner.mjs cleanup
env:
STATE_DIRECTORY: ${{ runner.temp }}/commercekit-integration
61 changes: 61 additions & 0 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Manual cleanup dry-run integration
on:
workflow_dispatch:
inputs:
confirmation:
description: Type RUN-COMMERCEKIT-SANDBOX-TESTS to create a disposable cleanup fixture
type: string
required: true
permissions:
contents: read
packages: read
concurrency:
group: commercekit-sandbox-cleanup
cancel-in-progress: false
jobs:
cleanup:
if: >-
github.repository == 'commercekit-tools/action-integration-tests' &&
github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' &&
inputs.confirmation == 'RUN-COMMERCEKIT-SANDBOX-TESTS'
runs-on: ubuntu-24.04
timeout-minutes: 15
environment: sandbox-e2e
env:
SCENARIO: cleanup-dry-run
PROVIDER: none
CONFIRMATION: ${{ inputs.confirmation }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Set private state directory for this job
run: printf 'STATE_DIRECTORY=%s/commercekit-cleanup-integration\n' "$RUNNER_TEMP" >> "$GITHUB_ENV"
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version-file: .node-version
registry-url: https://npm.pkg.github.com
scope: '@commercekit-tools'
- run: corepack enable
- run: pnpm install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create and seed one isolated cleanup fixture
id: prepare
run: node scripts/runner.mjs prepare
- name: Validate initial cleanup dry-run
if: steps.prepare.outcome == 'success'
uses: ./.github/actions/cleanup
with:
attempt: first
- name: Validate repeated cleanup dry-run
if: steps.prepare.outcome == 'success'
uses: ./.github/actions/cleanup
with:
attempt: repeat
- name: Assert unchanged inventory and zero target API mutations
if: ${{ always() && steps.prepare.outcome == 'success' }}
run: node scripts/runner.mjs assert-cleanup
- name: Delete disposable run and verify cleanup
if: ${{ always() }}
run: node scripts/runner.mjs cleanup
env:
STATE_DIRECTORY: ${{ runner.temp }}/commercekit-cleanup-integration
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CommerceKit Action Integration Tests

Integration coverage for the CommerceKit Build → Deploy → Notify flow against the
public CCv2 Sandbox. This repository executes the actual, SHA-pinned Actions and
public CCv2 Sandbox, including an approval-gated synthetic deploy and cleanup dry-run. This repository executes the actual, SHA-pinned Actions and
uses their real outputs; it does not replace them with test implementations.

Each scenario creates one disposable Sandbox run, runs the Build Action, passes
Expand All @@ -24,6 +24,31 @@ Start with [setup and dispatch](docs/SETUP.md). The [scenario reference](docs/SC
defines expected negative outcomes and required assertions. Passing offline CI is
not evidence that live Sandbox scenarios or provider delivery have passed.

## Additional manual workflows

| Workflow | Order and effect |
| ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [build-approve-deploy.yml](.github/workflows/build-approve-deploy.yml) | Repository quality gate → CommerceKit check of three synthetic files → actual CCv2 Build Action → required approval → recreate the validated build in a fresh Sandbox run → actual Deploy Action |
| [cleanup.yml](.github/workflows/cleanup.yml) | Create an isolated 105-build fixture → actual Cleanup Action in hardcoded dry-run → repeat and compare → verify zero target mutations → remove the run |

Both require a deliberate main-branch dispatch and
`RUN-COMMERCEKIT-SANDBOX-TESTS`. They have no schedule, real SAP credentials,
provider sends, publication or release steps. The approval environment is
`sandbox-deploy-approval`: reviewer `anilkreddy`, own-run approval allowed, main
only, administrator bypass disabled. Its settings are verified before the build
and again before preparing the approved deployment run.

The repository stage runs this JavaScript harness's existing `pnpm quality` gate;
it does not compile a customer Commerce application. CommerceKit CLI
`0.1.0-preview.2` checks real supported fixture files. Only a validated build code
crosses jobs; source-run credentials are never exported or uploaded. Approval
starts a fresh synthetic run, with the source code mapped to an `approved-...`
fixture identifier because the Sandbox fixture API does not accept dots in keys.

See [workflow setup, dispatch and limits](docs/WORKFLOWS.md). In particular,
merged Sandbox source does not prove that the hosted `/cleanup-fixture` endpoint
is deployed. Live workflow results are recorded separately from offline tests.

## Development

Use Node 24 and pnpm 12.6.0, then configure local GitHub Packages read access as
Expand All @@ -37,9 +62,10 @@ pnpm quality

Shared schema validation and CCv2 HTTP/authentication come from the existing
`@commercekit-tools/notification-contract` and `@commercekit-tools/ccv2-client`
packages, pinned to `0.0.3`. These package versions are separate from Action
versions. Actual Action pins live once each in the composite wrappers under
`.github/actions/`.
packages, pinned to `0.0.4` and `0.0.3` respectively. These package versions are separate from Action
versions. Action revisions are catalogued in `action-refs.json`. Producer pins live in
the composite wrappers under `.github/actions/`; CLI setup is pinned in the
build/approval workflow.

See [Contributing](CONTRIBUTING.md), [agent guidance](AGENTS.md), and the
[security policy](SECURITY.md) before changing the harness.
4 changes: 3 additions & 1 deletion action-refs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"actions/setup-node": "949feb2413d6458794dcd2491c4babbbce0c15c1",
"commercekit-tools/ccv2-build": "923535d589bd8cebece4f3cbf479608f9535c4c3",
"commercekit-tools/ccv2-deploy": "e2b3f4cb7e03bfbcbba22eaf84545829b5629557",
"commercekit-tools/notify": "8242af6a4aaafd7917c93f0db27f1794266efeee"
"commercekit-tools/notify": "8242af6a4aaafd7917c93f0db27f1794266efeee",
"commercekit-tools/ccv2-build-cleanup": "4ab51d33ded51a360e8223e686bb46918cf7863f",
"commercekit-tools/setup-commercekit": "7f650f3162ab027bfd784cf879832f44d3248584"
}
22 changes: 22 additions & 0 deletions docs/SCENARIOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,25 @@ The provider suite additionally verifies webhook acceptance of actual producer
events. Representative Slack/Teams visual inspection and a separate owner
decision are still required before releasing the Actions. Initial repository
creation alone is not evidence that any live suite ran.

## Standalone cleanup fixture

The separate manual `cleanup.yml` workflow uses `cleanup-dry-run`; it does not
extend the existing 16-entry full suite or send provider messages. Its shared
catalog seeds 105 builds (two listing pages) and three current/active deployment
references. It includes old/recent completions, latest-count protection, a
start-time tie, deployed/snapshot/excluded/active/unknown/deletion-marked builds,
a missing timestamp and an old completion with recent internal modification.

The current production-shaped cleanup adapter cannot verify SAP four-hour
eligibility. Expected result: `blocked`, `dryRun=true`, 105 scanned/skipped,
13 protected dispositions, zero eligible/planned/requested/failed/unknown/deferred.
Every exact per-build reason set and the shared cleanup notification are checked;
reason categories overlap. `blocked` in dry-run is a handled successful Action
execution with a shared failure-status notification, not a deletion.

A second invocation must preserve counts/decisions. Observed target API counters
must contain only supported reads/authentication, and listing counters must prove
both pages across both discovery passes for each invocation. Fixture creation and
run removal are control-plane operations, counted separately from target API
mutations. The final always-run step removes the disposable run and verifies404.
12 changes: 10 additions & 2 deletions docs/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ commits. This setup does not deploy the Sandbox or release any Action.
3. Allow the declared `contents: read` and `packages: read` job permissions. The
workflows need no contents-write, release, or package-publish permission.
4. In each shared package's **Manage Actions access**, grant this repository
**Read** access to `notification-contract` and `ccv2-client`. Both are pinned
exactly to `0.0.3`. A successful install with an owner's local credential does
**Read** access to `notification-contract` and `ccv2-client`. The contract is pinned
exactly to `0.0.4` and the client to `0.0.3`. A successful install with an owner's local credential does
not prove the repository's workflow token has package access.
5. Create/configure the environments below before the first live dispatch.

Expand Down Expand Up @@ -186,3 +186,11 @@ This repository has no Marketplace, Action-tagging, GitHub Release, or package
publication workflow. Its token permissions are read-only. Passing tests here
does not release Notify, Build, or Deploy; release remains a separate decision in
their owning repositories.

## Approval-gated build/deploy and cleanup

The additional `build-approve-deploy.yml` and `cleanup.yml` workflows are manual,
main-only Sandbox integrations. Their exact order, native approval environment,
synthetic handoff, cleanup expectations and dispatch commands are in
[WORKFLOWS.md](WORKFLOWS.md). No permanent SAP or Sandbox secrets are required.
The existing smoke/full/provider suites and their environments remain unchanged.
Loading