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

Add script for tag porting when migrating libraries into the core monorepo #1802

Merged
merged 42 commits into from
Nov 3, 2023

Conversation

MajorLift
Copy link
Contributor

@MajorLift MajorLift commented Oct 11, 2023

Motivation

When migrating libraries into core, the tags need to be ported and renamed to fit the core repo release tag naming scheme:

  • v[major].[minor].[patch] for core repo releases
  • @metamask/<package-name>@[major].[minor].[patch] for package releases.

However, the migration process entails rewriting the git history of the original repo, which changes all of the commit hashes.

So in order to port tags attached to release commits from the original repo to core, we need a script to automate the process of finding the release commits from the migrated/rewritten git history, and recreating + renaming + attaching the corresponding tags.

Instructions

migrate-tags.md

Feature Checklist

  • The script accepts five arguments: one required, the rest named and optional (see migrate-tags.md > B. Options).
  • Extracts corresponding pairs of release version number and release commit hash from the migrated git history in merged-packages/<package-name>.
  • Prepends @metamask/<package-name>@ to the version numbers.
    • Correctly handles renamed packages with at most two different package names.
  • Creates package name-prepended tags on the release commits using the git tag <package-name> [commit hash] command.
  • Pushes created tags to the remote repo using the git push <remote-repo> [tag-name] command.
  • Tested on fork of core.
  • Make dry-run mode the default. -non-dry-run flag required for tags to be created and pushed.
  • Document instructions for using this script in comments and the migration process guide.

Status

Successfully tested on fork of core:

References

Changelog

N/A. No end user-facing changes.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@MajorLift MajorLift self-assigned this Oct 11, 2023
@MajorLift MajorLift force-pushed the 231010-migration-port-tags branch 5 times, most recently from 6c5cd51 to 9e82fc4 Compare October 13, 2023 16:13
MajorLift added a commit that referenced this pull request Oct 13, 2023
## Explanation

This PR implements the following incremental steps in the process for
migrating `eth-json-rpc-provider` into the core monorepo:

***

### Phase B: Staging from `merged-packages/`

#### 5. Port tags 
  - See: #1800
  
<details>  
  <summary>Push ported tags to core repo</summary>
  
- [x]
https://github.com/MetaMask/core/releases/tag/@metamask/[email protected]
- [x]
https://github.com/MetaMask/core/releases/tag/@metamask/[email protected]
- [x]
https://github.com/MetaMask/core/releases/tag/@metamask/[email protected]
- [x]
https://github.com/MetaMask/core/releases/tag/@metamask/[email protected]
- [x]
https://github.com/MetaMask/core/releases/tag/@metamask/[email protected]
</details>

<details>
<summary>Verify that the tag diff links in CHANGELOG are
working</summary>
  
- [x] **WONTFIX**:
https://github.com/MetaMask/core/compare/@metamask/[email protected]
- [x]
https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
- [x]
https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
- [x]
https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
- [x]
https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
</details>

### Phase C: Integration into `packages/`

#### 1. The big leap
- [x] **Move migration target from `migrated-packages/` to
`packages/`.**
- [x] Run `yarn install` in the root directory.
- [x] Check that all tests are passing in migration target by running
`yarn workspace @metamask/<package-name> test`.

#### 2. Update downstream repos
- [x] Add tsconfig reference paths for migration target in downstream
packages and root.
- [x] Bump migration target version in downstream packages and root.

#### 3. Linter fixes
- [x] Apply yarn constraints fixes to migration target package.json
file: `yarn constraints --fix` (run twice).
- [x] Identify validator fixes for CHANGELOG using `yarn workspace
@metamask/<package-name> changelog:validate` and apply the diffs.

#### 4. Resolve downstream errors
- [x] #1653
  - If introducing the migration target breaks any downstream repos:
    - [x] Resolve simple errors
- [x] Mark and ignore complex errors using `@ts-expect-error TODO:`
annotations.
- [x] Create a separate issue for resolving the marked errors as soon as
the migration is completed.

#### 5. Finalize merge
- [x] Check that all tests are passing in all subpackages of core and
CI.
- [x] Merge `packages/<package-name>` directory into core main branch.

***

See #1551 (comment)
for an outline of the entire process.

## Next Steps

- The next PR(s) will implement the final steps of the migration process
(D-1 in the migration checklist).

## Blocked by
- Dependencies:
  - [x] typescript bump: #1718
- [x] `@metamask/utils` bump: #1639
- Downstream type errors:
  - [x] #1653
- [ ] MetaMask/eth-json-rpc-provider#14
(ignored)
  - [ ] MetaMask/utils#140 (ignored)
- Tag porting:
  - [x] #1802
- [x] "Unreleased" tag diff link shows entire history of core:
https://github.com/MetaMask/core/compare/@metamask/[email protected]

## References

- Contributes to #1685
- Contributes to #1551

## Changelog

<!--
If you're making any consumer-facing changes, list those changes here as
if you were updating a changelog, using the template below as a guide.

(CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or
FIXED. For security-related issues, follow the Security Advisory
process.)

Please take care to name the exact pieces of the API you've added or
changed (e.g. types, interfaces, functions, or methods).

If there are any breaking changes, make sure to offer a solution for
consumers to follow once they upgrade to the changes.

Finally, if you're only making changes to development scripts or tests,
you may replace the template below with "None".
-->

### `@metamask/eth-json-rpc-provider`

- **ADDED**: Migrated into the core monorepo.

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
@mcmire
Copy link
Contributor

mcmire commented Oct 13, 2023

@MajorLift Just a reminder here that when testing out this script, it would be better to test this out on a fork of core rather than core itself, so that you have a copy that you can safely blow and recreate if you need to, etc.

@MajorLift
Copy link
Contributor Author

Yes absolutely. I won't push any tags to core with the script while it's in development.

@MajorLift MajorLift force-pushed the 231010-migration-port-tags branch 3 times, most recently from 1cde98c to 8086691 Compare October 20, 2023 00:30
@MajorLift MajorLift force-pushed the 231010-migration-port-tags branch 6 times, most recently from 0afc885 to c6299c7 Compare October 24, 2023 23:03
@MajorLift MajorLift marked this pull request as ready for review October 24, 2023 23:03
@MajorLift MajorLift requested a review from a team as a code owner October 24, 2023 23:03
@MajorLift
Copy link
Contributor Author

MajorLift commented Nov 2, 2023

Note: json-rpc-engine has a large number of earlier release commits that weren't tagged in the original repo. I think discovering untagged release commits should be considered out-of-scope for this script.

We could manually create any omitted tags in the original repo as a preparation step before the migration.

@mcmire
Copy link
Contributor

mcmire commented Nov 2, 2023

We could manually create any omitted tags in the original repo as a preparation step before the migration.

Sure. We could also create them in this repo after migration. If some links in the changelog were already broken before the migration, then it's not a huge deal if they're still broken afterward (as long as we fix them at some point, of course).

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

This is getting close! Just one more thing.

scripts/migrate-tags.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Thanks for your patience and working through all my comments on this PR! This looks good to me now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add script for tag porting when migrating libraries into the core monorepo
2 participants