Skip to content

fix: Skip passed e2e tests on re-run to reduce CI time#24263

Merged
OGPoyraz merged 5 commits intomainfrom
ogp/rerun-only-failed-test-from-chunk
Jan 7, 2026
Merged

fix: Skip passed e2e tests on re-run to reduce CI time#24263
OGPoyraz merged 5 commits intomainfrom
ogp/rerun-only-failed-test-from-chunk

Conversation

@OGPoyraz
Copy link
Copy Markdown
Member

@OGPoyraz OGPoyraz commented Jan 6, 2026

Description

Similar what we've done in the extension here, this PR implements same approach into mobile repository.
For more information please see thread here.

When an E2E test fails in CI and developer triggers a re-run, all tests in that chunk are executed again, not just the failed ones. This leads to:

  • Wasted CI time: A chunk with 20 tests where only 1 failed will re-run all 20 tests
  • Increased costs: Unnecessary compute resources consumed on re-runs
  • Slower feedback loop: Developers wait longer to verify if a flaky test passes on retry
  • Inefficient debugging: When investigating flaky tests, having to wait for unrelated tests adds friction

For example, with 20 parallel chunks each running ~15 tests, a single flaky test failure triggers a re-run of the entire chunk (~15 tests) instead of just the 1 failed test.

For solution; implement selective test re-runs that automatically detect when a job is being re-run and skip tests that already passed.

  • First run (run_attempt = 1): Tests run normally, results are uploaded as artifacts
  • Re-run (run_attempt > 1):
    • Download the previous run's test result artifacts
    • Parse XML results to extract passed test file paths
    • Run all tests in the chunk EXCEPT those that passed
    • Skip execution entirely if all tests in the chunk passed previously

Validation of PR:

Intentionally broke tests here: c8f029f

On attempt1 it failed but other tests passed: https://github.com/MetaMask/metamask-mobile/actions/runs/20751876785/attempts/1?pr=24263

On attempt2 it only run failed test and skipped already passed tests: https://github.com/MetaMask/metamask-mobile/actions/runs/20751876785/attempts/2?pr=24263

Logs from attempt 2:

Found 8 executed test files
Found 2 failed test files
Found 6 fully passed test files
Failed tests: e2e/specs/confirmations-redesigned/transactions/send-max-transfer.spec.ts, e2e/specs/confirmations-redesigned/transactions/send-max-transfer-retry-1.spec.ts
Previous run results: 6 passed, 2 failed
This chunk: 1 failed, 0 not executed

Changelog

CHANGELOG entry:

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Reduces CI time by re-running only failed or not-executed E2E specs on job re-runs and preserving pass/fail history.

  • New scripts: e2e-extract-test-results.mjs (parses jest-junit XML to identify passed/failed/executed specs) and e2e-merge-test-results.mjs (merges prior XML results for specs not executed this attempt)
  • Updates e2e-split-tags-shards.mjs to: on re-runs, filter shard files using extracted results; skip if all passed; limit flakiness duplication to first attempt
  • Modifies run-e2e-workflow.yml to: download previous results on re-runs, pass RUN_ATTEMPT/PREVIOUS_RESULTS_PATH envs, add debug listing, and merge previous results into current e2e/reports before uploading artifacts

Written by Cursor Bugbot for commit e5cd5c7. This will update automatically on new commits. Configure here.

@metamaskbot metamaskbot added the team-confirmations Push issues to confirmations team label Jan 6, 2026
@github-actions github-actions bot added the size-M label Jan 6, 2026
@OGPoyraz OGPoyraz added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Jan 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 6, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

The PR introduces E2E test re-run optimization - a CI/CD infrastructure improvement that allows re-runs to skip passed tests and only re-run failed/not-executed tests.

Key changes:

  1. New e2e-extract-test-results.mjs - Parses JUnit XML to identify passed/failed tests
  2. New e2e-merge-test-results.mjs - Merges test results across re-runs
  3. Modified e2e-split-tags-shards.mjs - Added re-run detection and test filtering logic
  4. Modified run-e2e-workflow.yml - Added workflow steps for downloading/merging previous results

These are purely CI/CD infrastructure changes with no application code modifications:

  • No changes to app source code, components, or business logic
  • No changes to E2E test specs themselves
  • The changes only affect how tests are selected during workflow re-runs
  • First-run behavior (attempt 1) remains unchanged - backward compatible

Running E2E tests would not validate these changes because:

  1. E2E tests verify application functionality, not CI workflow behavior
  2. The re-run optimization can only be tested by actually triggering workflow re-runs
  3. No user-facing features or flows are affected

This is a low-risk change as it's additive infrastructure that doesn't modify existing test execution for first runs.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Jan 6, 2026

Copy link
Copy Markdown
Member

@cortisiko cortisiko left a comment

Choose a reason for hiding this comment

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

🌮 🌮

@OGPoyraz OGPoyraz added this pull request to the merge queue Jan 7, 2026
Merged via the queue into main with commit 3e16f7d Jan 7, 2026
168 of 170 checks passed
@OGPoyraz OGPoyraz deleted the ogp/rerun-only-failed-test-from-chunk branch January 7, 2026 06:23
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2026
@metamaskbot metamaskbot added the release-7.62.0 Issue or pull request that will be included in release 7.62.0 label Jan 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.62.0 Issue or pull request that will be included in release 7.62.0 size-L team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants