Improve get preview channel changes script
- Filter out N/As - Identify missing release note lines Co-Authored-By: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
This commit is contained in:
parent
9e5a4ea6c4
commit
e6bda025a3
1 changed files with 39 additions and 24 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const { execFileSync } = require("child_process");
|
const { execFileSync } = require("child_process");
|
||||||
const { GITHUB_ACCESS_TOKEN } = process.env;
|
const { GITHUB_ACCESS_TOKEN } = process.env;
|
||||||
const PR_REGEX = /#\d+/ // Ex: matches on #4241
|
const PR_REGEX = /#\d+/; // Ex: matches on #4241
|
||||||
const FIXES_REGEX = /(fixes|closes|completes) (.+[/#]\d+.*)$/im;
|
const FIXES_REGEX = /(fixes|closes|completes) (.+[/#]\d+.*)$/im;
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
@ -12,7 +12,7 @@ async function main() {
|
||||||
const [newTag, oldTag] = execFileSync(
|
const [newTag, oldTag] = execFileSync(
|
||||||
"git",
|
"git",
|
||||||
["tag", "--sort", "-committerdate"],
|
["tag", "--sort", "-committerdate"],
|
||||||
{ encoding: "utf8" }
|
{ encoding: "utf8" },
|
||||||
)
|
)
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.filter((t) => t.startsWith("v") && t.endsWith("-pre"));
|
.filter((t) => t.startsWith("v") && t.endsWith("-pre"));
|
||||||
|
@ -22,13 +22,22 @@ async function main() {
|
||||||
|
|
||||||
let hasProtocolChanges = false;
|
let hasProtocolChanges = false;
|
||||||
try {
|
try {
|
||||||
execFileSync("git", ["diff", oldTag, newTag, "--exit-code", "--", "crates/rpc"]).status != 0;
|
execFileSync("git", [
|
||||||
|
"diff",
|
||||||
|
oldTag,
|
||||||
|
newTag,
|
||||||
|
"--exit-code",
|
||||||
|
"--",
|
||||||
|
"crates/rpc",
|
||||||
|
]).status != 0;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
hasProtocolChanges = true;
|
hasProtocolChanges = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasProtocolChanges) {
|
if (hasProtocolChanges) {
|
||||||
console.warn("\033[31;1;4mRPC protocol changes, server should be re-deployed\033[0m\n");
|
console.warn(
|
||||||
|
"\033[31;1;4mRPC protocol changes, server should be re-deployed\033[0m\n",
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log("No RPC protocol changes\n");
|
console.log("No RPC protocol changes\n");
|
||||||
}
|
}
|
||||||
|
@ -37,10 +46,14 @@ async function main() {
|
||||||
const pullRequestNumbers = getPullRequestNumbers(oldTag, newTag);
|
const pullRequestNumbers = getPullRequestNumbers(oldTag, newTag);
|
||||||
|
|
||||||
// Get the PRs that were cherry-picked between main and the old tag.
|
// Get the PRs that were cherry-picked between main and the old tag.
|
||||||
const existingPullRequestNumbers = new Set(getPullRequestNumbers("main", oldTag));
|
const existingPullRequestNumbers = new Set(
|
||||||
|
getPullRequestNumbers("main", oldTag),
|
||||||
|
);
|
||||||
|
|
||||||
// Filter out those existing PRs from the set of new PRs.
|
// Filter out those existing PRs from the set of new PRs.
|
||||||
const newPullRequestNumbers = pullRequestNumbers.filter(number => !existingPullRequestNumbers.has(number));
|
const newPullRequestNumbers = pullRequestNumbers.filter(
|
||||||
|
(number) => !existingPullRequestNumbers.has(number),
|
||||||
|
);
|
||||||
|
|
||||||
// Fetch the pull requests from the GitHub API.
|
// Fetch the pull requests from the GitHub API.
|
||||||
console.log("Merged Pull requests:");
|
console.log("Merged Pull requests:");
|
||||||
|
@ -56,6 +69,16 @@ async function main() {
|
||||||
|
|
||||||
// Print the pull request title and URL.
|
// Print the pull request title and URL.
|
||||||
const pullRequest = await response.json();
|
const pullRequest = await response.json();
|
||||||
|
const releaseNotesHeader = /^\s*(?:Release )?Notes\s*:(.+)/ims;
|
||||||
|
|
||||||
|
let releaseNotes = pullRequest.body || "";
|
||||||
|
const captures = releaseNotesHeader.exec(releaseNotes);
|
||||||
|
const notes = captures ? captures[1] : "MISSING";
|
||||||
|
const skippableNoteRegex = /^\s*-?\s*n\/?a\s*/ims;
|
||||||
|
|
||||||
|
if (skippableNoteRegex.exec(notes) != null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
console.log("*", pullRequest.title);
|
console.log("*", pullRequest.title);
|
||||||
console.log(" PR URL: ", webURL);
|
console.log(" PR URL: ", webURL);
|
||||||
|
|
||||||
|
@ -66,38 +89,30 @@ async function main() {
|
||||||
console.log(" Issue URL: ", fixedIssueURL);
|
console.log(" Issue URL: ", fixedIssueURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
let releaseNotes = (pullRequest.body || "").split("Release Notes:")[1];
|
releaseNotes = notes.trim().split("\n");
|
||||||
|
console.log(" Release Notes:");
|
||||||
|
|
||||||
if (releaseNotes) {
|
for (const line of releaseNotes) {
|
||||||
releaseNotes = releaseNotes.trim().split("\n")
|
console.log(` ${line}`);
|
||||||
console.log(" Release Notes:");
|
|
||||||
|
|
||||||
for (const line of releaseNotes) {
|
|
||||||
console.log(` ${line}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log()
|
console.log();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPullRequestNumbers(oldTag, newTag) {
|
function getPullRequestNumbers(oldTag, newTag) {
|
||||||
const pullRequestNumbers = execFileSync(
|
const pullRequestNumbers = execFileSync(
|
||||||
"git",
|
"git",
|
||||||
[
|
["log", `${oldTag}..${newTag}`, "--oneline"],
|
||||||
"log",
|
{ encoding: "utf8" },
|
||||||
`${oldTag}..${newTag}`,
|
|
||||||
"--oneline"
|
|
||||||
],
|
|
||||||
{ encoding: "utf8" }
|
|
||||||
)
|
)
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.filter(line => line.length > 0)
|
.filter((line) => line.length > 0)
|
||||||
.map(line => {
|
.map((line) => {
|
||||||
const match = line.match(/#(\d+)/);
|
const match = line.match(/#(\d+)/);
|
||||||
return match ? match[1] : null;
|
return match ? match[1] : null;
|
||||||
})
|
})
|
||||||
.filter(line => line);
|
.filter((line) => line);
|
||||||
|
|
||||||
return pullRequestNumbers;
|
return pullRequestNumbers;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue