Skip to content
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

chore: adds quality gate for rerunning e2e spec files that are new or have been modified #24556

Merged
merged 54 commits into from
Jul 1, 2024

Conversation

seaona
Copy link
Contributor

@seaona seaona commented May 16, 2024

Description

This PR adds a quality gate for new or modified e2e spec files. Whenever there is a PR which modifies or changes a test, this will be run more times, in order to prevent introducing a flakiness accidentally. It is done as follows:

  • Identifies any new or modified e2e file from inside the test/ folder using git diff and using these 2 filters:
    • file.filename.startsWith('test/e2e/') &&
    • file.filename.endsWith('.spec.js') || file.filename.endsWith('.spec.ts')
  • Copies the given specs x5 times in the list of testpaths to execute -> this number is arbitrary, we could modify it to any value we want. The reason for taking this approach instead of changing the retrial number is to benefit of the parallelization, as @HowardBraham pointed out in a comment.
  • Since we already had a flag which could support the re-running successful tests, --retry-until-failure I just leveraged this into the for loop for each test, and if that testcase was identified as new/modified, the flag is added so the new tests fail fast without retrials

Incremental git fetch depth within shallow clone

We use git fetch with incremental depth as @danjm suggested. The ci environment uses a shallow clone, meaning we won't be able to succeed just by using git diff as it won't find the merge base. For fixing that, we start with a git fetch depth of 1, and keep incrementing the depth (1, 10, 100) it the error is no merge base up until 100. If the git diff still fails, we then do a full git fetch with the unshallow flag.

New ci Job

The git diff is done in a new ci job which runs at the beginning in parallel of prep-deps.

Open in GitHub Codespaces

Related issues

Fixes: #24009

Manual testing steps

  1. Check ci runs (notice previous runs had failing and changed tests on purpose, in order to try the different scenarios described below)

Screenshots/Recordings

=============================================== [UPDATE with the new code changes]

  • 🟢 Case 1: A test has changed -> it's rerun 1+5 times and it's successful (it will be run in different buckets)
new-tests-ci.mp4

https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/89277/workflows/7fce0a2e-773f-46da-8ab9-1dbec7992b58/jobs/3297267/parallel-runs/10?filterBy=ALL

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've completed the PR template to the best of my ability
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.

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.

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.

test/e2e/run-all.js Outdated Show resolved Hide resolved
@seaona seaona changed the title chore: quality gate mock alt chore: adds quality gate for rerunning e2e spec files that are new or have been modified May 16, 2024
test/e2e/run-all.js Outdated Show resolved Hide resolved
test/e2e/run-all.js Outdated Show resolved Hide resolved
test/e2e/run-all.js Outdated Show resolved Hide resolved
Copy link

codecov bot commented May 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.57%. Comparing base (4a9c480) to head (07e81d8).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #24556   +/-   ##
========================================
  Coverage    69.57%   69.57%           
========================================
  Files         1360     1360           
  Lines        48172    48172           
  Branches     13296    13296           
========================================
  Hits         33513    33513           
  Misses       14659    14659           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@metamaskbot
Copy link
Collaborator

Builds ready [71bbf50]
Page Load Metrics (623 ± 464 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint60133882110
domContentLoaded95417126
load482385623966464
domInteractive95417126
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@seaona seaona marked this pull request as ready for review May 21, 2024 15:08
@seaona seaona requested review from kumavis and a team as code owners May 21, 2024 15:08
@seaona seaona self-assigned this May 21, 2024
DDDDDanica
DDDDDanica previously approved these changes May 21, 2024
vthomas13
vthomas13 previously approved these changes May 21, 2024
@seaona seaona added the DO-NOT-MERGE Pull requests that should not be merged label May 22, 2024
test/e2e/run-all.js Outdated Show resolved Hide resolved
test/e2e/run-all.js Outdated Show resolved Hide resolved
Gudahtt
Gudahtt previously approved these changes Jun 27, 2024
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
@seaona seaona dismissed stale reviews from Gudahtt and chloeYue via 3e952e7 June 28, 2024 08:31
seaona and others added 5 commits June 28, 2024 10:32
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
@metamaskbot
Copy link
Collaborator

Builds ready [9b1c7cc]
Page Load Metrics (140 ± 187 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint629480105
domContentLoaded9221231
load401840140390187
domInteractive9221231
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

…suggestion

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link

sonarcloud bot commented Jun 28, 2024

@Gudahtt Gudahtt requested a review from chloeYue June 28, 2024 16:18
@metamaskbot
Copy link
Collaborator

Builds ready [07e81d8]
Page Load Metrics (186 ± 204 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint7351013710651
domContentLoaded1096302010
load542018186425204
domInteractive1096302010
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@seaona seaona merged commit 3ea381d into develop Jul 1, 2024
62 checks passed
@seaona seaona deleted the quality-gate-gh branch July 1, 2024 08:17
@github-actions github-actions bot locked and limited conversation to collaborators Jul 1, 2024
@metamaskbot metamaskbot added the release-12.2.0 Issue or pull request that will be included in release 12.2.0 label Jul 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
flaky tests release-12.2.0 Issue or pull request that will be included in release 12.2.0 team-extension-platform
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Flakiness quality gate for new tests
10 participants