Repository navigation
Conversation
…h command googletest (whose primary build is Bazel), Catch2, nlohmann/json and SwiftLint build and test with Bazel, but nothing read it. Their `bazel test` jobs counted as plain jobs with no configuration, and `.bazelrc`'s `-Werror`, `-std=c++17` and `--compilation_mode` were unseen (cpp-best-practices#207). - Recognition: a MODULE.bazel, WORKSPACE(.bazel) or BUILD.bazel makes Bazel a build system of the C, C++ and Swift profiles. Its output directories (`bazel-bin`, `bazel-<workspace>`) are build trees. - BUILD files are parsed for the rules they call (`build_systems/bazel/syntax`). A statement that does not parse is a problem, and the rest of the file is still read. - Each file records the kinds of rule it uses and its test rules (`cc_test`, `swift_test`, any `*_test`). - Starlark's syntax is Python's, so statements are parsed with Python's own `ast`. It is in the standard library, not a parsing dependency. Only literals are read as values; anything computed (`glob()`, `select()`, `+`) is kept as its text. - Tests: `bazel test` and `bazel coverage` (also through bazelisk, past startup options) run the tests the BUILD files define. - Build types: a command's last `--compilation_mode` / `-c` is its build type. `dbg` is Debug, `opt` is Release, and the default, `fastbuild`, is neither. - `.bazelrc`: a bazel command is expanded into itself with the options its rc files give it written out, plus `--ignore_all_rc_files`, with which bazel reads none. This is the same command, so `--copt=-Werror` and `-c opt` count as its own. - A command takes the options of `common` and of the commands it inherits (test inherits build; coverage inherits test). - `--config=name` brings each command's `:name` options in its place, recursively. - With `--enable_platform_specific_config`, the config for the host's OS applies, in the builds on that OS. - `import` and `try-import` of workspace files are followed, as is a `--bazelrc=` file; imports nest at most 10 deep. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
grpc-proto's only CI job is `bazelisk build //...` over BUILD files of `proto_library` rules, and envoy's data-plane-api builds its APIs the same way. Bazel compiles each rule's schemas with protoc, but schema-validation failed with "none found" (cpp-best-practices#207). A `bazel build` (or `test`, `coverage`) now validates the schemas when the BUILD files define a `proto_library` rule. A command that builds nothing (`bazel query`) does not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #381 +/- ##
==========================================
- Coverage 99.50% 99.49% -0.02%
==========================================
Files 320 324 +4
Lines 21149 21421 +272
Branches 2540 2589 +49
==========================================
+ Hits 21045 21312 +267
- Misses 104 109 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bazel is now read as a build system (#207).
googletest (whose primary build is Bazel), Catch2, nlohmann/json, SwiftLint, grpc-proto, envoy's data-plane-api and protovalidate build or test with Bazel. Nothing read it: their
bazel testjobs counted as plain jobs with no configuration,.bazelrc's-Werrorand-std=c++17were unseen, and grpc-proto'sproto_libraryrules weren't schema validation.What is read
MODULE.bazel,WORKSPACE(.bazel)orBUILD.bazelmakes Bazel a build system of the C, C++ and Swift profiles. Its output directories (bazel-bin,bazel-<workspace>) are build trees.build_systems/bazel/syntax.py).cc_test,swift_test, any*_test).ast. That's the standard library, not a parsing dependency (no tree-sitter). Only literals are read as values; anything computed (glob(),select(),+) is kept as text.bazel testandbazel coveragerun the tests the BUILD files define. This also works through bazelisk and past startup options (bazel --batch test).--compilation_mode/-cis its build type.dbgis Debug,optis Release, and the default,fastbuild, is neither..bazelrc: a bazel command is expanded into itself with the options its rc files give it written out, plus--ignore_all_rc_files, with which bazel reads none. It's the same command, so--copt=-Werror,--cxxopt=-std=c++17and-c optthere count as its own, and the existing flag questions see them.common's options and those of the commands it inherits (test inherits build; coverage inherits test).--config=namebrings each command's:nameoptions in its place, recursively (googletest'sbuild:gcc --config=linux).--enable_platform_specific_config(Catch2, SwiftLint), the config for the host's OS applies, in the builds on that OS.importandtry-importof workspace files are followed (at most 10 deep, tested at the limit), as is a--bazelrc=file.bazel build(ortest) validates Protobuf schemas when the BUILD files define aproto_libraryrule, which protoc compiles as the build does.Left for a decision
Bazel's own files could be judged as a format, as CMake's are in #378: formatted and linted by buildifier (
buildifier -mode=check,-lint=warn). That would add failures to the seven Bazel projects in the corpus, so it's left out until you decide. Until then,.bzlmacro files stay listed as an unrecognised suffix, while BUILD and MODULE files are accounted as build files.Corpus
Compared against main's recording, the seven Bazel projects now list Bazel among their build systems. Two statuses change:
--stricttoo.cc_testrules run bybazel testnow count, and its auxiliary Go tests still warn.Other changes, which leave statuses as they were:
-Wallfor appleclang, from.bazelrc'sbuild:macos, which CI brings through--config;swift_testrules count for its C code too. Splitting the runner by rule kind can follow if you want it stricter..bazelleaves the list everywhere..bzl,.bazelrcand.bzlmodstay (see "Left for a decision").Tests
tests/test_starlark_syntax.py(the reader),tests/test_bazel.py(recognition, the rules and tests read, build trees, build types, tests-run) andtests/test_bazelrc.py(commands, configs, platform configs, imports,--bazelrc, cycles). Protobuf's tests coverproto_library, and there's a limit test for rc imports.bazel testamong the runners, and the snapshots list the new tools.Gates
pytest, ruff, ruff format, mypy, lizard, coverage, jscpd and strict self-validation: all pass.
🤖 Generated with Claude Code
https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt