Repository navigation
[No QA] Migrate the PR-testing (now AdHoc) Cloudflare Worker to App #104801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,977
−58
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d334f44
chore: migrate the PR-testing Worker to App
roryabraham ad74f1e
Merge main into the PR-testing Worker migration
roryabraham 0ea9ab6
ci: merge main and isolate PR previews
roryabraham 30cbbcf
chore: merge latest main
roryabraham eeadddd
ci: preserve queued main build artifacts
roryabraham ded7c95
ci: allow authorized branch preview workflows
roryabraham 030eb33
ci: load preview credentials from 1Password
roryabraham d7b090d
ci: reuse existing Worker deployment token
roryabraham 8e35534
ci: publish ad-hoc builds as Worker Previews
roryabraham d9de2e8
ci: remove GitHub Deployment bookkeeping
roryabraham b9a265b
docs: trim preview credential documentation
roryabraham 0e9e35b
chore: merge main for preview experiment
roryabraham d5b56e9
ci: opt into workspace dependencies per job
roryabraham 9ddb94d
ci: publish previews on the dedicated adhoc Worker
roryabraham c96940f
chore: merge main and finish adhoc naming
roryabraham 18aa978
ci: target renamed ad-hoc Worker
roryabraham 42c0b2b
fix: correct ad-hoc Worker resource name
roryabraham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,10 @@ on: | |
| type: string | ||
| default: 'false' | ||
|
|
||
| concurrency: | ||
| group: adhoc-${{ github.event_name }}-${{ format('app-{0}-mobile-{1}', inputs.APP_PR_NUMBER || inputs.APP_REF, inputs.MOBILE_EXPENSIFY_PR || inputs.MOBILE_EXPENSIFY_REF) }} | ||
| cancel-in-progress: ${{ github.event_name != 'push' }} | ||
|
|
||
| jobs: | ||
| postGitHubCommentBuildStarted: | ||
| name: Post build started comment | ||
|
|
@@ -105,49 +109,47 @@ jobs: | |
| ref: ${{ inputs.APP_REF }} | ||
| environment: adhoc | ||
| pull-request-number: ${{ inputs.APP_PR_NUMBER }} | ||
| build-preview-worker: true | ||
| secrets: inherit | ||
|
|
||
| deployWebAdHoc: | ||
| name: Deploy Web to S3 (adhoc) | ||
| name: Deploy the PR Worker Preview and web assets | ||
| needs: [buildWeb] | ||
| if: ${{ fromJSON(inputs.BUILD_WEB) && inputs.APP_PR_NUMBER != '' }} | ||
| runs-on: blacksmith-4vcpu-ubuntu-2404 | ||
| runs-on: blacksmith-2vcpu-ubuntu-2404 | ||
|
Comment on lines
-114
to
+118
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was it intentional to switch to smaller vm here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah all this job does is download some shit and upload some shit. So it can use the smallest runner |
||
| env: | ||
| WRANGLER_SEND_METRICS: false | ||
| steps: | ||
| - name: Download web build artifact | ||
| # v7 | ||
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 | ||
| - name: Checkout trusted preview tooling, not the PR branch | ||
| uses: useblacksmith/checkout@0647fdbab2614a5eb86d2971070e325060d91056 # v1.7.0 | ||
| with: | ||
| name: web-build-tar-gz-artifact | ||
| path: ./ | ||
|
|
||
| - name: Extract web build | ||
| run: tar -xzvf "${{ needs.buildWeb.outputs.TAR_FILENAME }}" | ||
| ref: ${{ github.workflow_sha }} | ||
| persist-credentials: false | ||
|
|
||
| - name: Configure AWS Credentials | ||
| # v6 | ||
| uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 | ||
| - name: Setup Node | ||
| uses: ./.github/actions/composite/setupNode | ||
| with: | ||
| role-to-assume: arn:aws:iam::949552126497:role/app-adhoc-web-deploy-gh-actions | ||
| role-session-name: gh-${{ github.run_id }}-${{ github.run_attempt }} | ||
| aws-region: us-east-1 | ||
| WORKSPACES: '["web/cloudflare-worker"]' | ||
|
|
||
| - name: Deploy to S3 | ||
| run: | | ||
| BUCKET="s3://ad-hoc-expensify-cash/web/${{ inputs.APP_PR_NUMBER }}" | ||
| - name: Download the matching web assets | ||
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7 | ||
| with: | ||
| name: web-build-tar-gz-artifact | ||
| path: ${{ runner.temp }}/adhoc-artifacts/assets | ||
|
|
||
| aws s3 sync dist "$BUCKET" --delete --acl public-read \ | ||
| --exclude "*.br" \ | ||
| --exclude "index.html" \ | ||
| --exclude "service-worker.js" \ | ||
| --exclude "workbox-*.js" \ | ||
| --cache-control "public,max-age=31536000,immutable" | ||
| - name: Download the branch Worker bundle as data | ||
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7 | ||
| with: | ||
| name: adhoc-worker-artifact | ||
| path: ${{ runner.temp }}/adhoc-artifacts/worker | ||
|
|
||
| aws s3 sync dist "$BUCKET" --acl public-read \ | ||
| --exclude "*" \ | ||
| --include "index.html" \ | ||
| --include "service-worker.js" \ | ||
| --include "workbox-*.js" \ | ||
| --cache-control "no-cache,no-store,must-revalidate" | ||
| - name: Deploy and verify the PR Preview and assets together | ||
| run: | | ||
| bun scripts/deployAdhocCloudflareWorker.ts \ | ||
| --pr-number ${{ inputs.APP_PR_NUMBER }} --sha ${{ needs.buildWeb.outputs.BUILD_SHA }} \ | ||
| --artifact-directory "${{ runner.temp }}/adhoc-artifacts" | ||
| env: | ||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_WORKERS_DEPLOY_TOKEN }} | ||
| CLOUDFLARE_ACCOUNT_ID: 3eb3df6f8c190fa13c3fc0a53c30af1a | ||
|
|
||
| postGithubComment: | ||
| runs-on: blacksmith-4vcpu-ubuntu-2404 | ||
|
|
@@ -175,7 +177,7 @@ jobs: | |
| WEB: ${{ needs.buildWeb.result == 'failure' && 'failure' || needs.deployWebAdHoc.result }} | ||
| ANDROID_LINK: ${{ needs.buildAndroid.outputs.ROCK_ARTIFACT_URL }} | ||
| IOS_LINK: ${{ needs.buildIOS.outputs.ROCK_ARTIFACT_URL }} | ||
| WEB_LINK: https://${{ inputs.APP_PR_NUMBER }}.pr-testing.expensify.com | ||
| WEB_LINK: https://${{ inputs.APP_PR_NUMBER }}.adhoc.expensify.com | ||
|
|
||
| - name: Publish links to apps for download on Expensify/Mobile-Expensify PR | ||
| if: ${{ inputs.MOBILE_EXPENSIFY_PR != '' }} | ||
|
|
@@ -219,12 +221,13 @@ jobs: | |
| github-token: ${{ github.token }} | ||
| script: | | ||
| const prNumber = '${{ inputs.APP_PR_NUMBER }}'; | ||
| const webLink = prNumber && '${{ needs.deployWebAdHoc.result }}' === 'success' ? `https://${prNumber}.pr-testing.expensify.com` : ''; | ||
| const webResult = '${{ needs.deployWebAdHoc.result }}'; | ||
| const webLink = prNumber && webResult === 'success' ? `https://${prNumber}.adhoc.expensify.com` : ''; | ||
| const androidLink = '${{ needs.buildAndroid.outputs.ROCK_ARTIFACT_URL }}' || ''; | ||
| const iosLink = '${{ needs.buildIOS.outputs.ROCK_ARTIFACT_URL }}' || ''; | ||
| const mobileExpensifySHA = '${{ steps.getMobileExpensifySHA.outputs.SHA }}' || ''; | ||
|
|
||
| const webFailed = '${{ needs.buildWeb.result }}' === 'failure' || '${{ needs.deployWebAdHoc.result }}' === 'failure'; | ||
| const webFailed = '${{ needs.buildWeb.result }}' === 'failure' || webResult === 'failure'; | ||
| const webStatus = webLink ? '✅ Success' : webFailed ? '❌ Failed' : '⏭️ Skipped'; | ||
| const androidStatus = androidLink ? '✅ Success' : '${{ needs.buildAndroid.result }}' === 'failure' ? '❌ Failed' : '⏭️ Skipped'; | ||
| const iosStatus = iosLink ? '✅ Success' : '${{ needs.buildIOS.result }}' === 'failure' ? '❌ Failed' : '⏭️ Skipped'; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we need platform in this key as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add it but I don't think we need to. I was thinking we only manage concurrency on a per-PR basis, rather than per-platform-per-PR. Basically, if you start a web-only AdHoc build on a PR, then before it finishes start an all-platforms AdHoc build, it's expected that the latter would interrupt the former.