refactor(ci): extract shared helpers from description-check scripts#5486
Open
rudra496 wants to merge 1 commit into
Open
refactor(ci): extract shared helpers from description-check scripts#5486rudra496 wants to merge 1 commit into
rudra496 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The two description-check scripts —
check-pr-description.jsandcheck-issue-description.js— had three near-identical blocks of logic copied between them: markdown section extraction, fail-soft label management, and find-by-marker comment upsert/delete. Every fix had to be made twice, and the two copies had already drifted (the issue script escaped?inAre you willing to implement this?as\\?while the PR script didn't).This PR extracts the shared logic into
.github/scripts/lib/:markdown.js—strip(text)andsection(body, heading).sectionescapes regex specials in the heading internally so callers pass plain text (e.g.Are you willing to implement this?without pre-escaping the?). This fixes the drift — both scripts now use the same escaping.labels.js—labelExists/addLabel/dropLabel/swapLabel, preserving the existing fail-soft discipline (never auto-create; warn and skip when absent).comment.js—findComment/upsertComment/deleteComment(find-by-marker, paginated lookup).Both check scripts now
require()these helpers instead of carrying their own copies. No behaviour change — the same API calls are made in the same order with the same fail-soft handling.Target branch
dev, notmain.Linked Issue
Fixes #2453
Type of Change
Checklist
devnode --checkon all 5 files (2 scripts + 3 lib modules) — all pass.How to Test
node --check .github/scripts/check-pr-description.js— passes.node --check .github/scripts/check-issue-description.js— passes.node --check .github/scripts/lib/markdown.js && node --check .github/scripts/lib/labels.js && node --check .github/scripts/lib/comment.js— all pass.ci.yml→ "Check PR description" andissue-description-check.yml→ "Check Issue description") will exercise the refactored code on this PR itself.Visual / UI changes — REQUIRED if you touched anything that renders
Not applicable: CI/automation scripts only.