Skip to content

[NoQA] Fix three ways a version sync can fail or push a bad version to main - #97599

Merged
MariaHCD merged 9 commits into
mainfrom
vit-syncVersions-emptyCommit
Sep 30, 2026
Merged

MariaHCD merged 9 commits into
mainfrom
vit-syncVersions-emptyCommit

Conversation

@mountiny

@mountiny mountiny commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Note

Extract syncVersions workflow shell into a script, which this was stacked on, has merged. This now targets main directly and its diff is only the hunks described below.

The full version sync path in .github/scripts/syncVersions.sh records the Mobile-Expensify submodule pointer unconditionally:

git add Mobile-Expensify
git commit -m "Update Mobile-Expensify submodule version to $target (sync recovery)"

When the versions differ but the App gitlink already points at Mobile-Expensify main, nothing is staged, so git commit exits 1. Under set -e that kills the job after the local version commit and before any push — so the sync silently accomplishes nothing and has to be re-run.

That state is reachable in practice: it is exactly what a previously half-completed sync leaves behind, where the submodule pointer got bumped but the versions did not.

The fix applies the same guard the submodule-only path already uses:

git add Mobile-Expensify
if ! git diff --staged --quiet; then
    git commit -m "Update Mobile-Expensify submodule version to $target (sync recovery)"
fi

This was deliberately left out of #97598 so that PR stayed a provably behavior-neutral refactor.

Two more failure modes in the same script are fixed here, for the same reason — they are behavior changes, so they do not belong in the refactor.

A TARGET_VERSION that isn't the Mobile-Expensify version reached main before failing. Only the App side is rewritten, so any other target fails the final verification. It did so after sync_full_version had committed and pushed that version to App main, leaving main claiming a version Mobile-Expensify never had. resolve_target_version now rejects it before anything is written.

Mobile-Expensify moving mid-run was reported as a failed sync. Verification refetches Mobile-Expensify main and compares it to the gitlink App now records. A deployer triggers this during a deploy, so Mobile-Expensify main can easily gain a commit while the sync runs — and a sync that recorded exactly what check pinned it to was then announced as a failure in #deployer. That one case is now a ::warning:: telling you to re-run; a gitlink this run never pinned is still a hard ::error::.

Accepting that case means the run reaches the Announce sync in Slack step, whose text claimed the submodule matches Mobile-Expensify main — which is exactly what this branch just established is not true. verify_sync therefore reports a SUBMODULE_MATCHES_REMOTE output and the announcement branches on it, so #deployer is told to run it again rather than that everything is aligned. That is the one hunk in .github/workflows/syncVersions.yml.

Fixed Issues

$ #88233
PROPOSAL: N/A

