Update user test baseline script to diff against a single authoratative WIP master branch (like RWC) (#37350)

This commit is contained in:
Wesley Wigham 2020-03-11 14:38:59 -07:00 committed by GitHub
parent 1a9c8197ff
commit bacfda4ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,28 +12,35 @@ function padNum(num: number) {
const userName = process.env.GH_USERNAME;
const reviewers = process.env.REQUESTING_USER ? [process.env.REQUESTING_USER] : ["weswigham", "sandersn", "RyanCavanaugh"];
const now = new Date();
const branchName = `user-update-${process.env.TARGET_FORK}-${now.getFullYear()}${padNum(now.getMonth() + 1)}${padNum(now.getDate())}${process.env.TARGET_BRANCH ? "-" + process.env.TARGET_BRANCH : ""}`;
const masterBranchname = `user-baseline-updates`;
const branchName = process.env.TARGET_FORK.toLowerCase() === "microsoft" && (process.env.TARGET_BRANCH || "master") === "master"
? masterBranchname
: `user-update-${process.env.TARGET_FORK}-${now.getFullYear()}${padNum(now.getMonth() + 1)}${padNum(now.getDate())}${process.env.TARGET_BRANCH ? "-" + process.env.TARGET_BRANCH : ""}`;
const remoteUrl = `https://${process.argv[2]}@github.com/${userName}/TypeScript.git`;
const baseRef = branchName === masterBranchname ? "master" : masterBranchname;
runSequence([
["git", ["remote", "add", "fork", remoteUrl]], // Add the remote fork
["git", ["checkout", "."]], // reset any changes
["git", ["fetch", baseRef === "master" ? "origin" : "fork", baseRef]], // fetch target ref in case it's not present locally
["git", ["checkout", baseRef]], // move head to target
["node", ["./node_modules/gulp/bin/gulp.js", "baseline-accept"]], // accept baselines
["git", ["checkout", "-b", branchName]], // create a branch
["git", ["add", "."]], // Add all changes
["git", ["commit", "-m", `"Update user baselines"`]], // Commit all changes
["git", ["remote", "add", "fork", remoteUrl]], // Add the remote fork
["git", ["push", "--set-upstream", "fork", branchName, "-f"]] // push the branch
]);
const gh = new Octokit({
auth: process.argv[2]
});
const prOwner = branchName === masterBranchname ? "microsoft" : userName;
gh.pulls.create({
owner: process.env.TARGET_FORK!,
owner: prOwner,
repo: "TypeScript",
maintainer_can_modify: true,
title: `🤖 User test baselines have changed` + (process.env.TARGET_BRANCH ? ` for ${process.env.TARGET_BRANCH}` : ""),
head: `${userName}:${branchName}`,
base: process.env.TARGET_BRANCH || "master",
base: branchName === masterBranchname ? "master" : masterBranchname,
body:
`${process.env.SOURCE_ISSUE ? `This test run was triggerd by a request on https://github.com/Microsoft/TypeScript/pull/${process.env.SOURCE_ISSUE} `+"\n" : ""}Please review the diff and merge if no changes are unexpected.
You can view the build log [here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary).
@ -44,7 +51,7 @@ cc ${reviewers.map(r => "@" + r).join(" ")}`,
console.log(`Pull request ${num} created.`);
if (!process.env.SOURCE_ISSUE) {
await gh.pulls.createReviewRequest({
owner: process.env.TARGET_FORK!,
owner: prOwner,
repo: "TypeScript",
pull_number: num,
reviewers,
@ -53,7 +60,7 @@ cc ${reviewers.map(r => "@" + r).join(" ")}`,
else {
await gh.issues.createComment({
issue_number: +process.env.SOURCE_ISSUE,
owner: "Microsoft",
owner: "microsoft",
repo: "TypeScript",
body: `The user suite test run you requested has finished and _failed_. I've opened a [PR with the baseline diff from master](${r.data.html_url}).`
});