fix: remove auto-execution from library sub-modules bundled into mention-reply#178
Conversation
…ion-reply
When tsup bundles dist/mention-reply.js it inlines add-reaction,
check-org-membership, get-pr-meta, and post-comment. Each had a top-level
if (!process.env.VITEST) { run().catch(...) } guard that fired on bundle
load, calling core.getInput('owner', { required: true }) etc. — inputs that
are not set in the mention-reply action context — causing the job to fail.
None of these four modules are used as standalone GitHub Action entrypoints;
they are pure library helpers. Remove the auto-execution block and dead run()
function from each, and drop the now-unused `import * as core` from the
three modules that no longer need it.
Also upgrade .github/actions/mention-reply/action.yml from node20 to node24.
Assisted-By: docker-agent
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
This PR correctly diagnoses and fixes the 'Input required and not supplied' failures in the mention-reply action.
Root cause (confirmed correct): src/mention-reply/index.ts imports from add-reaction, check-org-membership, get-pr-meta, and post-comment. Because tsup bundles with splitting: false and noExternal: [/.*/], all four sub-modules' code is inlined into dist/mention-reply.js. When GitHub Actions loads that file, Node.js executes every top-level statement — including the if (!process.env.VITEST) { run() } blocks from each sub-module, which immediately called core.getInput('owner', { required: true }) etc., triggering the errors.
Changes reviewed:
- ✅
add-reaction/index.ts— standalonerun()entrypoint removed; no action.yml references this bundle directly - ✅
check-org-membership/index.ts— standalone entrypoint + now-unused@actions/coreimport removed; exportedcheckOrgMembershipfunction is unaffected - ✅
get-pr-meta/index.ts— same pattern;getPrMetafunction unaffected - ✅
post-comment/index.ts— same pattern;postCommentfunction unaffected - ✅
.github/actions/mention-reply/action.yml—node20→node24aligns the runner with the tsup build target; GitHub Actions has supportednode24since runner v2.316.1+
No standalone action.yml files exist for the four modified sub-modules, so removing their run() entrypoints does not break any existing invocations.
|
❌ PR Review Failed — The review agent encountered an error and could not complete the review. View logs. |
Problem
When
tsupbundlesdist/mention-reply.js, it inlines the four library sub-modules (add-reaction,check-org-membership,get-pr-meta,post-comment). Each had a top-level auto-execution block:When the runner loads the bundle, all four standalone
run()functions fire — not justmention-reply's. They callcore.getInput('owner', { required: true })etc., inputs that aren't set in themention-replycontext, causing:Failing run: https://github.com/docker/gordon/actions/runs/25450919377/job/74667539670
Fix
run()function definition from each of the four library sub-modules. None are used as standalone GitHub Action entrypoints — they are pure library helpers bundled only to remain individually testable/usable.import * as corefrom the three modules that no longer referencecoreat all (check-org-membership,get-pr-meta,post-comment)..github/actions/mention-reply/action.ymlfromnode20tonode24(deprecation warning fix).Testing
pnpm build && pnpm test && pnpm lintall pass (biome + tsc clean, 100/100 unit tests pass;actionlintis not available in the sandbox but the only YAML change is the well-knownnode20→node24runtime value).