Skip to content

[No QA] Deploy staging web builds to the staging Static Assets Worker - #104104

Merged
justinpersaud merged 11 commits into
mainfrom
jpersaud-newdot-staging-worker
Oct 16, 2026
Merged

justinpersaud merged 11 commits into
mainfrom
jpersaud-newdot-staging-worker

Conversation

@justinpersaud

@justinpersaud justinpersaud commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Move staging over the Cloudflare Static Worker

Fixed Issues

For https://github.com/Expensify/Expensify/issues/688126
PROPOSAL:

Tests

  • Verify that no errors appear in the JS console

Offline tests

N/A. Deploy pipeline only.

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

No QA. staging.new.expensify.com and new.expensify.com are still served the same way.

  • 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 verified any copy / text that was added to the app 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 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 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Each Worker version only contains the files uploaded with it, so tabs still running an older build would lose its chunks on every deploy. Files from the current build are never replaced.
The test-staging job becomes a matrix over test-staging and staging. The staging Worker serves no traffic until staging.new.expensify.com is routed to it in Cloudflare, and stays continue-on-error until then.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T19:44:31.443522Z 011dc3a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@melvin-bot
melvin-bot Bot requested review from stitesExpensify and removed request for a team October 15, 2026 15:31
@melvin-bot

melvin-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

@stitesExpensify 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]

@justinpersaud

Copy link
Copy Markdown
Contributor Author

hold actually, shouldn't have been out of draft yet

@justinpersaud
justinpersaud marked this pull request as draft October 15, 2026 15:42

@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: 45ae241c9c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +25 to +26
done < <(gh release list --repo Expensify/App --exclude-drafts --limit 50 --json tagName \
--jq "[.[] | select(.tagName | test(\"-staging$\"))][:$RELEASE_COUNT][].tagName")

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 Exclude the release being redeployed from the carry-forward count

When a staging deployment is retried after createRelease has already published its release—or when that concurrently running job publishes before this query—the descending release list includes the current release first, so [:$RELEASE_COUNT] downloads the current build plus only nine genuinely previous builds. This silently shortens the promised ten-release compatibility window and can make tabs from the tenth prior release lose their chunks; exclude the current deployment tag before applying the limit. I confirmed from gh release list --help that its default ordering is descending (--order ... (default "desc")).

Useful? React with 👍 / 👎.

strategy:
fail-fast: false
matrix:
# `staging` serves no traffic until staging.new.expensify.com is routed to its Worker in Cloudflare.

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.

This means the PR can go whenever and we'll make the switch when ready via dashboard

Comment on lines +1 to +9
/**
* Copies files from previous web builds into the current one when the current build doesn't have them, so tabs still
* running an older build can load its chunks after a deploy. Files with fixed names exist in every build and are
* never replaced, so in practice only content-hashed and versioned files are carried forward.
*
* node scripts/carryForwardPreviousBuilds.ts <current dist> <previous dist>...
*
* List previous builds newest first.
*/

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.

@AndrewGable @roryabraham curious for your thoughts here

so with cloudfront/s3, we leave old deploy files there forever and don't wipe them out

Lets say someone opens staging on build N, then the page knows to load the assets for build N

Later on, we deploy build N+1, and now the assets have a different name but the previous user still has a tab open on the previous version. This works because on S3/CloudFront, we never delete the files that get uploaded.

With Static Workers, we're bundling everything into the worker, meaning the old assets don't exist. To tackle that, it suggested we just keep up to the last 10 releases in the worker bundle available. The alternative is we don't do this at all, and let the app recover by force reloading. Is force reloading a problem?

A retried deploy, or one whose release is published while the job runs, counted its own release as one of the previous 10, so only nine older builds were carried forward. The current release is identified from dist/version.json.
A Worker version only contains the current build, so a tab running an older build gets a 404 for any chunk that has since changed. When the current build misses a file requested by a script or image, the staging Workers now look it up in the new-expensify-web-assets-staging bucket. The current build always takes priority, and navigations never read from the bucket.
Uploading only the new files of each build keeps CI time constant however much history the Workers can serve, and the bucket's 60-day lifecycle rule bounds that history. The upload is skipped with a warning until the R2 credentials are added.
@justinpersaud
justinpersaud marked this pull request as ready for review October 15, 2026 19:31
Comment thread .github/workflows/deploy.yml Outdated
exit 0
fi
aws configure set default.s3.preferred_transfer_client classic
aws s3 sync dist s3://new-expensify-web-assets-staging/ \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we currently have separate s3 buckets for previous staging and production builds?

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.

Yeah but we only have staging setup here for now, so left the production one out

WRANGLER_SEND_METRICS: false

- name: Verify deploy
if: ${{ matrix.environment == 'test-staging' }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why only verify on test-staging?

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.

We aren't mapping the worker to staging here yet, but rather just deploying to it.

I'll have to update the route in the console after.

The alternative is we manage the route in the wrangler config file here and have this PR act as a staging cutover once it's merged.

Maybe that's fine? I guess I'm being overly cautious that someone won't mess with the route hostname and miss it in a review, because that has the potential to cause a site outage with a bad edit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's fine to leave things that won't change often and have a high risk of causing outages (e.g. the host name), on a dashboard that only ring0 has access to change.

@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: 011dc3a2f7

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/deploy.yml Outdated
aws configure set default.s3.preferred_transfer_client classic
aws s3 sync dist s3://new-expensify-web-assets-staging/ \
--endpoint-url "https://$CLOUDFLARE_ACCOUNT_ID.r2.cloudflarestorage.com" \
--size-only --no-progress \

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 Refresh reused R2 objects before lifecycle expiry

In the inspected webDeployCloudflareWorkers upload, --size-only causes every unchanged content-hashed file to be skipped because AWS documents that this flag uses object size as the sole sync criterion. Consequently, an asset introduced more than 60 days ago but still referenced by yesterday's build retains its original age and can be deleted by the bucket lifecycle; once today's build removes it, a tab from yesterday immediately gets a 404 instead of the promised fallback. Refresh existing objects on each deploy or namespace them by build and expire the namespaces. See the AWS CLI sync documentation and Cloudflare R2 lifecycle behavior.

Useful? React with 👍 / 👎.

With --size-only, a file was uploaded once and skipped afterwards, so the bucket's 60-day lifecycle rule could delete a font, image or chunk that builds still used. Once a later build changed it, tabs on the previous build got a 404 instead of the fallback. Re-uploading everything restarts each file's expiry while it is in use.
@stitesExpensify

Copy link
Copy Markdown
Contributor

All you @roryabraham

@justinpersaud
justinpersaud merged commit 15064ef into main Oct 16, 2026
43 of 45 checks passed
@justinpersaud
justinpersaud deleted the jpersaud-newdot-staging-worker branch October 16, 2026 19:09
@justinpersaud

Copy link
Copy Markdown
Contributor Author

Forgot Rory is OOO so I will just merge this so we can keep moving forward

@github-actions

Copy link
Copy Markdown
Contributor

🚧 justinpersaud has triggered a test Expensify/App build. You can view the workflow run here.

@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

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/justinpersaud in version: 9.5.14-0 🚀

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

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.

4 participants