Skip to content

feat: needs.json merger - #733

Open
AlexanderLanin wants to merge 3 commits into
eclipse-score:mainfrom
etas-contrib:json
Open

feat: needs.json merger#733
AlexanderLanin wants to merge 3 commits into
eclipse-score:mainfrom
etas-contrib:json

Conversation

@AlexanderLanin

Copy link
Copy Markdown
Member

Summary

  • add a Bazel CLI to merge Sphinx-Needs needs.json inventories
  • validate input structure and reject conflicting Need definitions
  • write output atomically and preserve existing results on failure
  • add unit and Sphinx app-level coverage, including empty inventories
  • reuse public docs_bundle targets for test data instead of redundant source filegroups

Validation

  • bazel test //scripts_bazel/tests:merge_needs_json_unit_tests //scripts_bazel/tests:merge_needs_json_app_tests --test_output=errors
  • bazel build //scripts_bazel:merge_needs_json
  • commit hooks: Ruff, BasedPyright, copyright checks

@github-actions

github-actions Bot commented Aug 20, 2026

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: aa563b95-3d54-4e90-88bf-dfb8700316f1
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: 6.232s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

@github-actions

Copy link
Copy Markdown
Contributor

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

@AlexanderLanin AlexanderLanin changed the title feat: add production-ready needs JSON merger feat: needs.json merger Aug 20, 2026
Comment thread scripts_bazel/README.md
metadata and version container from the first input:

```text
bazel run //scripts_bazel:merge_needs_json -- \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You really need it as a script, not a bazel rule?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Bazel rule might be easier to use, but harder to write. No big disadvantage in using python AFAIK.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You are right that the Bazel-facing interface should be a rule. We will add a dedicated Bazel rule wrapper in a follow-up, while keeping the Python merger as the action implementation.

A pure Starlark implementation is not a good fit here because rule analysis cannot read the contents of generated needs.json inputs; the merge has to run as an execution action. Conversely, exposing only the Python CLI keeps its path-based inputs and manually selected output outside Bazel’s action graph, so consumers lose declared dependencies, caching, sandboxing, incremental rebuilds, and straightforward target composition.

The wrapper gives us the useful split: a Bazel rule as the public API, with label-based inputs and a declared output, invoking the focused and independently testable Python tool internally.

— Generated by GPT-5.6-Sol-Med

build_dir: Path,
monkeypatch: pytest.MonkeyPatch,
) -> Path:
app = SphinxTestApp(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That is a very expensive test if you run Sphinx to verify if your needs-merging works. Test would probably run a lot faster if it relies on static json files instead of generating them with Sphinx.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually this whole "app test" seems unnecessary to me. It rather tests the Sphinx-Needs behavior instead of the merging because the unit tests cover the merging behavior already.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

unit tests verify artificial json files/pieces, I wanted to test with real json files. I did not create static copies of real json files, as this way they will verify that it still works when we update sphinx-needs. So basically these are black box end to end tests incl sphinx behavior.

On the other hand everything will break horribly anyway when the format changes 😆

@AlexanderLanin

Copy link
Copy Markdown
Member Author

discussed in call @AlexanderLanin @a-zw @MaximilianSoerenPollak: drop app tests, they will be executed implicitly in bundle tests soon

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.

2 participants