Repository navigation
[ci] Deploy worker previews from PRs and use them on staging #4493
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| name: worker-preview | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [labeled, unlabeled, synchronize, closed] | ||
|
|
||
| concurrency: | ||
| group: worker-preview-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
Comment on lines
+7
to
+9
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. 🔴 Unrelated labels cancel preview deployment Changing another label while a preview deploys makes Learn moreThe workflow subscribes to all label changes, but Example: Add Recommended fix: Ensure irrelevant label events cannot enter the preview's canceling concurrency group. For example, handle deployment and cleanup in separate workflows or concurrency groups with event-specific admission, and let a close event repeat cleanup even if Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| jobs: | ||
| deploy-worker-preview: | ||
| if: >- | ||
| github.event.pull_request.head.repo.full_name == github.repository && | ||
| github.event.action != 'closed' && | ||
| github.event.action != 'unlabeled' && | ||
| contains(github.event.pull_request.labels.*.name, 'preview') && | ||
| (github.event.action != 'labeled' || github.event.label.name == 'preview') | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| uses: ./.github/workflows/build-and-deploy-worker.yml | ||
| secrets: inherit | ||
| with: | ||
| environment: preview-pr-${{ github.event.pull_request.number }} | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
|
|
||
| summary: | ||
| needs: deploy-worker-preview | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Print usage instructions | ||
| run: | | ||
| cat >> "$GITHUB_STEP_SUMMARY" <<EOF | ||
| Worker from ${{ github.event.pull_request.head.sha }} is deployed as preview \`pr-${{ github.event.pull_request.number }}\`. | ||
|
|
||
| To use it on staging, set this env variable in the eas.json build profile \`env\` or in the workflow job \`env\`: | ||
|
|
||
| \`\`\` | ||
| __EAS_WORKER_PREVIEW=pr-${{ github.event.pull_request.number }} | ||
| \`\`\` | ||
|
|
||
| To use it for a simulator session on staging: | ||
|
|
||
| \`\`\` | ||
| EXPO_STAGING=1 eas simulator:start --worker-preview pr-${{ github.event.pull_request.number }} | ||
| \`\`\` | ||
| EOF | ||
|
|
||
| remove-worker-preview: | ||
| if: >- | ||
| github.event.pull_request.head.repo.full_name == github.repository && | ||
| ( | ||
| (github.event.action == 'unlabeled' && github.event.label.name == 'preview') || | ||
| (github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'preview')) | ||
| ) | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | ||
|
|
||
| - uses: ./.github/internal-actions/setup-gcloud | ||
|
|
||
| - name: Remove preview worker tarballs | ||
| run: | | ||
| for platform in android ios; do | ||
| gsutil rm "gs://eas-build-worker-tarballs/worker-$platform-preview-pr-${{ github.event.pull_request.number }}.tar.gz" || true | ||
| done | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,6 +143,11 @@ export default class Simulator extends EasCommand { | |
| hidden: true, | ||
| options: Object.values(DEVICE_RUN_SESSION_RESOURCE_CLASS_FLAG_VALUES), | ||
| })(), | ||
| 'worker-preview': Flags.string({ | ||
| description: | ||
| 'Run the session on a worker preview built from an expo/eas-cli pull request, e.g. "pr-1234". Only supported on staging.', | ||
| hidden: true, | ||
| }), | ||
|
Comment on lines
+146
to
+150
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. |
||
| egress: Flags.option({ | ||
| description: | ||
| 'With "local", the simulator system proxy points at this machine: HTTP(S) and WebSocket requests that honor it (WebKit, URLSession) and clients that read proxy environment variables (gRPC, libcurl) exit from this machine and fail while the egress client is disconnected. Connections that ignore both are refused inside the simulator and listed, with the library that tried, in the Logs section of the session page on expo.dev. The egress client must keep running for the life of the session. Only supported with --platform ios.', | ||
|
|
@@ -298,6 +303,7 @@ export default class Simulator extends EasCommand { | |
| ...(openUrl ? { openUrl } : {}), | ||
| ...(resourceClass ? { resourceClass } : {}), | ||
| ...(egress ? { egress } : {}), | ||
| ...(flags['worker-preview'] ? { workerPreview: flags['worker-preview'] } : {}), | ||
| maxRunTimeMinutes: flags['max-duration-minutes'], | ||
| maxIdleTimeMinutes: flags['max-idle-time-minutes'], | ||
| }); | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
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.
🟡 Reopened PR keeps a missing preview
Reopening a closed PR with the
previewlabel does not trigger deployment becausereopenedis absent. Closing deleted its tarballs, so the labeled PR has no preview until another push or relabel.Was this helpful? React with 👍 or 👎 to provide feedback.