Skip to content

feat(e2e): script and CI job to use AI for e2e test selection#20372

Merged
cmd-ob merged 29 commits intomainfrom
MMQA-991-clean
Oct 2, 2025
Merged

feat(e2e): script and CI job to use AI for e2e test selection#20372
cmd-ob merged 29 commits intomainfrom
MMQA-991-clean

Conversation

@cmd-ob
Copy link
Contributor

@cmd-ob cmd-ob commented Sep 25, 2025

Description

This PR introduces an E2E test selection system that uses AI to analyse files changed and automatically run only the most relevant smoke tests, reducing CI time.

How It Works

  1. AI analyses your code changes and selects appropriate test tags
  2. Results posted back to the PR with detailed analysis
  3. Test Matrix are included in the result which are compatible with our current GH workflows for running E2E tests

Key Features

  • 🤖 AI-powered selection - Claude AI analyses diffs and recommends test tags
  • 🎯 Risk assessment - Categorises changes as low/medium/high risk

Usage

For PRs:
AI Analysis is now integrated into main CI and will run on every pull request with recommendations. (Actual test running will be in a different PR)

For local testing:

yarn ai-e2e --verbose  # See AI reasoning
yarn ai-e2e --output json  # Machine-readable

See ai-e2e-testing.md for complete details.

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

Adds Claude-driven E2E test tag selection with a CI analysis job that outputs a test matrix, plus supporting scripts, docs, and dependencies.

  • CI / GitHub Actions:
    • Composite Action: Introduces .github/actions/ai-e2e-analysis to run AI analysis, set outputs (test_matrix), and optionally comment on PRs.
    • Workflow: Adds ai-e2e-analysis job in .github/workflows/ci.yml consuming needs_e2e_build changed files and exposing test-matrix output.
  • E2E Tooling:
    • AI Tag Selector: Adds e2e/scripts/ai-e2e-tags-selector.ts using @anthropic-ai/sdk with esbuild-register to choose smoke tags, count test files, and recommend splits with JSON output.
    • Runner Script: Adds .github/scripts/ai-e2e-analysis.mjs to execute the selector, parse results, and write GitHub Action outputs/summary.
  • Docs:
    • Adds e2e/scripts/ai-e2e-testing.md explaining usage and options.
  • Package / Config:
    • Updates package.json with ai-e2e script and dev deps @anthropic-ai/sdk, esbuild, esbuild-register; updates lavamoat.allowScripts and resolutions accordingly.
    • Updates .depcheckrc.yml ignores and .eslintignore for new files.
    • Exports tags from e2e/tags.js.

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

- Added reusable GitHub Actions workflow for reporting E2E test results.
- Created documentation for the AI E2E Testing system, detailing architecture and usage.
- Introduced AI E2E Tag Selector script to analyze code changes and select relevant tests.
- Updated E2E tags module to export tags for AI analysis.
- Added README for smart E2E test selection with local and CI usage instructions.
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@cmd-ob cmd-ob changed the title Mmqa 991 clean feat(e2e): script and CI job to use AI for e2e test selection Sep 25, 2025
@metamaskbot metamaskbot added the team-qa QA team label Sep 25, 2025
@socket-security
Copy link

socket-security bot commented Sep 25, 2025

@socket-security
Copy link

socket-security bot commented Sep 25, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

  • npm/@anthropic-ai/sdk@0.63.1

View full report

@cmd-ob
Copy link
Contributor Author

cmd-ob commented Sep 25, 2025

@SocketSecurity ignore @anthropic-ai/sdk

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@cmd-ob
Copy link
Contributor Author

cmd-ob commented Sep 25, 2025

@SocketSecurity ignore npm/@anthropic-ai/sdk@0.63.1

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@racitores racitores left a comment

Choose a reason for hiding this comment

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

Nice to see AI stuff in the pipelines

env:
E2E_CLAUDE_API_KEY: ${{ secrets.E2E_CLAUDE_API_KEY }}
run: |
echo "🤖 Running AI analysis..."
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd move this code to a script maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@ngalee8311

This comment was marked as spam.

@cmd-ob cmd-ob requested review from a team as code owners September 29, 2025 08:00
@github-actions github-actions bot deleted a comment from ngalee8311 Sep 29, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to convert this file to either python or .mjs. No .sh files please.

@cmd-ob cmd-ob enabled auto-merge October 1, 2025 16:37
@cmd-ob cmd-ob requested review from jvbriones and racitores October 1, 2025 16:37
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 1, 2025

@cmd-ob cmd-ob added this pull request to the merge queue Oct 2, 2025
@MetaMask MetaMask deleted a comment from github-actions bot Oct 2, 2025
Copy link
Contributor

@Qbandev Qbandev left a comment

Choose a reason for hiding this comment

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

Why is this file e2e/scripts/ai-e2e-testing.md in the script folder and not in the docs?

Merged via the queue into main with commit 954102b Oct 2, 2025
128 of 130 checks passed
@cmd-ob cmd-ob deleted the MMQA-991-clean branch October 2, 2025 08:52
@github-actions github-actions bot locked and limited conversation to collaborators Oct 2, 2025
@metamaskbot metamaskbot added the release-7.57.0 Issue or pull request that will be included in release 7.57.0 label Oct 2, 2025
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.57.0 Issue or pull request that will be included in release 7.57.0 size-XL team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants