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 setup_presubmit_repos.py to reproduce BCR presubmit locally #3550

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

meteorcloudy
Copy link
Member

@meteorcloudy meteorcloudy commented Jan 9, 2025

This script will create test repos based on presubmit.yml file of given repo and print out commands to reproduce the presubmit builds.

Requires bazelbuild/continuous-integration#2155

Fixes #1686

An example run on protobuf@29.2:

$ bazel run //tools:setup_presubmit_repos -- --module protobuf@29.2
INFO: Invocation ID: 61e8900e-69df-4cb4-82a2-7f6db491c75e
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=260
INFO: Reading rc options for 'run' from /Users/pcloudy/.bazelrc:
  Inherited 'build' options: --verbose_failures --announce_rc --disk_cache=/tmp/bazel_disk_cache --repository_cache=/tmp/bazel_repository_cache
INFO: Analyzed target //tools:setup_presubmit_repos (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //tools:setup_presubmit_repos up-to-date:
  bazel-bin/tools/setup_presubmit_repos
INFO: Elapsed time: 0.164s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/tools/setup_presubmit_repos <args omitted>
2025-01-09 14:50:35,148 - INFO: Testing using registry at: /Users/pcloudy/workspace/bazel-central-registry
2025-01-09 14:50:35,151 - INFO: Creating anonymous module repo at: /Users/pcloudy/workspace/bazel-central-registry/temp_test_repos/protobuf/29.2/anonymous_module
2025-01-09 14:50:35,152 - INFO: Anonymous module repo ready at: /Users/pcloudy/workspace/bazel-central-registry/temp_test_repos/protobuf/29.2/anonymous_module

To reproduce the build, follow these steps (make sure Bazelisk is installed as bazel):

    export USE_BAZEL_VERSION=7.x
    cd /Users/pcloudy/workspace/bazel-central-registry/temp_test_repos/protobuf/29.2/anonymous_module
    bazel build --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 -- @protobuf//:protobuf @protobuf//:protobuf_lite @protobuf//:protobuf_python @protobuf//:protobuf_java @protobuf//:protoc @protobuf//:test_messages_proto2_cc_proto @protobuf//:test_messages_proto3_cc_proto

Make sure to check /Users/pcloudy/workspace/bazel-central-registry/modules/protobuf/29.2/presubmit.yml for additional build and test configurations.

2025-01-09 14:50:35,152 - INFO: Creating test module repo at: /Users/pcloudy/workspace/bazel-central-registry/temp_test_repos/protobuf/29.2/test_module
2025-01-09 14:50:36,439 - INFO: Test module repo ready at: /Users/pcloudy/workspace/bazel-central-registry/temp_test_repos/protobuf/29.2/test_module/output/protobuf-29.2/examples

To reproduce the build, follow these steps (make sure Bazelisk is installed as bazel):

    export USE_BAZEL_VERSION=7.x
    cd /Users/pcloudy/workspace/bazel-central-registry/temp_test_repos/protobuf/29.2/test_module/output/protobuf-29.2/examples
    bazel build --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 -- //...

Make sure to check /Users/pcloudy/workspace/bazel-central-registry/modules/protobuf/29.2/presubmit.yml for additional build and test configurations.

@meteorcloudy
Copy link
Member Author

Also tested on Windows:

INFO: Running command line: bazel-bin/tools/setup_presubmit_repos.exe <args omitted>
2025-01-09 14:04:15,804 - INFO: Testing using registry at: C:\users\pcloudy\workdir\bazel-central-registry
2025-01-09 14:04:15,819 - INFO: Creating anonymous module repo at: C:\users\pcloudy\workdir\bazel-central-registry\temp_test_repos\protobuf\29.2\anonymous_module
2025-01-09 14:04:15,819 - INFO: Anonymous module repo ready at: C:\users\pcloudy\workdir\bazel-central-registry\temp_test_repos\protobuf\29.2\anonymous_module

To reproduce the build, follow these steps (make sure Bazelisk is installed as bazel):

    set USE_BAZEL_VERSION=7.x
    cd C:\users\pcloudy\workdir\bazel-central-registry\temp_test_repos\protobuf\29.2\anonymous_module
    bazel build --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 -- @protobuf//:protobuf @protobuf//:protobuf_lite @protobuf//:protobuf_python @protobuf//:protobuf_java @protobuf//:protoc @protobuf//:test_messages_proto2_cc_proto @protobuf//:test_messages_proto3_cc_proto

Make sure to check C:\users\pcloudy\workdir\bazel-central-registry\modules\protobuf\29.2\presubmit.yml for additional build and test configurations.

2025-01-09 14:04:15,819 - INFO: Creating test module repo at: C:\users\pcloudy\workdir\bazel-central-registry\temp_test_repos\protobuf\29.2\test_module
2025-01-09 14:04:19,260 - INFO: Test module repo ready at: C:\users\pcloudy\workdir\bazel-central-registry\temp_test_repos\protobuf\29.2\test_module\output\protobuf-29.2\examples

To reproduce the build, follow these steps (make sure Bazelisk is installed as bazel):

    set USE_BAZEL_VERSION=7.x
    cd C:\users\pcloudy\workdir\bazel-central-registry\temp_test_repos\protobuf\29.2\test_module\output\protobuf-29.2\examples
    bazel build --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 -- //...

Make sure to check C:\users\pcloudy\workdir\bazel-central-registry\modules\protobuf\29.2\presubmit.yml for additional build and test configurations.

@meteorcloudy meteorcloudy requested a review from Wyverald January 9, 2025 14:12
fmeum
fmeum previously approved these changes Jan 9, 2025
Copy link
Contributor

@fmeum fmeum 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 great, thanks!

tools/setup_presubmit_repos.py Outdated Show resolved Hide resolved
tools/setup_presubmit_repos.py Outdated Show resolved Hide resolved
tools/setup_presubmit_repos.py Outdated Show resolved Hide resolved
tools/setup_presubmit_repos.py Outdated Show resolved Hide resolved
tools/BUILD Show resolved Hide resolved
@bazel-io bazel-io dismissed fmeum’s stale review January 10, 2025 12:43

Require module maintainers' approval for newly pushed changes.

@hofbi
Copy link
Contributor

hofbi commented Jan 10, 2025

Damn, my suggestions are using the wrong email (the one where I don't have the CLA signed). Feel free to squash my recommendations to overcome this.

@meteorcloudy meteorcloudy enabled auto-merge (squash) January 10, 2025 12:53
@meteorcloudy
Copy link
Member Author

Thanks for the review and suggestions, I also updated the http_file rules to point to the official CI repo, this PR is ready to be merged.

@meteorcloudy meteorcloudy disabled auto-merge January 10, 2025 12:56
@meteorcloudy meteorcloudy enabled auto-merge (squash) January 10, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Locally verify the build of package
3 participants