Skip to content

verify-action-build: support .cjs and .mjs compiled bundles#734

Merged
dave2wave merged 1 commit intomainfrom
verify-action-cjs-mjs-support
Apr 18, 2026
Merged

verify-action-build: support .cjs and .mjs compiled bundles#734
dave2wave merged 1 commit intomainfrom
verify-action-cjs-mjs-support

Conversation

@potiuk
Copy link
Copy Markdown
Member

@potiuk potiuk commented Apr 18, 2026

Summary

Motivated by Dependabot PR #720 bumping JustinBeckwith/linkinator-action to v2.4.2. That action declares main: dist/index.cjs in action.yml and its npm run build invokes esbuild with --format=cjs --outfile=dist/index.cjs. Our verify-action-build pipeline only recognized *.js, so for any .cjs/.mjs bundle it:

  • did not delete the published file before rebuild (a broken rebuild silently leaves the original in place), and
  • reported "No compiled JavaScript found" from diff_js_files, skipping the original-vs-rebuilt comparison entirely.

Changes

  • utils/verify_action_build/dockerfiles/build_action.Dockerfile
    • Pre-rebuild delete step now matches *.js, *.cjs, *.mjs.
    • has_output() probe that decides whether to try the next build step now recognizes all three extensions.
  • utils/verify_action_build/diff_js.py
    • New _collect_compiled_js(base) helper scans *.js, *.cjs, *.mjs.
    • diff_js_files uses the helper.
  • utils/tests/verify_action_build/test_diff_js.py
    • 3 new tests: mixed extensions, empty dir, nested output (dist/sub/main/index.cjs — the gradle/actions-style monorepo shape).

How dist/index.cjs is rebuilt

linkinator-action's package.json has \"type\": \"module\" and:

\"build\": \"esbuild src/index.js --bundle --platform=node --format=cjs --outfile=dist/index.cjs --sourcemap\"

So when the Dockerfile runs npm run build inside the build dir, esbuild emits dist/index.cjs (+ dist/index.cjs.map). With the old find ... -name '*.js' guard the rebuild step's has_output returned false after esbuild succeeded, causing the Dockerfile to fall through to the npx ncc build --source-map fallback — which either failed or produced dist/index.js, something the action never ships. With this change the esbuild output is recognized as the final build artifact and compared directly against the committed dist/index.cjs.

Test plan

🤖 Generated with Claude Code

@potiuk
Copy link
Copy Markdown
Member Author

potiuk commented Apr 18, 2026

needs #735

The Dockerfile that rebuilds an action's bundle and diff_js only looked
for *.js. Actions bundled with esbuild or rollup often emit dist/index.cjs
(when the source package declares "type": "module" and needs a CommonJS
bundle for the node runner — JustinBeckwith/linkinator-action v2.4.2 is
the current trigger) or dist/index.mjs. For those actions the current
pipeline both skips deleting the published bundle before rebuild (so a
broken build is masked by the leftover file) and reports "No compiled
JavaScript found" because the comparison walks only *.js.

Extend the pre-rebuild delete step and the has_output probe in
build_action.Dockerfile to cover *.js, *.cjs and *.mjs, and factor the
file-collection in diff_js.py into a _collect_compiled_js helper that
scans all three extensions. Add unit tests covering the helper including
nested output directories (e.g. dist/sub/main/index.cjs).

Generated-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@potiuk potiuk force-pushed the verify-action-cjs-mjs-support branch from 3f56836 to 66ff315 Compare April 18, 2026 20:52
@potiuk
Copy link
Copy Markdown
Member Author

potiuk commented Apr 18, 2026

Looks good now - needs approval

Copy link
Copy Markdown
Member

@dave2wave dave2wave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dave2wave dave2wave merged commit e0f0ac7 into main Apr 18, 2026
10 checks passed
@dave2wave dave2wave deleted the verify-action-cjs-mjs-support branch April 18, 2026 21:25
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.

2 participants