Tests

  1. Check out this branch and run the suite on macOS. It lives in tests/tooling/ and runs under bun test, not Jest:

    TZ=utc bun test --parallel --preload ./scripts/stubReactNative.js --preload ./tests/tooling/setup.ts ./tests/tooling/SyncVersions.test.ts

    Verify all 19 tests pass. Four of them cover the three fixes:

    • still syncs when the submodule pointer is already current
    • rejects a target version that does not match Mobile-Expensify, without touching App main — a rewrite of fails verification when the target version does not match Mobile-Expensify, which passed for the wrong reason: it asserted the failure that happened after the bad version was pushed
    • warns instead of failing when Mobile-Expensify main advances mid-sync
    • fails verification when App main records a submodule commit this run never pinned — the other side of that branch, so downgrading it to a warning cannot swallow a real mismatch
  2. Verify they are genuine regression tests. The fixes are committed, so put main's script back rather than stashing:

    git checkout origin/main -- .github/scripts/syncVersions.sh

    Re-run the command above and confirm exactly those four fail and the other 15 pass, then restore with git checkout HEAD -- .github/scripts/syncVersions.sh and confirm all 19 pass again.

  3. Verify each failure in its unfixed state:

    • Empty submodule commit: the output shows nothing to commit, working tree clean and a non-zero exit, with origin/main left without the version commit. Fixed, origin/main ends on Update version to 9.3.11-48 (sync recovery) and POST_SYNC_APP_VERSION is set.
    • Bad TARGET_VERSION: origin/main receives Update version to 9.9.9-9 (sync recovery) before verification fails. Fixed, origin/main is untouched and the error names both versions.
    • Mobile-Expensify moving mid-run: the run exits 1 with ::error::Submodule on App main ... still differs. Fixed, it exits 0 with ::warning::Mobile-Expensify main advanced to .... A gitlink this run never pinned still exits 1 on that same ::error::.
  4. Run npm run shellcheck and verify it passes.

  5. Read the Announce sync in Slack payload in .github/workflows/syncVersions.yml and confirm the success text says submodule matches Mobile-Expensify main. only when SUBMODULE_MATCHES_REMOTE is 'true', and otherwise tells the deployer to run it again. The suite asserts that output is 'true' after a clean submodule-only sync and 'false' after one where Mobile-Expensify moved mid-run.

  6. Deployer validation: trigger the Sync E/App and Mobile-Expensify versions workflow manually from this branch (the Resolve the script to run step, now on main, makes that work before merge) and verify a normal sync — versions differ and the submodule pointer is behind — still produces both commits: Update version to <version> (sync recovery) followed by Update Mobile-Expensify submodule version to <version> (sync recovery).

  7. Verify the TARGET_VERSION guard from the deployer side: trigger the same workflow with TARGET_VERSION set to something Mobile-Expensify is not on, and verify the run fails on ::error::TARGET_VERSION (...) must match the Mobile-Expensify version (...) with nothing pushed to main.

  • Verify that no errors appear in the JS console

Offline tests

Not applicable — this changes a GitHub Actions workflow script. There is no client-side behavior and no network state to vary.

QA Steps

Not applicable — no user-facing behavior changes. The workflow is a manual workflow_dispatch restricted to mobile deployers and is validated by triggering it directly (see step 5 in Tests), not on staging or production.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native

N/A — CI workflow change only.

Android: mWeb Chrome

N/A — CI workflow change only.

iOS: Native

N/A — CI workflow change only.

iOS: mWeb Safari

N/A — CI workflow change only.

MacOS: Chrome / Safari

N/A — CI workflow change only.

@mountiny

mountiny commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@codex @MelvinBot review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: b7e20e6a41

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@MelvinBot

Copy link
Copy Markdown
Contributor

Review — LGTM ✅

The fix is correct and minimal. git commit aborts with exit 1 when there's nothing staged, and under set -euo pipefail that would kill the sync after the local version commit but before the push — leaving origin/main without the version commit, exactly as the PR describes. Guarding the commit behind a staged-diff check is the right fix, and it mirrors the pattern the submodule-only path already uses (syncVersions.sh:206-210).

I verified:

  • Guard logic at syncVersions.sh:171-176 — git diff --staged --quiet returns non-zero only when the submodule gitlink actually changed, so a real pointer bump still commits and an already-current pointer is skipped. verify_sync still enforces recorded gitlink == Mobile-Expensify origin/main, so skipping the commit can't mask a genuinely out-of-date pointer.
  • The test is a genuine regression test. SyncVersionsTest.ts:330-342 sets up versions differing (9.3.10-1 vs 9.3.11-48) while the submodule pointer is already current, then asserts origin/main's tip is Update version to 9.3.11-48 (sync recovery). With the old code, the empty submodule commit would abort the run before the push, so that assertion would fail — which matches the author's step-3 verification.
  • All CI checks pass (14 tests including the new one, shellcheck via lint).
One non-blocking observation (pre-existing, out of scope)

The full-sync push-failure/rebase path (syncVersions.sh:179-184) does a plain git fetch + git rebase origin/main + git push, whereas the submodule-only path additionally re-runs git submodule update --remote and re-stages after the rebase (syncVersions.sh:213-221). This asymmetry predates this PR and isn't something this change should take on — flagging only for awareness.

No changes requested — this is good to merge (after the stacked base #97598, per the PR note).

@mountiny mountiny changed the title Skip the submodule commit during a full version sync when the pointer is already current [NoQA] Skip the submodule commit during a full version sync when the pointer is already current Aug 10, 2026
Only the App side is rewritten, so a target that isn't the Mobile-Expensify
version can never pass verification. It used to be caught after the version
commits were already pushed to main.
Verification refetches Mobile-Expensify main, which can move while the sync
runs, so a sync that recorded exactly what the check step pinned it to was
reported as a failure.
# Conflicts:
#	tests/tooling/SyncVersions.test.ts
@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 13 files with indirect coverage changes

# Conflicts:
#	tests/tooling/SyncVersions.test.ts
# Conflicts:
#	.github/scripts/syncVersions.sh
@mountiny mountiny changed the title [NoQA] Skip the submodule commit during a full version sync when the pointer is already current [NoQA] Fix three ways a version sync can fail or push a bad version to main Sep 25, 2026
Base automatically changed from vit-syncVersions-script to main September 25, 2026 15:34
@mountiny
mountiny marked this pull request as ready for review September 29, 2026 08:45
@mountiny
mountiny requested a review from a team as a code owner September 29, 2026 08:45
@melvin-bot
melvin-bot Bot requested review from ZhenjaHorbach and removed request for a team September 29, 2026 08:45
@melvin-bot

melvin-bot Bot commented Sep 29, 2026

Copy link
Copy Markdown

@ZhenjaHorbach Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69aa94de68

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

# Mobile-Expensify main can advance mid-run, which is likely because a deployer triggers this
# during a deploy. Recording what `check` pinned is still a successful sync, so report it and
# let the next run collect the newer commit.
if [[ "$recorded" == "$EXPECTED_SUBMODULE_SHA" ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Do not claim the stale gitlink matches current main

When Mobile-Expensify advances after check, this branch deliberately returns success while recorded is still the older SHA. The workflow then runs its existing “Announce sync in Slack” step, whose success message says that the submodule matches Mobile-Expensify main, even though this branch just established that it does not. Deployer notifications will therefore report a completed, fully synchronized version when a rerun is still required; expose this stale-but-accepted state to the workflow or change the success announcement accordingly.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(Vit's agent)

Good catch, and correct — fixed in 7a6f54c8d62. verify_sync now sets a SUBMODULE_MATCHES_REMOTE output, and the announce step's text branches on it, so the stale-but-accepted case says "Mobile-Expensify main has advanced since, so run this again to record it" instead of claiming a match. Both directions are asserted in the suite.

Letting a mid-run Mobile-Expensify advance pass verification left the announce
step still saying the submodule matches main. verify_sync now reports which of
the two it was.
@ZhenjaHorbach

ZhenjaHorbach commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Minor comment
But when tested locally, all 19 tests pass with the fix. Small nit on step 2 of the Tests section
With main's script, 5 tests fail, not 4. commits and pushes the new submodule pointer, then verifies also fails because it now asserts SUBMODULE_MATCHES_REMOTE === 'true' and the old script doesn't emit that output
That's expected, but just a small mismatch 😅

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

@melvin-bot
melvin-bot Bot requested a review from madmax330 September 29, 2026 09:59
@melvin-bot

melvin-bot Bot commented Sep 29, 2026

Copy link
Copy Markdown

@madmax330 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@mountiny

Copy link
Copy Markdown
Contributor Author

@ZhenjaHorbach sorry this did not require C+ review, its just a workflow change

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@ZhenjaHorbach sorry this did not require C+ review, its just a workflow change

Don't worry
I just ran the tests quickly and approved it
so I won't be asking for payment 😁

@MariaHCD
MariaHCD merged commit e4dc6a1 into main Sep 30, 2026
35 of 38 checks passed
@MariaHCD
MariaHCD deleted the vit-syncVersions-emptyCommit branch September 30, 2026 09:10
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

OSBotify commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/MariaHCD in version: 9.5.0-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify

OSBotify commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Julesssss in version: 9.5.0-5 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 failure ❌

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants