Skip to content

Commit c8ba49f

Browse files
committed
Merge branch 'main' of https://github.com/expensify/app into gbr/partial-approval-fix2
2 parents 975d3c5 + a2fb98d commit c8ba49f

164 files changed

Lines changed: 2053 additions & 2572 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/javascript/markPullRequestsAsDeployed/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12787,7 +12787,7 @@ async function run() {
1278712787
});
1278812788
const prNumForCPMergeCommit = commit.message.match(/Merge pull request #(\d+)[\S\s]*\(cherry picked from commit .*\)/);
1278912789
if (prNumForCPMergeCommit?.at(1) === String(prNumber)) {
12790-
const cpActor = commit.message.match(/.*\(CP triggered by (.*)\)/)?.at(1);
12790+
const cpActor = commit.message.match(/.*\(cherry-picked to .* by (.*)\)/)?.at(1);
1279112791
if (cpActor) {
1279212792
deployer = cpActor;
1279312793
}

.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ async function run() {
140140
});
141141
const prNumForCPMergeCommit = commit.message.match(/Merge pull request #(\d+)[\S\s]*\(cherry picked from commit .*\)/);
142142
if (prNumForCPMergeCommit?.at(1) === String(prNumber)) {
143-
const cpActor = commit.message.match(/.*\(CP triggered by (.*)\)/)?.at(1);
143+
const cpActor = commit.message.match(/.*\(cherry-picked to .* by (.*)\)/)?.at(1);
144144
if (cpActor) {
145145
deployer = cpActor;
146146
}

.github/workflows/cherryPick.yml

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@ on:
66
PULL_REQUEST_URL:
77
description: The full URL of the E/App or E/Mobile-Expensify pull request to cherry-pick
88
required: true
9+
TARGET:
10+
description: CP to staging or production?
11+
required: true
12+
type: choice
13+
options:
14+
- staging
15+
- production
16+
default: staging
917

1018
jobs:
1119
createNewVersion:
1220
uses: ./.github/workflows/createNewVersion.yml
1321
secrets: inherit
22+
with:
23+
# In order to submit a new build for production review, it must have a higher PATCH version than the previously-submitted build
24+
SEMVER_LEVEL: ${{ inputs.TARGET == 'staging' && 'BUILD' || 'PATCH' }}
1425

1526
cherryPick:
1627
needs: createNewVersion
@@ -24,32 +35,20 @@ jobs:
2435
2536
- name: Verify repository
2637
run: |
27-
if [[ "${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}" != ${{ github.repository }} ]] && [[ "${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}" != "Expensify/Mobile-Expensify" ]]; then
38+
if [[ "${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}" != ${{ github.repository }} ]] && [[ ! "${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}" =~ Expensify/Mobile-Expensify* ]]; then
2839
echo "::error::❌ Cherry picks are only supported for the Expensify/App and Expensify/Mobile-Expensify repositories. Found: ${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}"
2940
exit 1
3041
fi
3142
3243
- name: Set conflict branch name
3344
id: getBranchName
34-
run: echo "CONFLICT_BRANCH_NAME=cherry-pick-staging-${{ steps.getPRInfo.outputs.PR_NUMBER }}-${{ github.run_id }}-${{ github.run_attempt }}" >> "$GITHUB_OUTPUT"
35-
36-
- name: Checkout staging branch with full history if cherry picking Mobile-Expensify
37-
if: ${{ steps.getPRInfo.outputs.REPO_FULL_NAME == 'Expensify/Mobile-Expensify' }}
38-
# v4
39-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
40-
with:
41-
ref: staging
42-
token: ${{ secrets.OS_BOTIFY_TOKEN }}
43-
submodules: true
44-
# Only fetch depth 0 for Mobile-Expensify, because it's a submodule and we need more history to cherry pick successfully
45-
fetch-depth: 0
45+
run: echo "CONFLICT_BRANCH_NAME=cherry-pick-${{ inputs.TARGET }}-${{ steps.getPRInfo.outputs.PR_NUMBER }}-${{ github.run_id }}-${{ github.run_attempt }}" >> "$GITHUB_OUTPUT"
4646

47-
- name: Checkout staging branch without full history if cherry picking App
48-
if: ${{ steps.getPRInfo.outputs.REPO_FULL_NAME == github.repository }}
4947
# v4
48+
- name: Checkout target branch without full history if cherry picking App
5049
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
5150
with:
52-
ref: staging
51+
ref: ${{ inputs.TARGET }}
5352
token: ${{ secrets.OS_BOTIFY_TOKEN }}
5453
submodules: true
5554

@@ -74,14 +73,13 @@ jobs:
7473
id: getPreviousVersion
7574
uses: ./.github/actions/javascript/getPreviousVersion
7675
with:
77-
SEMVER_LEVEL: "PATCH"
76+
SEMVER_LEVEL: ${{ inputs.TARGET == 'staging' && 'PATCH' || 'MINOR' }}
7877

79-
- name: Fetch history of relevant refs if cherry picking an App change
80-
if: ${{ steps.getPRInfo.outputs.REPO_FULL_NAME == github.repository }}
78+
- name: Fetch history of relevant refs
8179
run: |
82-
git fetch origin main staging --no-recurse-submodules --no-tags --shallow-exclude ${{ steps.getPreviousVersion.outputs.PREVIOUS_VERSION }}
80+
git fetch origin main ${{ inputs.TARGET }} --no-recurse-submodules --no-tags --shallow-exclude ${{ steps.getPreviousVersion.outputs.PREVIOUS_VERSION }}
8381
cd Mobile-Expensify
84-
git fetch origin main staging --no-recurse-submodules --no-tags --shallow-exclude ${{ steps.getPreviousVersion.outputs.PREVIOUS_VERSION }}
82+
git fetch origin main ${{ inputs.TARGET }} --no-recurse-submodules --no-tags --shallow-exclude ${{ steps.getPreviousVersion.outputs.PREVIOUS_VERSION }}
8583
8684
- name: Get E/App version bump commit
8785
id: getVersionBumpCommit
@@ -119,33 +117,35 @@ jobs:
119117
env:
120118
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
121119

122-
- name: Cherry-pick the Mobile-Expensify version bump to Mobile-Expensify staging
120+
- name: Cherry-pick the Mobile-Expensify version bump to Mobile-Expensify target branch
123121
working-directory: Mobile-Expensify
124122
run: |
125-
git switch staging
123+
git switch ${{ inputs.TARGET }}
126124
git cherry-pick -S -x --mainline 1 --strategy=recursive -Xtheirs ${{ steps.getMobileExpensifyVersionBumpCommit.outputs.VERSION_BUMP_SHA }}
127-
git push origin staging
125+
git commit --amend -m "$(git log -1 --pretty=%B)" -m "(cherry-picked to ${{ inputs.TARGET }} by ${{ github.actor }})"
126+
git push origin ${{ inputs.TARGET }}
128127
129-
- name: Cherry-pick the E/App version-bump to staging
128+
- name: Cherry-pick the E/App version-bump to target branch
130129
run: |
131-
git switch staging
130+
git switch ${{ inputs.TARGET }}
132131
git cherry-pick -S -x --mainline 1 --strategy=recursive -Xtheirs ${{ steps.getVersionBumpCommit.outputs.VERSION_BUMP_SHA }}
132+
git commit --amend -m "$(git log -1 --pretty=%B)" -m "(cherry-picked to ${{ inputs.TARGET }} by ${{ github.actor }})"
133133
134-
- name: Update the Mobile-Expensify submodule on E/App staging
134+
- name: Update the Mobile-Expensify submodule on E/App target branch
135135
run: |
136136
git add Mobile-Expensify
137137
git commit -m "Update Mobile-Expensify submodule version to ${{ needs.createNewVersion.outputs.NEW_VERSION }}"
138138
139139
- name: Cherry-pick the merge commit of target PR
140140
id: cherryPick
141141
# If cherry picking a Mobile-Expensify change, we need to run the cherry pick in the Mobile-Expensify directory
142-
working-directory: ${{ steps.getPRInfo.outputs.REPO_FULL_NAME == 'Expensify/Mobile-Expensify' && 'Mobile-Expensify' || '.' }}
142+
working-directory: ${{ startsWith(steps.getPRInfo.outputs.REPO_FULL_NAME, 'Expensify/Mobile-Expensify') && 'Mobile-Expensify' || '.' }}
143143
run: |
144144
echo "Attempting to cherry-pick ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }}"
145145
if git cherry-pick -S -x --mainline 1 ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }}; then
146146
echo "🎉 No conflicts! CP was a success, PR can be automerged 🎉"
147147
echo "HAS_CONFLICTS=false" >> "$GITHUB_OUTPUT"
148-
git commit --amend -m "$(git log -1 --pretty=%B)" -m "(CP triggered by ${{ github.actor }})"
148+
git commit --amend -m "$(git log -1 --pretty=%B)" -m "(cherry-picked to ${{ inputs.TARGET }} by ${{ github.actor }})"
149149
else
150150
echo "😞 PR can't be automerged, there are merge conflicts in the following files:"
151151
git --no-pager diff --name-only --diff-filter=U
@@ -159,10 +159,10 @@ jobs:
159159
git checkout -b ${{ steps.getBranchName.outputs.CONFLICT_BRANCH_NAME }}
160160
git push --set-upstream origin ${{ steps.getBranchName.outputs.CONFLICT_BRANCH_NAME }}
161161
else
162-
if [[ "${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}" == "Expensify/Mobile-Expensify" ]]; then
162+
if [[ "${{ steps.getPRInfo.outputs.REPO_FULL_NAME }}" =~ Expensify/Mobile-Expensify* ]]; then
163163
# Push Mobile-Expensify changes first
164164
cd Mobile-Expensify
165-
git push origin staging
165+
git push origin ${{ inputs.TARGET }}
166166
cd ..
167167
168168
# Update and commit the submodule reference in E/App
@@ -171,7 +171,7 @@ jobs:
171171
fi
172172
173173
# Push E/App changes
174-
git push origin staging
174+
git push origin ${{ inputs.TARGET }}
175175
fi
176176
177177
- name: Create Pull Request to manually finish CP
@@ -181,9 +181,9 @@ jobs:
181181
AUTHOR_CHECKLIST=$(sed -n '/### PR Author Checklist/,$p' .github/PULL_REQUEST_TEMPLATE.md)
182182
183183
PR_DESCRIPTION=$(cat <<EOF
184-
🍒 Cherry pick ${{ github.event.inputs.PULL_REQUEST_URL }} to staging 🍒
184+
🍒 Cherry pick ${{ github.event.inputs.PULL_REQUEST_URL }} to ${{ inputs.TARGET }} 🍒
185185
186-
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:
186+
This PR had conflicts when we tried to cherry-pick it to ${{ inputs.TARGET }}. You'll need to manually perform the cherry-pick, using the following steps:
187187
188188
\`\`\`bash
189189
git fetch
@@ -194,25 +194,25 @@ jobs:
194194
Then manually resolve conflicts, and commit the change with \`git cherry-pick --continue\`. Lastly, please run:
195195
196196
\`\`\`bash
197-
git commit --amend -m "\$(git log -1 --pretty=%B)" -m "(CP triggered by ${{ github.actor }})"
197+
git commit --amend -m "\$(git log -1 --pretty=%B)" -m "(cherry-picked to ${{ inputs.TARGET }} by ${{ github.actor }})"
198198
\`\`\`
199199
200-
That will help us keep track of who triggered this CP. Once all that's done, push your changes with \`git push origin ${{ steps.getBranchName.outputs.CONFLICT_BRANCH_NAME }}\`, and then open this PR for review.
200+
This last part is important. It will help us keep track of who triggered this CP, and will ensure that version bumps are tracked correctly. Once all that's done, push your changes with \`git push origin ${{ steps.getBranchName.outputs.CONFLICT_BRANCH_NAME }}\`, and then open this PR for review.
201201
202202
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.
203203
204-
_Pro-tip:_ If this PR appears to have conflicts against the _staging_ base, it means that the version on staging has been updated. The easiest thing to do if you see this is to close the PR and re-run the CP.
204+
_Pro-tip:_ If this PR appears to have conflicts against the _${{ inputs.TARGET }}_ base, it means that the version on ${{ inputs.TARGET }} has been updated. The easiest thing to do if you see this is to close the PR and re-run the CP.
205205
206206
$AUTHOR_CHECKLIST
207207
EOF
208208
)
209209
210210
# Create PR
211211
gh pr create \
212-
--title "🍒 Cherry pick PR #${{ steps.getPRInfo.outputs.PR_NUMBER }} to staging 🍒" \
212+
--title "🍒 Cherry pick PR #${{ steps.getPRInfo.outputs.PR_NUMBER }} to ${{ inputs.TARGET }} 🍒" \
213213
--body "$PR_DESCRIPTION" \
214214
--label "Engineering,Hourly" \
215-
--base "staging"
215+
--base "${{ inputs.TARGET }}"
216216
sleep 5
217217
env:
218218
GITHUB_TOKEN: ${{ steps.setupGitForOSBotify.outputs.OS_BOTIFY_API_TOKEN }}
@@ -228,8 +228,8 @@ jobs:
228228
# In cases when the original PR author is outside the org, the `gh pr edit` command will fail. But we don't want to fail the workflow in that case.
229229
continue-on-error: true
230230

231-
- name: Label original PR with CP Staging
232-
run: gh pr edit ${{ github.event.inputs.PULL_REQUEST_URL }} --add-label 'CP Staging'
231+
- name: Label original PR with CP label
232+
run: gh pr edit ${{ github.event.inputs.PULL_REQUEST_URL }} --add-label '${{ inputs.TARGET == 'staging' && 'CP Staging' || 'CP Production' }}'
233233
env:
234234
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
235235

@@ -245,7 +245,7 @@ jobs:
245245
attachments: [{
246246
color: "#DB4545",
247247
pretext: `<!subteam^S4TJJ3PSL>`,
248-
text: `💥 Failed to CP ${{ github.event.inputs.PULL_REQUEST_URL }} to staging 💥`,
248+
text: `💥 Failed to CP ${{ github.event.inputs.PULL_REQUEST_URL }} to ${{ inputs.TARGET }} 💥`,
249249
}]
250250
}
251251
env:

.github/workflows/createNewVersion.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
git commit -m "Update version to ${{ steps.bumpVersion.outputs.NEW_VERSION }}"
132132
if ! git push origin main; then
133133
echo "Race condition! Mobile-Expensify main was updated while this workflow was running, so push failed. Fetching remote, rebasing, and retrying push once."
134-
git fetch origin main --depth=1
134+
git fetch origin main
135135
if ! git rebase origin/main; then
136136
echo "::error:: Rebase failed while retrying Mobile-Expensify push"
137137
exit 1
@@ -159,7 +159,7 @@ jobs:
159159
git commit -m "Update Mobile-Expensify submodule version to ${{ steps.bumpVersion.outputs.NEW_VERSION }}"
160160
if ! git push origin main; then
161161
echo "Race condition! E/App main was updated while this workflow was running, so push failed. Fetching remote, rebasing, and retrying push once."
162-
git fetch origin main --depth=1
162+
git fetch origin main
163163
if ! git rebase origin/main; then
164164
echo "::error:: Rebase failed while retrying Mobile-Expensify push"
165165
exit 1

0 commit comments

Comments
 (0)