-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chore(e2e): Cache app builds. Skip E2E on docs only PR. #9930
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
Open
yasserfaraazkhan
wants to merge
11
commits into
main
Choose a base branch
from
e2e-ci-optimize
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+807
−282
Open
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3f9b318
feat(e2e): skip non-app PRs and cache builds by content fingerprint
yasserfaraazkhan 457c492
Merge remote-tracking branch 'origin/main' into e2e-ci-optimize
yasserfaraazkhan 45bf555
upgrade to ubuntu-24 runner
yasserfaraazkhan 3bbb37e
clean up
yasserfaraazkhan 85e6975
clean up
yasserfaraazkhan 1c2ed6c
clean up
yasserfaraazkhan fe0f222
fix(e2e): revert CMT S3 cache — release branches never hit it
yasserfaraazkhan 049b514
clean up
yasserfaraazkhan 62bb8ff
fix(e2e): replace dorny/paths-filter with github-script
yasserfaraazkhan 2786de1
fix(e2e): pass ruby-version when using fastlane working-directory
yasserfaraazkhan 82ebb9b
fix(e2e): restore Detox iOS prewarm and notifications-only grants
yasserfaraazkhan 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| name: Compute E2E build fingerprint | ||
| description: Compute a content-based fingerprint for E2E builds to enable caching | ||
|
|
||
| inputs: | ||
| platform: | ||
| description: 'Platform to compute fingerprint for (ios, android-detox, android-maestro)' | ||
| required: true | ||
|
|
||
| outputs: | ||
| fingerprint: | ||
| description: 'Computed fingerprint' | ||
| value: ${{ steps.compute.outputs.fingerprint }} | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Compute fingerprint | ||
| id: compute | ||
| shell: bash | ||
| run: | | ||
| # Fingerprint = sha256 of git blob hashes for all binary-impacting paths. | ||
| # Missing a path causes false cache HITs (wrong binary tested). | ||
| # Test files (detox/e2e/**, detox/maestro/**) are excluded so test-only | ||
| # PRs still hit cache. Keep app-source subset in sync with label-manager filter. | ||
| case "${{ inputs.platform }}" in | ||
| ios) | ||
| paths=(app/ ios/ libraries/ share_extension/ patches/ \ | ||
| types/ assets/fonts/ assets/sounds/ \ | ||
| assets/base/images/ assets/base/release/ assets/base/config.json \ | ||
| package.json package-lock.json \ | ||
| tsconfig.json babel.config.js metro.config.js \ | ||
| index.tsx app.json react-native.config.js \ | ||
| .nvmrc fastlane/) | ||
| ;; | ||
| android-detox) | ||
| paths=(app/ android/ libraries/ share_extension/ patches/ \ | ||
| types/ assets/fonts/ assets/sounds/ \ | ||
| assets/base/images/ assets/base/release/ assets/base/config.json \ | ||
| package.json package-lock.json \ | ||
| tsconfig.json babel.config.js metro.config.js \ | ||
| index.tsx app.json react-native.config.js \ | ||
| .nvmrc detox/.detoxrc.json detox/package.json \ | ||
| detox/package-lock.json detox/scripts/) | ||
| ;; | ||
| android-maestro) | ||
| paths=(app/ android/ libraries/ share_extension/ patches/ \ | ||
| types/ assets/fonts/ assets/sounds/ \ | ||
| assets/base/images/ assets/base/release/ assets/base/config.json \ | ||
| package.json package-lock.json \ | ||
| tsconfig.json babel.config.js metro.config.js \ | ||
| index.tsx app.json react-native.config.js \ | ||
| .nvmrc) | ||
| ;; | ||
| *) | ||
| echo "::error::Invalid platform: ${{ inputs.platform }}" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| # Fall back to commit SHA if ls-tree fails (e.g., shallow clone) so the build still runs. | ||
| fingerprint=$(git ls-tree -r HEAD -- "${paths[@]}" 2>/dev/null | sha256sum | cut -d' ' -f1) | ||
| if [ -z "$fingerprint" ] || [ "$fingerprint" = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ]; then | ||
| fingerprint="nocache-$(git rev-parse --short HEAD 2>/dev/null || echo unknown)" | ||
| echo "::warning::git ls-tree produced no output — using fallback fingerprint. S3 cache will miss." | ||
| fi | ||
| echo "fingerprint=${fingerprint}" >> "$GITHUB_OUTPUT" | ||
| echo "Computed fingerprint for ${{ inputs.platform }}: ${fingerprint}" |
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 |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| name: S3 Build Cache | ||
| description: >- | ||
| Cache/restore compiled app binaries in S3 keyed by content fingerprint. | ||
| Uses S3 instead of actions/cache because large binaries (200MB–1GB) | ||
| blow the 10GB GHA cache limit and cause eviction thrashing. | ||
|
|
||
| inputs: | ||
| fingerprint: | ||
| description: 'Content fingerprint (from compute-e2e-build-fingerprint)' | ||
| required: true | ||
| platform: | ||
| description: 'Platform key: ios, android-detox, android-maestro' | ||
| required: true | ||
| bucket: | ||
| description: 'S3 bucket name' | ||
| required: true | ||
| s3-key-prefix: | ||
| description: 'Key prefix in the bucket (e.g. e2e-builds/)' | ||
| required: false | ||
| default: 'e2e-builds/' | ||
| cache-path: | ||
| description: 'Local path to cache (glob for restore, directory for save)' | ||
| required: true | ||
| mode: | ||
| description: >- | ||
| restore (check + download), save (upload after build), or | ||
| check (existence only — no download; for cache-warming jobs) | ||
| required: true | ||
|
|
||
| outputs: | ||
| cache-hit: | ||
| description: 'true if a cached build was found and restored' | ||
| value: ${{ steps.s3-cache.outputs.cache-hit }} | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708 # v5.1.1 | ||
| with: | ||
| aws-access-key-id: ${{ env.DETOX_AWS_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ env.DETOX_AWS_SECRET_ACCESS_KEY }} | ||
| aws-region: us-east-1 | ||
|
|
||
| - name: S3 cache ${{ inputs.mode }} | ||
| id: s3-cache | ||
| shell: bash | ||
| env: | ||
| FINGERPRINT: ${{ inputs.fingerprint }} | ||
| PLATFORM: ${{ inputs.platform }} | ||
| BUCKET: ${{ inputs.bucket }} | ||
| KEY_PREFIX: ${{ inputs.s3-key-prefix }} | ||
| CACHE_PATH: ${{ inputs.cache-path }} | ||
| MODE: ${{ inputs.mode }} | ||
| run: | | ||
| set -eu | ||
| S3_KEY="${KEY_PREFIX}${PLATFORM}/${FINGERPRINT}.tar.gz" | ||
|
|
||
| if [ "$MODE" = "restore" ] || [ "$MODE" = "check" ]; then | ||
| echo "Checking s3://${BUCKET}/${S3_KEY} ..." | ||
| if aws s3 ls "s3://${BUCKET}/${S3_KEY}" 2>/dev/null; then | ||
| if [ "$MODE" = "check" ]; then | ||
| echo "Cache HIT — existence-only check, skipping download." | ||
| echo "cache-hit=true" >> "$GITHUB_OUTPUT" | ||
| # Any download/extract failure must degrade to a cache miss so the | ||
| # build still runs instead of aborting the action under set -eu. | ||
| elif aws s3 cp "s3://${BUCKET}/${S3_KEY}" /tmp/build-cache.tar.gz \ | ||
| && tar xzf /tmp/build-cache.tar.gz; then | ||
| rm -f /tmp/build-cache.tar.gz | ||
| echo "Restored build from S3 (fingerprint=${FINGERPRINT:0:12})" | ||
| echo "cache-hit=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "::warning::Cache restore failed (download/extract error) — treating as cache miss." | ||
| rm -f /tmp/build-cache.tar.gz || true | ||
| echo "cache-hit=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| else | ||
| echo "Cache MISS — no cached build for fingerprint ${FINGERPRINT:0:12}" | ||
| echo "cache-hit=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| elif [ "$MODE" = "save" ]; then | ||
| # nullglob: non-matching glob → empty array instead of literal pattern. | ||
| shopt -s nullglob | ||
| FILES=() | ||
| for f in $CACHE_PATH; do | ||
| [ -e "$f" ] && FILES+=("$f") | ||
| done | ||
| shopt -u nullglob | ||
|
|
||
| if [ ${#FILES[@]} -eq 0 ]; then | ||
| echo "::warning::No files found at '$CACHE_PATH' — skipping S3 cache save." | ||
| echo "cache-hit=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Uploading ${#FILES[@]} path(s) to s3://${BUCKET}/${S3_KEY} ..." | ||
| tar czf /tmp/build-cache.tar.gz "${FILES[@]}" | ||
| aws s3 cp /tmp/build-cache.tar.gz "s3://${BUCKET}/${S3_KEY}" | ||
| rm -f /tmp/build-cache.tar.gz | ||
| echo "Saved build to S3 (fingerprint=${FINGERPRINT:0:12})" | ||
| else | ||
| echo "::error::Invalid mode: $MODE (expected restore, save, or check)" | ||
| exit 1 | ||
| fi | ||
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.
Uh oh!
There was an error while loading. Please reload this page.