Skip to content

chore(e2e): Cache app builds. Skip E2E on docs only PR.#9930

Open
yasserfaraazkhan wants to merge 11 commits into
mainfrom
e2e-ci-optimize
Open

chore(e2e): Cache app builds. Skip E2E on docs only PR.#9930
yasserfaraazkhan wants to merge 11 commits into
mainfrom
e2e-ci-optimize

Conversation

@yasserfaraazkhan

Copy link
Copy Markdown
Contributor

Summary

E2E currently runs on every Matterwick dispatch, including docs-only changes and re-pushes that don't affect the app.

What's Changed

  • Path-based skipping: Skip E2E for non-app changes using dorny/paths-filter (e2e-label-manager.yml).
  • S3 build cache: Cache compiled binaries using a content fingerprint of all build-impacting files. Cache hits skip the 20–30 minute build.
  • Nightly cache seed: Pre-build main nightly so matching PRs can reuse cached binaries. Old cache entries are pruned after 21 days.
  • CMT: No changes. It already builds once per run and reuses artifacts across the matrix.
NONE

yasserfaraazkhan and others added 7 commits July 14, 2026 00:30
Reduce E2E cost by path-filtering Matterwick label refresh, caching iOS/Android
binaries in S3 keyed by build-impacting content, adopting preboot_ios_simulator,
and seeding caches nightly from main.

Co-authored-by: Cursor <cursoragent@cursor.com>
CMT runs against a freshly-cut build-release-NNN branch, so its app
content never matches main's fingerprint and the S3 build cache would
always miss. Revert CMT to its native pattern: build each app once per
run and reuse across every server-version leg of the matrix via
run_id artifacts. Removes the fingerprint job, per-build cache steps,
runner bump, and top-level AWS bucket env from CMT.

Nightly prune comment updated to reflect that e2e-builds/ is shared only
by PR builds and the nightly seed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds fingerprinted S3 caching for iOS and Android E2E builds, nightly cache maintenance, updated Ruby dependency caching, delegated iOS simulator prebooting, app-impact-based E2E label handling, and Ubuntu 24.04 runners.

Changes

E2E build caching

Layer / File(s) Summary
Fingerprint and S3 cache primitives
.github/actions/compute-e2e-build-fingerprint/action.yml, .github/actions/s3-build-cache/action.yml
Computes platform-specific fingerprints and supports S3 cache restore, check, save, and cache-hit output behaviour.
Pull request E2E cache integration
.github/actions/prepare-ios-build/action.yaml, .github/actions/prepare-mobile-build/action.yaml, .github/workflows/e2e-detox-pr.yml
Uses fingerprints to skip cached iOS, Android Detox, and Android Maestro builds, uploads available outputs, and updates Ruby dependency caching.
Nightly cache seeding and pruning
.github/workflows/e2e-nightly-cache-seed.yml
Seeds platform caches from main on schedule or manual dispatch and removes S3 objects older than 21 days.

E2E workflow maintenance

Layer / File(s) Summary
E2E impact and label gating
.github/workflows/e2e-label-manager.yml
Detects app-impacting changes, cancels stale runs, posts successful skipped statuses, and conditions label operations on impact.
iOS simulator preboot integration
.github/workflows/e2e-ios-template.yml, detox/scripts/preboot_ios_simulator.sh
Delegates simulator setup to the preboot script, adds optional call-permission grants, warns on notification-grant failures, and polls for app termination.
Ubuntu runner migration
.github/workflows/*.yml
Changes affected workflow jobs from ubuntu-22.04 to ubuntu-24.04.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Workflow
  participant FingerprintAction
  participant S3BuildCache
  participant S3
  participant E2EBuild
  Workflow->>FingerprintAction: compute platform fingerprint
  FingerprintAction-->>Workflow: return fingerprint
  Workflow->>S3BuildCache: restore cache
  S3BuildCache->>S3: check and download artifact
  S3-->>S3BuildCache: return cache result
  S3BuildCache-->>Workflow: return cache-hit
  Workflow->>E2EBuild: build when cache misses
  E2EBuild->>S3BuildCache: save build artifact
  S3BuildCache->>S3: upload fingerprinted artifact
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the two main changes: build caching and skipping E2E for docs-only PRs.
Description check ✅ Passed The description directly matches the PR’s goals, including path-based skipping, S3 build caching, nightly seeding, and CMT reuse.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch e2e-ci-optimize

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 4

🧹 Nitpick comments (3)
.github/workflows/e2e-nightly-cache-seed.yml (2)

6-9: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Add a minimal permissions: block.

No permissions: block exists anywhere in this workflow, so all jobs run with the default (potentially broad) token permissions. Since every job here only reads the repo and writes to S3 via AWS credentials (never to the GitHub repo), a top-level permissions: contents: read would tighten this per least-privilege.

 on:
   schedule:
     - cron: '0 2 * * *'  # 2 AM UTC daily
   workflow_dispatch:
 
+permissions:
+  contents: read
+
 jobs:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/e2e-nightly-cache-seed.yml around lines 6 - 9, Add a
top-level permissions block to the workflow containing only contents: read,
alongside the existing on configuration. Keep the scheduled and
workflow_dispatch triggers unchanged, and do not grant write permissions because
repository writes are not required.

Source: Linters/SAST tools


12-14: 🧹 Nitpick | 🔵 Trivial

No timeout-minutes on long-running seed jobs.

build-ios/build-android-detox/build-android-maestro run full native builds without an explicit timeout, defaulting to GitHub's 360-minute job timeout. A hang (e.g., simulator/gradle daemon stuck) would tie up an expensive runner for hours before failing.

Also applies to: 71-77, 130-136

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/e2e-nightly-cache-seed.yml around lines 12 - 14, Add an
explicit timeout-minutes value to the build-ios, build-android-detox, and
build-android-maestro jobs in the nightly cache-seed workflow, using an
appropriate limit for their native build duration so hung jobs terminate well
before GitHub’s default timeout.
.github/actions/compute-e2e-build-fingerprint/action.yml (1)

25-58: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Manually maintained path lists are inherently fragile.

The comment at lines 21-24 explicitly acknowledges the risk of missing a path. For React Native projects, @expo/fingerprint provides a maintained, dependency-aware alternative to hand-rolled path lists (works with bare RN, not just Expo-managed projects). Worth evaluating if it fits, though not blocking.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/actions/compute-e2e-build-fingerprint/action.yml around lines 25 -
58, Evaluate replacing the manually maintained platform-specific path arrays in
the fingerprint action with `@expo/fingerprint`’s dependency-aware fingerprinting,
ensuring it supports this bare React Native project and preserves distinct iOS,
Android Detox, and Android Maestro inputs. If adopted, remove the duplicated
path lists and integrate the generated fingerprint into the existing action
output flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/actions/s3-build-cache/action.yml:
- Around line 59-75: Update the restore branch around the aws s3 cp and tar xzf
commands so any download, extraction, or cleanup failure is handled as a cache
miss rather than aborting the action under set -eu. Ensure the failed restore
emits cache-hit=false and allows the build to continue, while preserving the
existing successful restore behavior and check-mode existence-only path.

In @.github/workflows/e2e-detox-pr.yml:
- Around line 75-77: Add persist-credentials: false to the checkout step for the
compute-build-fingerprints job, matching the other updated checkout steps while
preserving its existing MOBILE_VERSION ref.

In @.github/workflows/e2e-label-manager.yml:
- Around line 91-97: Update the impact filter in the E2E label-manager workflow
to include the .github/actions/prepare-mobile-build/** path alongside the
existing mobile build action paths, ensuring changes to that action trigger E2E
impact handling.

In @.github/workflows/e2e-nightly-cache-seed.yml:
- Around line 18-20: Update the checkout steps in the build-ios,
build-android-detox, and build-android-maestro jobs to set persist-credentials
to false alongside ref: main, ensuring none of these S3-only jobs retain
repository credentials.

---

Nitpick comments:
In @.github/actions/compute-e2e-build-fingerprint/action.yml:
- Around line 25-58: Evaluate replacing the manually maintained
platform-specific path arrays in the fingerprint action with `@expo/fingerprint`’s
dependency-aware fingerprinting, ensuring it supports this bare React Native
project and preserves distinct iOS, Android Detox, and Android Maestro inputs.
If adopted, remove the duplicated path lists and integrate the generated
fingerprint into the existing action output flow.

In @.github/workflows/e2e-nightly-cache-seed.yml:
- Around line 6-9: Add a top-level permissions block to the workflow containing
only contents: read, alongside the existing on configuration. Keep the scheduled
and workflow_dispatch triggers unchanged, and do not grant write permissions
because repository writes are not required.
- Around line 12-14: Add an explicit timeout-minutes value to the build-ios,
build-android-detox, and build-android-maestro jobs in the nightly cache-seed
workflow, using an appropriate limit for their native build duration so hung
jobs terminate well before GitHub’s default timeout.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 77d914ba-3222-4379-a3e6-7e8cddaad306

📥 Commits

Reviewing files that changed from the base of the PR and between f1e263b and fe0f222.

📒 Files selected for processing (14)
  • .github/actions/compute-e2e-build-fingerprint/action.yml
  • .github/actions/prepare-ios-build/action.yaml
  • .github/actions/prepare-mobile-build/action.yaml
  • .github/actions/s3-build-cache/action.yml
  • .github/workflows/cmt-provisioner.yml
  • .github/workflows/compatibility-matrix-testing.yml
  • .github/workflows/e2e-android-template.yml
  • .github/workflows/e2e-cancel-on-label-removal.yml
  • .github/workflows/e2e-detox-pr.yml
  • .github/workflows/e2e-detox.yml
  • .github/workflows/e2e-ios-template.yml
  • .github/workflows/e2e-label-manager.yml
  • .github/workflows/e2e-maestro-pr.yml
  • .github/workflows/e2e-nightly-cache-seed.yml

Comment thread .github/actions/s3-build-cache/action.yml
Comment thread .github/workflows/e2e-detox-pr.yml
Comment thread .github/workflows/e2e-label-manager.yml Outdated
Comment thread .github/workflows/e2e-nightly-cache-seed.yml
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

Coverage Comparison Report

Generated on July 15, 2026 at 15:17:17 UTC

+-----------------+------------+------------+-----------+
| Metric          | Main       | This PR    | Diff      |
+-----------------+------------+------------+-----------+
| Lines           |     87.70% |     87.73% |     0.03% |
| Statements      |     87.57% |     87.60% |     0.03% |
| Branches        |     76.57% |     76.59% |     0.02% |
| Functions       |     87.17% |     87.22% |     0.05% |
+-----------------+------------+------------+-----------+
| Total           |     84.75% |     84.78% |     0.03% |
+-----------------+------------+------------+-----------+

Enterprise allowlist blocks dorny/paths-filter, causing E2E label
manager startup_failure so E2E/Run is never added. Use allowlisted
actions/github-script + pulls.listFiles with the same path globs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mattermost-build mattermost-build added E2E/Run Triggers E2E tests on both iOS and Android via Matterwick and removed E2E/Run Triggers E2E tests on both iOS and Android via Matterwick labels Jul 14, 2026
setup-ruby looks for .ruby-version under working-directory; with
fastlane/ that file is missing because it lives at the repo root.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mattermost-build mattermost-build added the E2E/Run Triggers E2E tests on both iOS and Android via Matterwick label Jul 15, 2026
@yasserfaraazkhan yasserfaraazkhan removed the E2E/Run Triggers E2E tests on both iOS and Android via Matterwick label Jul 15, 2026
Skipping prewarm (copied from Maestro) left pending-install launchd state
and caused mass iPhone Detox failures; mic/camera privacy grants diverged
from proven main Detox setup on iOS 26.x.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mattermost-build mattermost-build added the E2E/Run Triggers E2E tests on both iOS and Android via Matterwick label Jul 15, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@detox/scripts/preboot_ios_simulator.sh`:
- Around line 107-117: Update kill_app_via_launchd() to track whether the bundle
disappears from launchctl list during the retry loop; only log successful
termination and return zero when cleanup completes, otherwise return non-zero
after the retries so the preboot flow stops treating a timeout as success.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5578d26b-7114-4c84-8b44-1382f0583b1c

📥 Commits

Reviewing files that changed from the base of the PR and between 2786de1 and 82ebb9b.

📒 Files selected for processing (2)
  • .github/workflows/e2e-ios-template.yml
  • detox/scripts/preboot_ios_simulator.sh

Comment on lines +107 to +117
if [ -z "$app_pid" ]; then
return 0
fi
xcrun simctl spawn "$SIMULATOR_ID" kill -9 "$app_pid" 2>/dev/null || true
for _ in 1 2 3 4; do
if ! xcrun simctl spawn "$SIMULATOR_ID" launchctl list 2>/dev/null | grep -q "$BUNDLE_ID"; then
break
fi
sleep 0.25
done
log "Killed app via launchd (PID $app_pid)"

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the file shape first, then read the relevant slice.
ast-grep outline detox/scripts/preboot_ios_simulator.sh --view expanded || true
wc -l detox/scripts/preboot_ios_simulator.sh
sed -n '1,180p' detox/scripts/preboot_ios_simulator.sh

Repository: mattermost/mattermost-mobile

Length of output: 7387


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect call sites and the remainder of the script around the helper.
rg -n "kill_app_via_launchd|prewarm_app|Killed app via launchd|launchctl list" detox/scripts/preboot_ios_simulator.sh
sed -n '120,260p' detox/scripts/preboot_ios_simulator.sh

Repository: mattermost/mattermost-mobile

Length of output: 5322


Handle launchd cleanup timeouts
kill_app_via_launchd() still logs “Killed app” even when the bundle remains in launchctl list after the retry loop. Return non-zero on timeout so the preboot flow doesn’t continue as if cleanup succeeded.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@detox/scripts/preboot_ios_simulator.sh` around lines 107 - 117, Update
kill_app_via_launchd() to track whether the bundle disappears from launchctl
list during the retry loop; only log successful termination and return zero when
cleanup completes, otherwise return non-zero after the retries so the preboot
flow stops treating a timeout as success.

@mattermost-build mattermost-build removed the E2E/Run Triggers E2E tests on both iOS and Android via Matterwick label Jul 15, 2026
@yasserfaraazkhan yasserfaraazkhan added the E2E/Override Skip Running E2E tests label Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

E2E/Override Skip Running E2E tests release-note-none

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants