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 Stardoc repository mapping aware #16775

Closed
wants to merge 1 commit into from

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Nov 16, 2022

By taking in .bzl files as runfiles rather than inputs, Stardoc can use the existing Java runfiles library to resolve apparent repository names in load labels into canonical repository names.

Work towards #16124
Fixes #14140

@fmeum fmeum force-pushed the 16124-stardoc branch 2 times, most recently from 7807e42 to 96d65bc Compare November 16, 2022 02:47
@fmeum
Copy link
Collaborator Author

fmeum commented Nov 16, 2022

@comius Combined with bazelbuild/stardoc#141, which this PR is referencing, I got Stardoc to work with Bzlmod. Both PRs need some cleanup, but early feedback on the general approach would be appreciated.

@fmeum fmeum marked this pull request as ready for review November 18, 2022 20:51
@fmeum
Copy link
Collaborator Author

fmeum commented Nov 18, 2022

@comius This should be ready for review now.

@ShreeM01 ShreeM01 added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Nov 18, 2022
distdir_deps.bzl Outdated
@@ -274,16 +274,15 @@ DIST_DEPS = {
],
},
"io_bazel_skydoc": {
"archive": "1ef781ced3b1443dca3ed05dec1989eca1a4e1cd.tar.gz",
"sha256": "5a725b777976b77aa122b707d1b6f0f39b6020f66cd427bb111a585599c857b1",
"archive": "d09735f49f046fdebf2fc36312dc9f021f89ce27.tar.gz",
Copy link
Contributor

Choose a reason for hiding this comment

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

This points out of main branch of stardoc and as such it should probably be reverted.

What is the right order? I'm guessing first merge this PR, then release the binary in stardoc repo with .bzl fixes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I only added this here to make more of the tests pass. I will revert this part and check whether that can be merged.

@fmeum fmeum force-pushed the 16124-stardoc branch 2 times, most recently from 79648ee to 5100f17 Compare December 5, 2022 15:30
@fmeum
Copy link
Collaborator Author

fmeum commented Dec 5, 2022

@comius Tests are failing here if I don't also update the pin to the stardoc rules. Since the same is true for bazelbuild/stardoc#141, I don't see a way to merge this that doesn't involve temporarily pointing one repo at a non-main branch of the other.

@fmeum fmeum requested a review from comius December 5, 2022 15:42
@fmeum
Copy link
Collaborator Author

fmeum commented Dec 5, 2022

@comius How about the following:

  1. After reviewing Add support for Bzlmod stardoc#141 and before merging it to master, you create a trusted branch from it.
  2. I update the pin in the current PR to point to that branch's HEAD commit, temporarily removing the mirror URL.
  3. You merge this Bazel PR.
  4. I update Add support for Bzlmod stardoc#141 to reference that Bazel commit, getting the tests to pass.
  5. You merge Add support for Bzlmod stardoc#141.
  6. I submit a new Bazel PR together with a mirror request for stardoc, changing the distdir dep for stardoc back to stardoc master.

@comius
Copy link
Contributor

comius commented Dec 9, 2022

@comius How about the following:

  1. After reviewing Add support for Bzlmod stardoc#141 and before merging it to master, you create a trusted branch from it.
  2. I update the pin in the current PR to point to that branch's HEAD commit, temporarily removing the mirror URL.
  3. You merge this Bazel PR.
  4. I update Add support for Bzlmod stardoc#141 to reference that Bazel commit, getting the tests to pass.
  5. You merge Add support for Bzlmod stardoc#141.
  6. I submit a new Bazel PR together with a mirror request for stardoc, changing the distdir dep for stardoc back to stardoc master.

SQTM

@brentleyjones
Copy link
Contributor

Friendly ping on this 🙏.


package com.google.devtools.build.runfiles;

public class RunfilesForStardoc {
Copy link
Contributor

Choose a reason for hiding this comment

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

Lint suggests: Classes which are not intended to be instantiated should be made non-instantiable with a private constructor. This includes utility classes (classes with only static members), and the main class.

Make the class final and add a private no-op constructor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can fix that, but should I repair the merge first?

Copy link
Contributor

Choose a reason for hiding this comment

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

feel free to drop the merge commit and do a rebase (or anything else you might prefer)

package com.google.devtools.build.runfiles;

public class RunfilesForStardoc {
public static String getCanonicalRepository(Runfiles runfiles, String sourceRepository) {
Copy link
Contributor

Choose a reason for hiding this comment

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

linter wants a javadoc on public methods :)

Copy link
Contributor

Choose a reason for hiding this comment

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

and on the class

Copy link
Collaborator Author

@fmeum fmeum Mar 8, 2023

Choose a reason for hiding this comment

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

Added. I also renamed the parameter.

@@ -23,18 +23,16 @@ java_test(
deps = [
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/packages/semantics",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/java/com/google/devtools/build/skydoc:skydoc_lib",
"//src/main/java/com/google/devtools/build/skydoc/fakebuildapi",
"//src/main/java/com/google/devtools/build/skydoc/rendering",
"//src/main/java/com/google/devtools/build/skydoc/rendering/proto:stardoc_output_java_proto",
"//src/main/java/net/starlark/java/eval",
"//src/main/java/net/starlark/java/syntax",
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax also seems unused

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is used for Resolver.

By taking in .bzl files as runfiles rather than inputs, Stardoc can use
the existing Java runfiles library to resolve apparent repository names
in load labels into canonical repository names.
@fmeum fmeum requested review from comius and removed request for tetromino March 8, 2023 16:03
@fmeum
Copy link
Collaborator Author

fmeum commented Mar 16, 2023

@comius Friendly ping, is there anything else I should do to move this forward?

@comius
Copy link
Contributor

comius commented Mar 16, 2023

@comius Friendly ping, is there anything else I should do to move this forward?

In the last 2 weeks I did a reimport of stardoc, which didn't happen for 2 years and was tricky.

Generally the changes are ok, but since now stardoc needs runfiles and when they are handled using absolute paths we'll need to account for this. I checked and this can't be done by external contributor. Good thing is, that accounting for differences most likely won't be visible in PRs.

Also the plan looks ok. One option is that you go forward with the plan, and I account for the differences on each step. Second option is that I import everything, figure out how to account for the differences and then you go forward. This derisks it a bit.

I'm out of office until 27th March, but I'll pick it up when I'm back

Third option is that @Wyverald takes it over if there's more hurry than this.

@fmeum
Copy link
Collaborator Author

fmeum commented Mar 16, 2023

@comius Thank you very much for the transparency! There is no hurry, it's just difficult for a non-Googler like me to distinguish between something having been forgotten/deprioritized or something being stuck on some complicated google3 import. Thanks again for describing the options.

@meteorcloudy
Copy link
Member

Gently ping @comius

@comius
Copy link
Contributor

comius commented Apr 14, 2023

Hey, the migration plan doesn't work, because we're building from sources. Because of that the changes to stardoc.bzl and StardocMain.java need to happen atomically.

I think I have an alternative:

  1. first we copy stardoc.bzl into the bazel repostory and remove the stardoc dependency
  2. then I import both PRs at the same time, but export only to Bazel; Bazel CI will pass
  3. then we can merge Stardoc PR directly into main, which will reconcile the split worlds

@fmeum
Copy link
Collaborator Author

fmeum commented Apr 14, 2023

@comius Sounds good to me, although I don't understand all the implications well enough to assess whether this will work or not.

Do you want me to perform/prepare any of these steps or is it easier if you do it directly via CLs?

@comius
Copy link
Contributor

comius commented Apr 17, 2023

@comius Sounds good to me, although I don't understand all the implications well enough to assess whether this will work or not.

Do you want me to perform/prepare any of these steps or is it easier if you do it directly via CLs?

I've imported both PRs today, they are now in the internal review.

copybara-service bot pushed a commit that referenced this pull request Apr 20, 2023
Before Stardoc implementation was tested using stardoc.bzl from Stardoc repository. This makes it hard to change the implementation and bzl file at the same time.

The change is preparation to import #16775 and bazelbuild/stardoc#141. Without it we'd need to do a half-release of Stardoc PR to make Bazel's CI pass.

There's still a dependency on Stardoc repo/module from Bazel, which is used to generate the docs.

PiperOrigin-RevId: 525736214
Change-Id: I291838a9dd9bbb9482a47011e6e36fc6dd67eff1
@fmeum fmeum deleted the 16124-stardoc branch April 28, 2023 10:47
fweikert pushed a commit to fweikert/bazel that referenced this pull request May 25, 2023
Before Stardoc implementation was tested using stardoc.bzl from Stardoc repository. This makes it hard to change the implementation and bzl file at the same time.

The change is preparation to import bazelbuild#16775 and bazelbuild/stardoc#141. Without it we'd need to do a half-release of Stardoc PR to make Bazel's CI pass.

There's still a dependency on Stardoc repo/module from Bazel, which is used to generate the docs.

PiperOrigin-RevId: 525736214
Change-Id: I291838a9dd9bbb9482a47011e6e36fc6dd67eff1
fweikert pushed a commit to fweikert/bazel that referenced this pull request May 25, 2023
By taking in .bzl files as runfiles rather than inputs, Stardoc can use the existing Java runfiles library to resolve apparent repository names in load labels into canonical repository names.

Work towards bazelbuild#16124
Fixes bazelbuild#14140

Closes bazelbuild#16775.

PiperOrigin-RevId: 526976752
Change-Id: I0848a5c7590348f778ad8c939fd37c89a53e55b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bzlmod: stardoc is broken by repo mappings
5 participants