Skip to content

feat: include package.json files in code bundle cache hash#364

Merged
sorccu merged 2 commits intomainfrom
simo/sim-226-tf-include-all-packagejson-files-in-the-code-bundle-cache
Apr 20, 2026
Merged

feat: include package.json files in code bundle cache hash#364
sorccu merged 2 commits intomainfrom
simo/sim-226-tf-include-all-packagejson-files-in-the-code-bundle-cache

Conversation

@sorccu
Copy link
Copy Markdown
Member

@sorccu sorccu commented Apr 15, 2026

Summary

  • Extends the Playwright code bundle CacheHash to cover every package.json outside node_modules/ (at any depth) in addition to the lockfile, so dependency changes declared only in a package.json correctly invalidate the cache.
  • Canonicalizes each package.json (parse, strip top-level version, re-marshal with sorted keys) before hashing so cosmetic differences and CI-driven version bumps — e.g. auto-stamped commit-hash versions — don't churn the cache.
  • Renames PlaywrightCodeBundleMetadata.LockfileChecksumCacheHash (and JSON tag lcsch), and bumps the metadata version to 4 so existing resources recompute on first plan after upgrade.

Notes for reviewers

  • InspectLockfile gained an InspectLockfileOptions{PackageJSONExcludedFields} parameter. The production caller passes []string{"version"}.
  • Final checksum = SHA-256 of length-prefixed records: lockfile:<name> + lockfile hash, then each canonical package.json sorted by path.
  • Metadata version bump to 4 means Terraform will replace (and re-upload) existing checkly_playwright_code_bundle resources on next plan after upgrade — this is intentional, to get everyone onto the new hash.

Test plan

  • go test ./checkly -run TestInspectLockfile — all pre-existing + 6 new subtests pass.
  • Acceptance tests to confirm no regression in the full bundle flow.
  • Manual check: modify only version in a bundle's package.json, confirm no diff on terraform plan; modify another field (e.g. scripts), confirm a replacement is planned.

🤖 Generated with Claude Code

Extend the cache hash to cover every package.json outside node_modules
in addition to the lockfile. Each package.json is canonicalized (parsed,
top-level "version" stripped, re-marshaled with sorted keys) before
hashing, so cosmetic or CI-driven version bumps don't invalidate the
cache. Rename PlaywrightCodeBundleMetadata.LockfileChecksum to CacheHash
and bump metadata version to 4 so existing resources recompute on
upgrade.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sorccu sorccu force-pushed the simo/sim-226-tf-include-all-packagejson-files-in-the-code-bundle-cache branch from c02151d to c77984e Compare April 20, 2026 16:47
@sorccu sorccu merged commit 3c69bfc into main Apr 20, 2026
6 checks passed
@sorccu sorccu deleted the simo/sim-226-tf-include-all-packagejson-files-in-the-code-bundle-cache branch April 20, 2026 17:05
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