Skip to content

feat(scripts): run test.prepare before deploy and test.cleanup after remove in live tests - #830

Merged
czubocha merged 1 commit into
v4from
test-prepare-cleanup-hooks
Nov 24, 2026
Merged

czubocha merged 1 commit into
v4from
test-prepare-cleanup-hooks

Conversation

@czubocha

Copy link
Copy Markdown
Contributor

Summary

  • example.json accepts test.prepare and test.cleanup, each { "path": "<Node.js script>" }. test.cleanup needs test.prepare.
  • scripts/test-example.mjs runs the prepare script after install and before deploy. It runs the cleanup script after remove whenever prepare started: also after a failed step or an interruption (with its own 10-minute deadline and no signal, like remove), and in --remove-only runs, also when nothing was deployed. Both run with node in the copy, with EXAMPLE_STAGE, EXAMPLE_REGION and EXAMPLE_DIR set.
  • A failed prepare is the prepare step: nothing is deployed and cleanup still runs. A failed cleanup is the cleanup step when everything else passed; otherwise its error is added to the detail of the first failed step.
  • The check-paths static check reports missing prepare and cleanup scripts. AGENTS.md describes the hooks.

This is for examples that need something CloudFormation can't create before the deploy. The first one is aws-node-customer-managed-runtime, whose runtime version needs its container image in ECR before the stack is created. Its PR builds on this branch.

Test plan

  • npm test: 323 pass, including new runner tests for the order of steps, the hook environment, a failed prepare, a failed install, cleanup after a failed check, a failed cleanup after a pass, an interruption during prepare, and --remove-only with and without a deployed stack. Also new manifest and static-check tests.
  • npm run docs and check-examples.mjs on the first example that uses the hooks: 0 errors.
  • Live tests in a development account with that example: prepare pushed the image, cleanup deleted the repository after a pass, after a failed deploy and after a failed check.

Generated by Claude Code

@czubocha
czubocha merged commit 7cf6d10 into v4 Nov 24, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant