Skip to content

feat(docs_and_test): Bazel macro chaining tests/coverage with docs build - #759

Draft
antonkri wants to merge 2 commits into
mainfrom
ankr_docs_and_test
Draft

feat(docs_and_test): Bazel macro chaining tests/coverage with docs build#759
antonkri wants to merge 2 commits into
mainfrom
ankr_docs_and_test

Conversation

@antonkri

Copy link
Copy Markdown
Contributor

Split out of #730, which grew to cover two independent concerns. This PR contains only the docs_and_test Bazel macro:

  • bzl/docs_and_test.bzl: macro generating <name> / <name>_preview py_binary targets that run bazel test/bazel coverage on a set of test targets, then invoke a docs (or live-preview) target — since Bazel has no native way to make a build target depend on test execution.
  • bzl/run_docs_and_test.py: the Python driver invoked by those targets, including a fix so negative Bazel target patterns (e.g. -//foo:bar) are correctly separated with -- instead of being mistaken for CLI flags.
  • BUILD: exports bzl/run_docs_and_test.py so it can be used as a py_binary srcs/main file by consumers.

The score_module_verification_report Sphinx extension changes remain in #730 and are independent of this macro (the directive works standalone; docs_and_test is just a convenience wrapper so a report reflects a fresh test run).

New docs_and_test macro generates two py_binary targets that run
'bazel test' (or 'bazel coverage --combined_report=lcov' when
coverage=True) followed by 'bazel run //:docs' resp. '//:live_preview'
in a single command:

    load('@score_docs_as_code//:bzl/docs_and_test.bzl', 'docs_and_test')

    docs_and_test(
        name = 'module_verification_report',
        test_targets = ['//score/...'],
    )

Consumers get //:<name> and //:<name>_preview without any local
Python driver. Extra Bazel flags forward via '--test-flag=…'. Ctrl+C
in the driver propagates cleanly as exit 130.

Ships the driver via exports_files so external py_binary(srcs=…)
can reference it.
…patterns

Negative Bazel target patterns (e.g. '-//foo:bar') passed via
test_targets were mistaken for CLI flags by 'bazel test'/'bazel
coverage'. Insert '--' as a separator before the targets so they are
always parsed as target patterns.

(Split out of #730, which also fixed an
unrelated zero-coverage-row rendering bug in the
score_module_verification_report extension.)
@github-actions

Copy link
Copy Markdown
Contributor

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //src:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.6.0) and connecting to it...
INFO: Invocation ID: 27cffb48-891e-483c-92bf-6427154bc0a0
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading: src
WARNING: Target pattern parsing failed.
ERROR: Skipping '//src:license-check': no such target '//src:license-check': target 'license-check' not declared in package 'src' defined by /home/runner/work/docs-as-code/docs-as-code/src/BUILD
ERROR: no such target '//src:license-check': target 'license-check' not declared in package 'src' defined by /home/runner/work/docs-as-code/docs-as-code/src/BUILD
INFO: Elapsed time: 5.882s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

antonkri added a commit that referenced this pull request Aug 26, 2026
Removes bzl/docs_and_test.bzl, bzl/run_docs_and_test.py and the BUILD
exports_files entry for the driver script, along with the
'Running tests and docs together: docs_and_test' documentation section,
since this PR should only cover the score_module_verification_report
Sphinx extension.

The docs_and_test macro (including the -- separator fix for negative
Bazel target patterns) now lives in
#759.
@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-759: https://eclipse-score.github.io/docs-as-code/pr-759/

MaximilianSoerenPollak pushed a commit that referenced this pull request Aug 27, 2026
Removes bzl/docs_and_test.bzl, bzl/run_docs_and_test.py and the BUILD
exports_files entry for the driver script, along with the
'Running tests and docs together: docs_and_test' documentation section,
since this PR should only cover the score_module_verification_report
Sphinx extension.

The docs_and_test macro (including the -- separator fix for negative
Bazel target patterns) now lives in
#759.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant