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

Make Jest unit tests run faster in GitHub actions #25680

Closed
1 of 9 tasks
itsyoboieltr opened this issue Jul 4, 2024 · 0 comments · Fixed by #25726
Closed
1 of 9 tasks

Make Jest unit tests run faster in GitHub actions #25680

itsyoboieltr opened this issue Jul 4, 2024 · 0 comments · Fixed by #25726
Assignees
Labels
release-12.3.0 Issue or pull request that will be included in release 12.3.0 team-extension-platform

Comments

@itsyoboieltr
Copy link
Contributor

itsyoboieltr commented Jul 4, 2024

What is this about?

Mentioned in #25570, quoting @davidmurdoch :

As discussed in slack, let's follow up this PR with an investigation into making it go faster (to match the speeds at which Circleci ran the same jobs).

But in case it takes a while to do that work: can you add a new GitHub Issue and a comment in this file linking to the issue, explaining that we should look into making it go faster?

I just don't want people copying this work in the (near) future, not noticing the slow down, and suddenly our tests take hours to pass CI. Hopefully a comment in here will help prevent that.

By migrating the jest unit tests from CircleCI to GitHub actions the time to run unit tests has increased to 15 minutes from 5 minutes. This can be for several reasons:

  1. CircleCI and GitHub runners have different hardware
    • CircleCI: 3 CPU, 6 GB RAM VM
    • GitHub: 2 CPU, 7 GB RAM VM
  2. CircleCI runs the tests in parallel (parallelism: 8).

Scenario

No response

Design

No response

Technical Details

No response

Threat Modeling Framework

No response

Acceptance Criteria

The unit tests run under 5 minutes, like it did on CircleCI

Stakeholder review needed before the work gets merged

  • Engineering (needed in most cases)
  • Design
  • Product
  • QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
  • Security
  • Legal
  • Marketing
  • Management (please specify)
  • Other (please specify)

References

No response

@itsyoboieltr itsyoboieltr self-assigned this Jul 4, 2024
@metamaskbot metamaskbot added the release-12.3.0 Issue or pull request that will be included in release 12.3.0 label Jul 12, 2024
montelaidev pushed a commit that referenced this issue Jul 12, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/25726?quickstart=1)

Based on #25680, by
migrating the jest unit tests from CircleCI to GitHub actions the time
to run unit tests has increased to 15 minutes from 5 minutes. This PR
makes Jest unit tests run faster in Github actions. This is achieved by
some improvements to the testing infrastructure.

1. **Sharding**: the tests are run on 6 machines in parallel, instead of
a single machine. This saves around ~8-9 minutes on average.
2. **Optimized coverage generation**: I removed the generation of html
reports in CI, as they are only used for local debugging. This should
also save some time, as unused files are not being generated on CI.
3. **Merged development tests**: The two small tests under
`build/transforms` were merged into the main test configuration. This
means that one less machine needs to be started (as the development
tests would require their own machine to run, due to the sharding
introduced in this PR), saving around approx. 2 minutes of compute time.
4. **Minor fixes**: Now the `run-unit-tests` workflow will also run on
push to the `develop` and `master` branches.

## **Related issues**

Fixes: #25680,

## **Manual testing steps**

1. Run CI and see that tests are running fast (between 5-7 mins on
average)

## **Screenshots/Recordings**

Not Applicable

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-12.3.0 Issue or pull request that will be included in release 12.3.0 team-extension-platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants