google / benchmark

A microbenchmark support library
Apache License 2.0
8.59k stars 1.57k forks source link

Migrate to bzlmod #1743

Open dmah42 opened 5 months ago

dmah42 commented 5 months ago

https://bazel.build/external/migration#migration

it seems we've started (we have both WORKSPACE and MODULE.bazel) but not finished. we should finish it as then we'll have nice things like module_version() available to our build scripts, and can push to the bazel central repo for distribution, etc.

nicholasjng commented 5 months ago

I'm happy to help with the Python part, just say the word :)

dmah42 commented 5 months ago

i think we're most of the way there:

$  ~/dev/bazel-central-registry/tools/migrate_to_bzlmod.py -t //test/...
INFO: Executing command: bazel --version
bazel 7.0.2
INFO: Detected original workspace name: com_github_google_benchmark
INFO: Generating ./resolved_deps.py file
INFO: Executing command: bazel clean --expunge
INFO: Executing command: bazel build --nobuild --experimental_repository_resolved_file=resolved_deps.py //test/...
INFO: Found 42 external repositories in the ./resolved_deps.py file.
INFO: Executing command: bazel build --nobuild --enable_bzlmod //test/...
INFO: Congratulations! All external repositories needed for building `//test/...` are available with Bzlmod (and the WORKSPACE.bzlmod file)!
INFO: Things you should do next:
INFO:   - Migrate remaining dependencies in the WORKSPACE.bzlmod file to Bzlmod.
INFO:   - Run the actual build with Bzlmod enabled (with --enable_bzlmod, but without --nobuild) and fix remaining build time issues.
~/dev/bazel-central-registry/tools/migrate_to_bzlmod.py -t //tools/...
INFO: Executing command: bazel --version
bazel 7.0.2
INFO: Detected original workspace name: com_github_google_benchmark
INFO: Found existing ./resolved_deps.py file, if it's out of date, please add `--force/-f` flag to force update it.
INFO: Found 42 external repositories in the ./resolved_deps.py file.
INFO: Executing command: bazel build --nobuild --enable_bzlmod //tools/...
INFO: Congratulations! All external repositories needed for building `//tools/...` are available with Bzlmod (and the WORKSPACE.bzlmod file)!
INFO: Things you should do next:
INFO:   - Migrate remaining dependencies in the WORKSPACE.bzlmod file to Bzlmod.
INFO:   - Run the actual build with Bzlmod enabled (with --enable_bzlmod, but without --nobuild) and fix remaining build time issues.

what isn't clear from https://bazel.build/external/migration#migration is what to do now we can build with bzlmod enabled.

dmah42 commented 5 months ago

https://github.com/bazel-contrib/publish-to-bcr may be the next step.

dmah42 commented 5 months ago

oh. we're already there: https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/google_benchmark

mmorel-35 commented 3 months ago

Have you considered using the BCR bot to automatically update in BCR after each new release ?

https://github.com/bazelbuild/bazel-central-registry/tree/main/docs#bazel-central-registry-bcr-contribution-guidelines

dmah42 commented 3 months ago

i haven't but i'm happy to. anything that makes this process easier :)

patches welcome!

mmorel-35 commented 3 months ago

That is something only maintainers can do through https://github.com/apps/publish-to-bcr

dmah42 commented 3 months ago

given this repo is owned by a company that have a large number of projects, i fail to see how this could possibly work. having the ruleset and BCR fork under my personal github is unmaintainable, and having it under google as a whole would cause issues when multiple projects want to use it.

unless i'm failing to understand how this works. it seems like a ... not great solution in terms of scaled maintenance.

mmorel-35 commented 3 months ago

To my understanding publish to bcr is an app/bot that requires a .bcr folder in each project that needs to be published. In this folder you have some files to configure how to publish and test the project.

Based on that configuration when the project create a release it creates a new PR to BCR to publish the new version. You don't have to enable publihs to bcr to the whole organisation but only to the concerned projects.