Skip to content

Commit 95c7c8b

Browse files
committed
Validate change files in PR checks
Assisted-By: devx/06090486-2b20-4fb8-99f0-cdf7db642619
1 parent 88ded38 commit 95c7c8b

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

scripts/pr.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import * as fs from "node:fs";
3333
import * as util from "node:util";
3434

35+
import { parseAllChangeFiles } from "./changes/changes.ts";
3536
import {
3637
addPrLabels,
3738
closePr,
@@ -96,6 +97,15 @@ pnpm run changes:add
9697
> Not every PR needs a change file — you can skip this step if the change is internal-only
9798
> (tests, tooling, docs)`;
9899

100+
const CHANGE_FILE_INVALID_COMMENT = `${CHANGE_FILE_MARKER}
101+
### ❌ Invalid Change Files
102+
103+
One or more change files are invalid. Run the following command locally for details:
104+
105+
\`\`\`sh
106+
pnpm changes:validate
107+
\`\`\``;
108+
99109
const CLOSE_FEATURE_PR_COMMENT = `\
100110
To align with our new [Open Governance](https://remix.run/blog/rr-governance) model, we are now asking that all new features go through the [Proposal/RFC process](https://github.com/remix-run/react-router/blob/main/GOVERNANCE.md#new-feature-process) and that we don't open PRs until a proposal has been accepted and advanced to Stage 1.
101111
@@ -274,6 +284,22 @@ async function changeFileCheck(ctx: CheckContext): Promise<CheckResult> {
274284
let body = CHANGE_FILE_MISSING_COMMENT;
275285

276286
if (summaries.length > 0) {
287+
let { valid } = parseAllChangeFiles();
288+
if (!valid) {
289+
console.log("changeFileCheck: invalid change files found");
290+
return {
291+
actions: [
292+
{
293+
type: "upsert-sticky-comment",
294+
marker: CHANGE_FILE_MARKER,
295+
body: CHANGE_FILE_INVALID_COMMENT,
296+
},
297+
],
298+
failureMessage:
299+
"Change file validation failed - please run `pnpm changes:validate` locally for details",
300+
};
301+
}
302+
277303
body = [
278304
CHANGE_FILE_FOUND_COMMENT,
279305
"| Type | Change |",

0 commit comments

Comments
 (0)