From 31649d0eeef2d18f8608fba5e9bfaff8d2c4697e Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 29 Jan 2025 11:30:32 -0800 Subject: [PATCH 1/6] Don't commit conflict markers - just post instructions for manual CP instead --- .github/workflows/cherryPick.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index 1772d5d309cc..4ddcb6f9edc6 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -85,14 +85,12 @@ jobs: if git cherry-pick -S -x --mainline 1 ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }}; then echo "🎉 No conflicts! CP was a success, PR can be automerged 🎉" echo "HAS_CONFLICTS=false" >> "$GITHUB_OUTPUT" + git commit --amend -m "$(git log -1 --pretty=%B)" -m "(CP triggered by ${{ github.actor }})" else echo "😞 PR can't be automerged, there are merge conflicts in the following files:" git --no-pager diff --name-only --diff-filter=U - git add . - GIT_MERGE_AUTOEDIT=no git cherry-pick --continue echo "HAS_CONFLICTS=true" >> "$GITHUB_OUTPUT" fi - git commit --amend -m "$(git log -1 --pretty=%B)" -m "(CP triggered by ${{ github.actor }})" - name: Push changes run: | @@ -109,7 +107,25 @@ jobs: run: | gh pr create \ --title "🍒 Cherry pick PR #${{ github.event.inputs.PULL_REQUEST_NUMBER }} to staging 🍒" \ - --body "🍒 Cherry pick https://github.com/Expensify/App/pull/${{ github.event.inputs.PULL_REQUEST_NUMBER }} to staging 🍒" \ + --body \ + "🍒 Cherry pick https://github.com/Expensify/App/pull/${{ github.event.inputs.PULL_REQUEST_NUMBER }} to staging 🍒 + This PR had conflicts when we tried to cherry-pick it to staging. You'll need to manually perform the cherry-pick, using the following steps: + + ```bash + git fetch + git checkout ${{ github.actor }}-cherry-pick-staging-${{ github.event.inputs.PULL_REQUEST_NUMBER }}-${{ github.run_attempt }} + git cherry-pick -S -x --mainline 1 ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }} + ``` + + Then manually resolve conflicts, and commit the change with `git cherry-pick --continue`. Lastly, please run: + + ```bash + git commit --amend -m "$(git log -1 --pretty=%B)" -m "(CP triggered by ${{ github.actor }})" + ``` + + That will help us keep track of who triggered this CP. Once all that's done, push your changes with `git push origin ${{ github.actor }}-cherry-pick-staging-${{ github.event.inputs.PULL_REQUEST_NUMBER }}-${{ github.run_attempt }}`, and then open this PR for review. + + Note that you **must** test this PR, and both the author and reviewer checklist should be completed, just as if you were merging the PR to main." \ --label "Engineering,Hourly" \ --base "staging" sleep 5 From 0de41a99bf591cbd7eb2787a9a52c47bd52a0599 Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 29 Jan 2025 11:31:06 -0800 Subject: [PATCH 2/6] Also assign original PR author --- .github/workflows/cherryPick.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index 4ddcb6f9edc6..f1b2326a3c40 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -133,7 +133,8 @@ jobs: "This pull request has merge conflicts and can not be automatically merged. :disappointed: Please manually resolve the conflicts, push your changes, and then request another reviewer to review and merge. **Important:** There may be conflicts that GitHub is not able to detect, so please _carefully_ review this pull request before approving." - gh pr edit --add-assignee "${{ github.actor }},${{ steps.getCPMergeCommit.outputs.MERGE_ACTOR }}" + ORIGINAL_PR_AUTHOR="$(gh pr view ${{ github.event.inputs.PULL_REQUEST_NUMBER }} --json author --jq .author.login)" + gh pr edit --add-assignee "${{ github.actor }},${{ steps.getCPMergeCommit.outputs.MERGE_ACTOR }},$ORIGINAL_PR_AUTHOR" env: GITHUB_TOKEN: ${{ steps.setupGitForOSBotify.outputs.OS_BOTIFY_API_TOKEN }} From 37d48865056e0d7dca448566fc40a00bf0999f7b Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 29 Jan 2025 11:31:17 -0800 Subject: [PATCH 3/6] clarify step name --- .github/workflows/cherryPick.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index f1b2326a3c40..e5cbdf9f9d8a 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -138,7 +138,7 @@ jobs: env: GITHUB_TOKEN: ${{ steps.setupGitForOSBotify.outputs.OS_BOTIFY_API_TOKEN }} - - name: Label PR with CP Staging + - name: Label original PR with CP Staging run: gh pr edit ${{ inputs.PULL_REQUEST_NUMBER }} --add-label 'CP Staging' env: GITHUB_TOKEN: ${{ github.token }} From c35b8d8ec2683ad8295f4db833070032a50fc427 Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 29 Jan 2025 11:43:41 -0800 Subject: [PATCH 4/6] Abort CP --- .github/workflows/cherryPick.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index e5cbdf9f9d8a..4b602a835fbe 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -89,6 +89,7 @@ jobs: else echo "😞 PR can't be automerged, there are merge conflicts in the following files:" git --no-pager diff --name-only --diff-filter=U + git cherry-pick --abort echo "HAS_CONFLICTS=true" >> "$GITHUB_OUTPUT" fi From 8f8078af2d6a552e978eb2e47664e371e3b0beec Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 29 Jan 2025 11:49:15 -0800 Subject: [PATCH 5/6] Escape backticks ;) --- .github/workflows/cherryPick.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index 4b602a835fbe..23d3167024d1 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -112,19 +112,19 @@ jobs: "🍒 Cherry pick https://github.com/Expensify/App/pull/${{ github.event.inputs.PULL_REQUEST_NUMBER }} to staging 🍒 This PR had conflicts when we tried to cherry-pick it to staging. You'll need to manually perform the cherry-pick, using the following steps: - ```bash + \`\`\`bash git fetch git checkout ${{ github.actor }}-cherry-pick-staging-${{ github.event.inputs.PULL_REQUEST_NUMBER }}-${{ github.run_attempt }} git cherry-pick -S -x --mainline 1 ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }} - ``` + \`\`\` - Then manually resolve conflicts, and commit the change with `git cherry-pick --continue`. Lastly, please run: + Then manually resolve conflicts, and commit the change with \`git cherry-pick --continue\`. Lastly, please run: - ```bash + \`\`\`bash git commit --amend -m "$(git log -1 --pretty=%B)" -m "(CP triggered by ${{ github.actor }})" - ``` + \`\`\` - That will help us keep track of who triggered this CP. Once all that's done, push your changes with `git push origin ${{ github.actor }}-cherry-pick-staging-${{ github.event.inputs.PULL_REQUEST_NUMBER }}-${{ github.run_attempt }}`, and then open this PR for review. + That will help us keep track of who triggered this CP. Once all that's done, push your changes with \`git push origin ${{ github.actor }}-cherry-pick-staging-${{ github.event.inputs.PULL_REQUEST_NUMBER }}-${{ github.run_attempt }}\`, and then open this PR for review. Note that you **must** test this PR, and both the author and reviewer checklist should be completed, just as if you were merging the PR to main." \ --label "Engineering,Hourly" \ From bc26d4c5c7b7abee1551e91be089e8976004c548 Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 29 Jan 2025 12:08:12 -0800 Subject: [PATCH 6/6] Escape double quotes --- .github/workflows/cherryPick.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index 23d3167024d1..9fe2d3e25018 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -121,7 +121,7 @@ jobs: Then manually resolve conflicts, and commit the change with \`git cherry-pick --continue\`. Lastly, please run: \`\`\`bash - git commit --amend -m "$(git log -1 --pretty=%B)" -m "(CP triggered by ${{ github.actor }})" + git commit --amend -m \"$(git log -1 --pretty=%B)\" -m \"(CP triggered by ${{ github.actor }})\" \`\`\` That will help us keep track of who triggered this CP. Once all that's done, push your changes with \`git push origin ${{ github.actor }}-cherry-pick-staging-${{ github.event.inputs.PULL_REQUEST_NUMBER }}-${{ github.run_attempt }}\`, and then open this PR for review.