Skip to content

Commit

Permalink
feat: move unit tests from Circleci to Github actions (#25570)
Browse files Browse the repository at this point in the history
<!--
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/25570?quickstart=1)

This PR moves unit tests from Circleci to Github actions. This is needed
to pass the Jest export to SonarCloud in order finalize the SonarCloud
integration. The reason why we want to use Github action rather than
Circleci is because Sonarcloud integration happens in a Github action
and we cannot pass data (i.e. the artifact) from Circleci to Github
action.

## **Related issues**

Fixes: MetaMask/MetaMask-planning#2449

## **Manual testing steps**

1. Seeing unit tests pass in GitHub actions instead of Circleci

## **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.
  • Loading branch information
itsyoboieltr authored Jul 5, 2024
1 parent f9f0c73 commit 2050886
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 64 deletions.
64 changes: 0 additions & 64 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,6 @@ workflows:
- /^Version-v(\d+)[.](\d+)[.](\d+)/
requires:
- prep-build
- test-unit-jest-main:
requires:
- prep-deps
- test-unit-jest-development:
requires:
- prep-deps
- upload-coverage:
requires:
- test-unit-jest-main
- test-unit-jest-development
- test-unit-global:
requires:
- prep-deps
Expand Down Expand Up @@ -305,10 +295,7 @@ workflows:
- test-lint-shellcheck
- test-lint-lockfile
- test-lint-changelog
- test-unit-jest-main
- test-unit-jest-development
- test-unit-global
- upload-coverage
- validate-source-maps
- validate-source-maps-beta
- validate-source-maps-flask
Expand Down Expand Up @@ -1630,9 +1617,6 @@ jobs:
path: builds-test
- store_artifacts:
path: builds-test-flask
- store_artifacts:
path: coverage
destination: coverage
- store_artifacts:
path: test-artifacts
destination: test-artifacts
Expand Down Expand Up @@ -1713,54 +1697,6 @@ jobs:
git config user.email metamaskbot@users.noreply.github.com
yarn ts-migration:dashboard:deploy
test-unit-jest-development:
executor: node-browsers-small
steps:
- run: *shallow-git-clone
- run: sudo corepack enable
- attach_workspace:
at: .
- run:
name: jest development unit tests
command: yarn test:coverage:jest:dev
- persist_to_workspace:
root: .
paths:
- coverage
- store_test_results:
path: test/test-results/junit.xml

test-unit-jest-main:
executor: node-browsers-medium-plus
parallelism: 8
steps:
- run: *shallow-git-clone
- run: sudo corepack enable
- attach_workspace:
at: .
- run:
name: test:coverage:jest
command: yarn test:coverage:jest
- persist_to_workspace:
root: .
paths:
- coverage
- store_test_results:
path: test/test-results/junit.xml

upload-coverage:
executor: node-browsers-small
steps:
- run: *shallow-git-clone
- run: sudo corepack enable
- attach_workspace:
at: .
- codecov/upload
- persist_to_workspace:
root: .
paths:
- coverage

test-unit-global:
executor: node-browsers-small
steps:
Expand Down
17 changes: 17 additions & 0 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Setup environment'
description: 'Setup environment'
runs:
using: 'composite'
steps:
- run: corepack enable
shell: bash

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: yarn

- name: Install dependencies
run: yarn --immutable
shell: bash
32 changes: 32 additions & 0 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# WARNING! It is currently being investigated how to make this faster
# DO NOT blindly copy this workflow, not noticing the slow down,
# because suddenly our tests will take hours to pass CI.
# Hopefully this comment here will help prevent that.
# https://github.com/MetaMask/metamask-extension/issues/25680

name: Run unit tests

on:
pull_request:
types: [opened,reopened,synchronize]

jobs:
test-unit-jest:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/setup-environment

- name: test:coverage:jest:dev
run: yarn test:coverage:jest:dev

- name: test:coverage:jest
run: yarn test:coverage:jest

- uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true

0 comments on commit 2050886

Please sign in to comment.