Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve backport experience #7

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions src/backport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const getFailedBackportCommentBody = ({
}) => {
const worktreePath = `.worktrees/backport-${base}`;
return [
`The backport to \`${base}\` failed:`,
`The backport to \`${base}\` failed at ${runUrl}:`,
"```",
errorMessage,
"```",
Expand All @@ -191,10 +191,22 @@ const getFailedBackportCommentBody = ({
"# Delete the working tree",
`git worktree remove ${worktreePath}`,
"```",
`Then, create a pull request where the \`base\` branch is \`${base}\` and the \`compare\`/\`head\` branch is \`${head}\`.`,
`See ${runUrl} for more information.`,
"Make sure to tag `@sourcegraph/release-guild` in the pull request description.",
"Once the backport pull request is created, kindly remove the `release-blocker` from this pull request."
"If you encouter conflict, first resolve the conflict and stage all files, then run the commands below:",
"```bash",
"git cherry-pick --continue",
"# Push it to GitHub",
`git push --set-upstream origin ${head}`,
"# Go back to the original working tree",
"cd ../..",
"# Delete the working tree",
`git worktree remove ${worktreePath}`,
"```",
"",
"- [ ] Follow above instructions to backport the commit.",
`- [ ] Create a pull request where the \`base\` branch is \`${base}\` and the \`compare\`/\`head\` branch is \`${head}\`., [click here to create the pull request](https://github.com/sourcegraph/sourcegraph/compare/${base}...${head}?expand=1).`,
Copy link
Member Author

@michaellzc michaellzc Sep 8, 2023

Choose a reason for hiding this comment

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

why not just send people directly to the page to create the pr

"- [ ] Make sure to tag `@sourcegraph/release-guild` in the pull request description.",
"- [ ] Once the backport pull request is created, kindly remove the `release-blocker` from this pull request.",
"",
].join("\n");
};

Expand All @@ -205,7 +217,6 @@ const backport = async ({
labelRegExp,
payload,
runId,
runNumber,
serverUrl,
token,
}: {
Expand Down Expand Up @@ -233,7 +244,6 @@ const backport = async ({
labelRegExp: RegExp;
payload: PullRequestClosedEvent | PullRequestLabeledEvent;
runId: number;
runNumber: number;
serverUrl: string;
token: string;
}): Promise<{ [base: string]: number }> => {
Expand Down Expand Up @@ -303,7 +313,7 @@ const backport = async ({

const title = getTitle({ base, number, title: originalTitle });
const merged_by = originalMergedBy?.login ?? "";
const runUrl = `${serverUrl}/${owner}/${repo}/actions/runs/${runId}/jobs/${runNumber}`;
const runUrl = `${serverUrl}/${owner}/${repo}/actions/runs/${runId}`;
Comment on lines -306 to +316
Copy link
Member Author

Choose a reason for hiding this comment

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

this link is broken

e.g., https://github.com/sourcegraph/sourcegraph/actions/runs/6123459521/jobs/15021

the job id is not exposed from the context, let's just go as far as the summary page of the workflow run

it's good enough

// PRs are handled sequentially to avoid breaking GitHub's log grouping feature.
// eslint-disable-next-line no-await-in-loop
await group(`Backporting to ${base} on ${head}.`, async () => {
Expand Down
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const run = async () => {

const payload = context.payload as PullRequestEvent;
const runId = context.runId;
const runNumber = context.runNumber;
const serverUrl = context.serverUrl;

if (payload.action !== "closed" && payload.action !== "labeled") {
Expand All @@ -40,7 +39,6 @@ const run = async () => {
labelRegExp,
payload,
runId,
runNumber,
serverUrl,
token,
});
Expand Down