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: Handle async migrations & add migration tests #8967

Merged
merged 17 commits into from
Mar 29, 2024

Conversation

Cal-L
Copy link
Contributor

@Cal-L Cal-L commented Mar 18, 2024

Description

This PR enables the ability to write both asynchronous and synchronous migrations. Moving forward, we should not have to worry about resolving the incoming states within migration themselves. This change wraps each migration in an asynchronous function, which resolves the state before sending it to the next migration. We also added unit tests for checking migration functionality using createMigrate

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

The videos below shows that migrations are still functioning as expected. There is no change in user experience. In addition to E2E tests, the main QA test to check is testing upgrading from current release (7.18.0) to this branch.

Video of upgrade from 7.17.0 -> This branch. Example: Shows migration 35 being applied, which sets the displayed currency to ETH
https://github.com/MetaMask/metamask-mobile/assets/10508597/ab21c8f1-de46-40b4-85a7-5ece5fbe4425

Same flow going from 7.15.0 -> This branch
https://github.com/MetaMask/metamask-mobile/assets/10508597/4d03ddea-2391-4372-b553-f79c9bd5300f

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • 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.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

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.

@Cal-L Cal-L requested a review from a team as a code owner March 18, 2024 04:29
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.

@Cal-L Cal-L added No QA Needed/E2E Only Apply this label when your PR does not need any QA effort. Run Smoke E2E Triggers smoke e2e on Bitrise labels Mar 18, 2024
Copy link
Contributor

github-actions bot commented Mar 18, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 9b14bfb
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/c8253472-32ce-4bf6-843f-4057675164e5

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@codecov-commenter
Copy link

codecov-commenter commented Mar 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 45.35%. Comparing base (bf87b58) to head (cd468c6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8967      +/-   ##
==========================================
+ Coverage   45.30%   45.35%   +0.04%     
==========================================
  Files        1272     1272              
  Lines       31239    31247       +8     
  Branches     3189     3189              
==========================================
+ Hits        14154    14171      +17     
+ Misses      16245    16234      -11     
- Partials      840      842       +2     

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

tommasini
tommasini previously approved these changes Mar 18, 2024
Copy link
Contributor

@tommasini tommasini left a comment

Choose a reason for hiding this comment

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

LGTM!!! This can be described with just this word -> AWESOME !!!

@Cal-L Cal-L added needs-qa Any New Features that needs a full manual QA prior to being added to a release. and removed No QA Needed/E2E Only Apply this label when your PR does not need any QA effort. labels Mar 18, 2024
@Cal-L Cal-L added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Mar 18, 2024
Copy link
Contributor

github-actions bot commented Mar 18, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 979cc5b
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/58b49e75-2dab-4d5b-917e-3abda1222d02

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@Cal-L Cal-L marked this pull request as draft March 18, 2024 22:57
@Cal-L Cal-L added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Mar 20, 2024
@Cal-L Cal-L marked this pull request as ready for review March 21, 2024 08:55
@chrisleewilcox
Copy link
Contributor

@Cal-L can you take a look at the merge conflicts.

@Cal-L Cal-L added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Mar 22, 2024
Copy link
Contributor

github-actions bot commented Mar 22, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 7be5f0d
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/1d30c9cf-5996-4e37-8cce-376dba1d2386

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

owencraston added a commit that referenced this pull request Mar 27, 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**


1. What is the reason for the change?
- @Cal-L discovered a missing test case in [his
PR](#8967) for my
migration. In order to perfectly handle the edge cases for this
migration we must also check if the Preferences controller state is
defined.
- In order to unblock the above PR we need to handle this edge case.
2. What is the improvement/solution?
- check if the preferences controller state is defined
- add tests for the error cases and error messages

## **Related issues**

Fixes: N/A

## **Manual testing steps**

- [x] the tests should all pass. 
- [x] this migration was already tested and QAd in this previous
[PR](https://github.com/pulls?page=2&q=is%3Apr+author%3Aowencraston+archived%3Afalse+is%3Aclosed)
## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<img width="1246" alt="Screenshot 2024-03-27 at 11 54 27 AM"
src="https://github.com/MetaMask/metamask-mobile/assets/22918444/f9a34068-8ab9-45fa-8f80-1b45eb6115d0">



## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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-mobile/blob/main/.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.
@Cal-L Cal-L added No QA Needed/E2E Only Apply this label when your PR does not need any QA effort. Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise No QA Needed/E2E Only Apply this label when your PR does not need any QA effort. labels Mar 27, 2024
Copy link
Contributor

github-actions bot commented Mar 27, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 876a0b5
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/ccfa80a3-452b-456c-affc-186c696bbdbd

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@Cal-L Cal-L added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Mar 29, 2024
Copy link
Contributor

github-actions bot commented Mar 29, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 7bbebeb
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/ba79a866-4a89-4f24-8089-16595a91caf8

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@Cal-L Cal-L removed the needs-qa Any New Features that needs a full manual QA prior to being added to a release. label Mar 29, 2024
Copy link
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.

This PR is QA passed.

Copy link

sonarcloud bot commented Mar 29, 2024

@Cal-L Cal-L merged commit 3fe4f51 into main Mar 29, 2024
31 checks passed
@Cal-L Cal-L deleted the chore/handle-async-migrations branch March 29, 2024 19:25
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2024
@metamaskbot metamaskbot added the release-7.20.0 Issue or pull request that will be included in release 7.20.0 label Mar 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.20.0 Issue or pull request that will be included in release 7.20.0 Run Smoke E2E Triggers smoke e2e on Bitrise team-mobile-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants