-
Notifications
You must be signed in to change notification settings - Fork 262
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
Adding a helper script for Bzlmod migration. #74
Conversation
The script does the following things: - 1. Run the build without Bzlmod enabled to generate resolved external dependencies with --experimental_repository_resolved_file - 2. Run the build with Bzlmod enabled and identify recongnized error message - 3. Use the resolved external deps info to give migration suggestions. - 4. Repeat 2 and 3 until all external deps are available via Bzlmod (or WORKSPACE.bzlmod). To start the migration, clone the Bazel central registry repo and run the following command from your project root: ``` <path to a local BCR repo>/tools/migrate_to_bzlmod.py <build flags> <build targets> ```
tools/migrate_to_bzlmod.py
Outdated
f"Please remove the usages of refering your own repo via `@{repo}//`, targets should be referenced directly with `//`. ") | ||
eprint("If it's used in a macro, you can use `Label(\"//foo/bar\")` to make sure it alwasy points to your repo no matter where the macro is used.") | ||
eprint(f"You can temporarily work around this by changing your module name to {WORKSPACE_NAME} and adding `workspace(name = '{WORKSPACE_NAME}')` in the WORKSPACE.bzlmod file.") | ||
return yes_or_no("Do you wish to retry the build after fixes?", True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe remove the "after fixes" part since it can be slightly confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tools/migrate_to_bzlmod.py
Outdated
return None, None | ||
|
||
|
||
def address_unavailable_repo_error(repo, from_repo, resolved_deps): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "from_repo" param no longer seems to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I'm keeping it in the return value of detect_unavailable_repo_error
just in case we need it later.
|
||
|
||
# Create MODULE.bazel file if it doesn't exist already. | ||
scratch_file("MODULE.bazel", [], mode="a") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe create these with the current workspace name? (or do you think it's better to let the user manually add a module name later on?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think let the user be aware of this is better.
The script does the following things:
dependencies with --experimental_repository_resolved_file
To start the migration, clone the Bazel central registry repo and run the following command from your project root: