Skip to content

Migrate changetool to pr-checks - #4128

Open
mbg wants to merge 3 commits into
mainfrom
mbg/move-changetool
Open

Migrate changetool to pr-checks#4128
mbg wants to merge 3 commits into
mainfrom
mbg/move-changetool

Conversation

@mbg

@mbg mbg commented Sep 9, 2026

Copy link
Copy Markdown
Member

Follow-up to discussion on #4116 which migrates scripts/changetool from its own project to the common pr-checks project to avoid duplicated infrastructure.

Although changetool's two unique dependencies are ESM-only, we simply use the .mts extension for the migrated source files to avoid switching all of pr-checks over to ESM, which would require other modifications.

Risk assessment

For internal use only. Please select the risk level of this change:

  • Low risk: Changes are fully under feature flags, or have been fully tested and validated in pre-production environments and are highly observable, or are documentation or test only.

Which use cases does this change impact?

Environments:

  • Testing/None - This change does not impact any CodeQL workflows in production.

How did/will you validate this change?

  • Unit tests - I am depending on unit test coverage (i.e. tests in .test.ts files).
  • End-to-end tests - I am depending on PR checks (i.e. tests in pr-checks).

If something goes wrong after this change is released, what are the mitigation and rollback strategies?

  • Development/testing only - This change cannot cause any failures in production.

How will you know if something goes wrong after this change is released?

  • Other - Please provide details.

Are there any special considerations for merging or releasing this change?

  • No special considerations - This change can be merged at any time.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.

@github-actions github-actions Bot added the size/M Should be of average difficulty to review label Sep 9, 2026
Comment thread pr-checks/changelog/validate.mts Fixed
@mbg
mbg force-pushed the mbg/move-changetool branch from 19e9e17 to d235931 Compare September 9, 2026 10:44
@mbg
mbg marked this pull request as ready for review September 9, 2026 10:47
Copilot AI balanced review requested due to automatic review settings September 9, 2026 10:48
@mbg
mbg requested a review from a team as a code owner September 9, 2026 10:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The migration preserves existing behavior, consolidates infrastructure cleanly, and passes the relevant tests and checks.

Review tier: Balanced
Findings: None

What changed in this PR

Migrates changetool into the shared pr-checks workspace while retaining ESM compatibility through .mts files.

Changes:

  • Relocates changelog validation code and tests.
  • Consolidates dependencies and TypeScript/ESLint configuration.
  • Runs migrated tests through the existing PR-checks job.
File Description
.github/​workflows/​pr-checks.yml Removes the redundant changetool test job.
eslint.config.mjs Applies PR-checks linting to .mts files.
package-lock.json Updates workspace and dependency resolution.
package.json Removes the separate changetool workspace.
pr-checks/​changelog/​validate.mts Relocates changelog validation logic.
pr-checks/​changelog/​validate.test.mts Relocates and adapts validation tests.
pr-checks/​package.json Adds changetool dependencies.
pr-checks/​tsconfig.json Includes nested TypeScript and .mts sources.
pr-checks/​validate-changelog.mts Relocates and renames the CLI entry point.
scripts/​changetool/​package.json Removes the obsolete standalone package.
scripts/​changetool/​tsconfig.json Removes the obsolete standalone configuration.
tsconfig.json Removes the deleted project from exclusions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

const filePath = path.join(tmpDir, baseFileName);
fs.writeFileSync(filePath, contents);
return await body(filePath);
return await Promise.resolve(body(filePath));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't this addition redundant and unnecessary? await will already resolve any Promise returned from body, so it's effectively the same as:

return await body(filePath);

But, also—now that I look closer—body (currently) never returns anything, so we can simplify it further:

Suggested change
return await Promise.resolve(body(filePath));
body(filePath);

Which means withTmpFile nor its anonymous body functions no longer need be async.

baseFileName: string,
contents: string,
body: (filePath: string) => Promise<T>,
body: (filePath: string) => Promise<T> | T,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since none of the body instances ever return anything, this can be simplified to:

Suggested change
body: (filePath: string) => Promise<T> | T,
body: (filePath: string) => void,

"2026-01-01-fix-bug.md",
"---\ncategory: fix\n---\n- Fixed a bug\n",
async (filePath) => {
(filePath) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change and the other similar ones below are not necessary with the noted simplifications to withTmpFile.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FYI, this script/tool will also be used for more than just validation, so I wouldn't narrow the name to that singular purpose, but it's fine for now. It can be changed later, if need be.

@mario-campos

Copy link
Copy Markdown
Contributor

BTW, Thanks for putting this together for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Should be of average difficulty to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants