Skip to content

Extract syncVersions workflow shell into a script - #97598

Draft
mountiny wants to merge 2 commits into
mainfrom
vit-syncVersions-script
Draft

Extract syncVersions workflow shell into a script#97598
mountiny wants to merge 2 commits into
mainfrom
vit-syncVersions-script

Conversation

@mountiny

Copy link
Copy Markdown
Contributor

Explanation of Change

Follow-up to the review feedback on Fix version sync between E/App and Mobile-Expensify: the main shell logic is moved out of .github/workflows/syncVersions.yml and into .github/scripts/syncVersions.sh, leaving the workflow responsible only for workflow_dispatch, checkout, validateActor, setupGitForOSBotify, setupNode, and thin run: invocations.

This is a behavior-preserving refactor. Every annotation string, commit message and git invocation is carried over unchanged.

Six run:-bearing steps collapse into two:

Before After
submoduleRemote, checkVersions ./.github/scripts/syncVersions.sh check
targetVersion, full version sync, submodule-only bump, verifySync ./.github/scripts/syncVersions.sh sync

The script uses two subcommands rather than a single always-run step so that setupNode can stay conditional — it is only needed for the full version sync path, and on macOS it runs npm ci (which also runs npm i inside Mobile-Expensify via scripts/postInstall.sh, dirtying the submodule working tree). Forcing it on the submodule-only path would be both slow and a new failure mode.

Notes on the details that matter for parity:

  • ACTUAL_SHA and NEED_FULL_VERSION_SYNC are threaded from check to sync through step outputs rather than recomputed. Recomputing ACTUAL_SHA would turn the "did the submodule checkout move since we updated it?" guard into a comparison of a value with itself.
  • sync deliberately never re-runs git submodule update --remote — Mobile-Expensify main can advance while Node is being set up between the two steps.
  • The two rebase-retry paths are kept separate rather than factored into a shared helper, because they genuinely differ (the submodule-only path re-updates the submodule, re-stages, and guards with git diff --staged --quiet; the full-sync path does none of that).
  • No ${{ }} expression is interpolated into a shell body any more. TARGET_VERSION now reaches the script via env:, which removes a script-injection vector on a runner that holds OS_BOTIFY_COMMIT_TOKEN and 1Password credentials.

The script gains one extra subcommand, version-components, purely so the Android/iOS version math can be unit tested without a repo fixture.

Two follow-ups intentionally left out of this PR so it stays a pure refactor:

  1. The full-sync path runs git add Mobile-Expensify; git commit unconditionally. When the versions differ but the App gitlink already points at Mobile-Expensify main, nothing is staged, git commit exits 1, and the job dies after the local version commit and before any push. The submodule-only path already guards this with git diff --staged --quiet. Fixed in a follow-up PR stacked on this one.
  2. The TARGET_VERSION dispatch input is only usable when it equals the Mobile-Expensify version, since only the App side is rewritten and verification then compares the two. The input description: is clarified here; the behavior is unchanged.

Fixed Issues

$ #88233
PROPOSAL: N/A

Tests

This is a CI-only workflow change; there is no app-facing behavior to exercise. It is covered by new unit tests plus ShellCheck.

  1. Run npm run shellcheck and verify it passes for all files, including the new .github/scripts/syncVersions.sh.
  2. Run npx jest tests/unit/SyncVersionsTest.ts on macOS and verify all 13 tests pass. The suite builds throwaway git repos (a bare Mobile-Expensify remote, a bare App remote, and a working clone wiring them together as a submodule) under os.tmpdir() and runs the real script against them:
    • version-components derives the correct SHORT_VERSION / BUILD_NUMBER / CF_VERSION / ANDROID_VERSION_CODE, including zero-padding, matching generateAndroidVersionCode in scripts/bumpVersion.ts.
    • check reports in-sync, full-version-sync-needed, and submodule-bump-needed for the three real-world states.
    • sync in submodule-only mode commits and pushes the new pointer and verifies it, and fails with ::error:: (without pushing) when the submodule checkout moved since check.
    • sync in full-version mode rewrites package.json, android/app/build.gradle and all three Info.plist files, pushes both commits, and fails verification when the target version does not match Mobile-Expensify.
  3. Verify that the three full-version-sync tests are skipped on Linux (they depend on PlistBuddy and BSD sed -i '') and run on macOS.
  4. Confirm the rendered workflow file still contains the same step order: checkout → validateActorsetupGitForOSBotifycheck → conditional setupNodesync → Slack announce → Slack failure.
  5. Deployer validation: trigger the Sync E/App and Mobile-Expensify versions workflow manually while App and Mobile-Expensify are already in sync, and verify the run exits early with ::notice::✅ Versions and submodule are in sync and makes no commits, no pushes and no Slack post.
  • Verify that no errors appear in the JS console

Offline tests

Not applicable — this changes a GitHub Actions workflow and its supporting 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.

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.

1 participant