Skip to content

Conversation

@jannowotsch
Copy link
Contributor

@jannowotsch jannowotsch commented Aug 14, 2025

Migrate initial content from BMW repository and update bazel configuration to support quality checks.
Disable certain score targets that are currently not compatible with multiple python versions.

lucasmuna and others added 30 commits August 8, 2025 11:29
This commit:
- create a generic python aspect that can interface multiple runners;
- create our first python runner that runs pylint;
- create the aspect user interface at defs.bzl;
- create a default pylint runner config at quality/BUILD;
- adds `quality/private/python` to our poetry/tox setup;
- adds pylint aspect config to .bazelrc;
- create a target for pyproject.toml.
This commit:
- adds a functional black aspect and runner;
- offers the aspect though quality/defs.bzl;
- as planned, make use of both python_tool_aspect.bzl and python_tool_common.py;
- add a black config to .bazelrc.
We currently have our own python toolchain and support only bazel workspace,
 even though we have bzlmod activated.

This commit removes our python toolchain in favor of rules_python toolchain.
 By doing this we increase toolchain support for multiple system, add support
 for both bzlmod and workspace, add support for multiple OSs, and easily
 update our toolchain version when a new one is released.

Other minor changes were made:
- change bazel labels to fit the new python toolchain;
- add a tools availability to our README.md
This modification allows the caller to have access to the actual subprocess
 stdout and stderr. This is important because the caller may rely on that
 information in case of a non-zero return code.

Example, isort returns 1 when it finds something, but we still want
 execute_subprocess to throw so we, on the application level, may be able to
 catch and evaluate it.

Each application will do its own evaluation.
This commit:
- adds a functional isort aspect and runner;
- offers the aspect though quality/defs.bzl;
- as planned, make use of both python_tool_aspect.bzl and python_tool_common.py;
- add a isort config to .bazelrc.
The current approach is wrong because it relies on the string `startswith`
 method.

This work on some cases but throws an exception on another ones, for example,
 "myapp" is not relative to "myapp_lib/path/..." but  "myapp_lib/path/.."
 startswiuth "myapp".

To avoid this we should rely on pathlib `is_relative_to`. This ensures that a
 path is actually relative to the other one instead of just comparing the
 string.
This commit:
- adds a functional mypy aspect and runner;
- offers the aspect though quality/defs.bzl;
- as planned, make use of both python_tool_aspect.bzl and python_tool_common.py;
- add a mypy config to .bazelrc.
This commit fixes every finding that doesn't come from clang-tidy or qac
 targets. Later PRs can fix those as well.
Multiple python runners may use the same entry_point, for example, ruff. With
 that in mind one might expect that, as the output file name is based on the
 tool and not on the runner, a conflict will happen when both runners are
 triggered.

This commit prevents that by changing how we name the output file, which will
 from now on be based on the runner name.

This commit also renamed runners, for example, pylint_runner to pylint, and
 also add an "_entry_point" to the py_console_script_binaries to avoid
 confusion. With this, for example, the pylint output file will still be
 called pylint_output_target_name.
This commit:
- adds two functional ruff aspects and runners, one to check files and another
 to format files;
- offers the aspects through quality/defs.bzl;
- as planned, make use of both python_tool_aspect.bzl and python_tool_common.py;
- add a ruff config to .bazelrc.

Two runners were created because ruff has both a check and a formatter. Each
 one of those must be invoked individually and therefore we have two output
 files. Knowing that the aspect requires one output file, ruff runner was
 splitted into two.

Also, as ruff python library doesn't provide a default entry point, a
 ruff_entry_point.py had to be created.
The default config should not be tied to the one that we have in our root.

Also, as every python_tool_config was the same we only need to keep one of
 those. With that, label_flag can now references to the same python config.
Mypy is still using the old nomenclature style.

This happened because while other python tools were being refactored mypy
 was being added to the repo.
To ensure that mypy can type check more code we need to add type libraries.

These libraries ususally come from https://github.com/python/typeshed, and
 most are daily released.

This also add those libraries to mypy entry point dependencies.
With this we set mypy as no incremental mode to both our repo and our default
 aspect config. The reason is that while it does speed up check, it also makes
 mypy bugprone and therefore we are disabling it.

For our repo mypy config we are also fixing it to python 3.9. This means that,
 if we change our python version, mypy will still check against 3.9 style.
As we aim to not provide our toolchains anymore, we, unfortunatelly, will need
 to support python 3.8. This mostly means replacing some built-ins typehints
 with typing
There was a fundamental flaw in the python aspect design. It was not
 collecting information from the whole dependency tree.

This commit fixes it by splitting the aspect into two aspects.

The `python_collect_aspect` parse the whole dependency tree and stores it at
 the `PythonCollectInfo` provider.

The already existing `python_tool_aspect` then inherits `PythonCollectInfo`
 and use that information to call our tool runners.
Naming files with the same name as libraries is a bad practice and can
 lead some tools to undefined behaviour.
Ideally we want two outputs, a json using quality-tools Fidings format and
 also a text output so we can output findings to the terminal. Diff outputs
 are additional.

This commit add a Findings definition that follows what quality-tools
 findings-converter expects. Also, a Findings and a FindingsJSONEncoder helps
 us to interface a list of Finding with string and json methods.
 Also, updates `black_runner`, to output their results using the updated
 Finding string.
This commit standardizes isort_runner output, which
is part of a bigger effort to standardize every
python tool output.
This commit will add test coverage to the current black runner.
This commit standardizes mypy_runner output, which
is part of a bigger effort to standardize every
python tool output.
This commit standardizes ruff_check_runner output, and
ruff_format_runner output which are part of a bigger effort
to standardize every python tool output.
This commit will be removing the DeprecatedLinterFindingAsError
function from the python_tool_common, since it should not be
used by the tools anymore.
This commit standardizes pylint_runner output, which
is part of a bigger effort to standardize every
python tool output.
To better integrate our python aspect with our metrics tooling or even
with a normal CI usage we should enable our aspect to automatically apply fixes.
So in this commit black shall now be able to automatically fix a file
depending on the user command.
To better integrate our python aspect with our metrics tooling or even
with a normal CI usage we should enable our aspect to automatically apply fixes.
So in this commit isort shall now be able to automatically fix a file
depending on the user command.
This commit goal is to fix test_black_output_with_refactor test,
fixing the assert case to assert against the correct variable.
To better integrate our python aspect with our metrics tooling or even
with a normal CI usage we should enable our aspect to automatically apply fixes.
So in this commit ruff check and ruff format shall now be able to automatically
fix a file depending on the user command.
Yuri Barboza and others added 11 commits August 8, 2025 11:29
This commit adds a new test case for both test_python_tool_common and
test_clang_tidy_runner, with the objective of reaching 100% coverage
with bazel coverage.
See https://bazel.build/rules/lib/builtins/actions#run
and https://bazel.build/reference/glossary#mnemonic.

This helps to identify and analyze actions e.g.
when running on a remote cluster.
While pytest-vcr is a nice library it is causing too much noise when using our
 custom py_pytest rule from an external repo due to incompatible libraries
 resolution.

As it is not used and also not considered an essential lib, it makes sense to
 remove it from BRQ.

Users can still add VCR back using their own dependencies.
This rule can be used to check python requirements files.

As it is an executable rule, it can be used with `bazel run //target` command.

From the start, it already supports:
- Locked and not locked requirement files;
- `index_url` option to change pip index;
- `no_deps` option to allow not locked files to be checked.
Move the pycoverage implementation from the quality-tools here. Since
pycoverage is a bazel integration it should rather be used by
quality-tools but provided by bazel-rules-quality.
Add entry point, allowing pycoverage to be called as a py_binary.
Update the names of output- and report generators in log messages and
tests according to the actual file name.
Update the way the pycoverage generators report their exit code,
actually returning something from the main function and use sys.exit()
to report that value to the system.
Update the report-generator implementation that identifies coverage data
files.
Adjust identifiers to new repository.
@github-actions
Copy link

github-actions bot commented Aug 14, 2025

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Invocation ID: 70553a24-3e4d-4fce-9f97-95ffac8a4d38
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 2 packages loaded
Analyzing: target //:license-check (3 packages loaded, 0 targets configured)
Analyzing: target //:license-check (3 packages loaded, 0 targets configured)

Analyzing: target //:license-check (62 packages loaded, 10 targets configured)

Analyzing: target //:license-check (70 packages loaded, 10 targets configured)

Analyzing: target //:license-check (115 packages loaded, 1981 targets configured)

Analyzing: target //:license-check (121 packages loaded, 2325 targets configured)

Analyzing: target //:license-check (121 packages loaded, 2325 targets configured)

Analyzing: target //:license-check (130 packages loaded, 4379 targets configured)

INFO: Analyzed target //:license-check (132 packages loaded, 4626 targets configured).
[8 / 13] Creating runfiles tree bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/score_dash_license_checker~/tool/formatters/dash_format_converter.runfiles [for tool]; 0s local ... (2 actions, 1 running)
[10 / 13] checking cached actions
[10 / 13] [Prepa] Generating Dash formatted dependency file ...
[11 / 13] checking cached actions
[11 / 13] [Prepa] JavaToolchainCompileBootClasspath external/rules_java~/toolchains/platformclasspath.jar
[12 / 13] [Prepa] Building license.check.license_check.jar ()
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 22.288s, Critical Path: 2.59s
INFO: 13 processes: 9 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 13 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt -review -project automotive.score -repo https://github.com/eclipse-score/bazel-tools-python -token otyhZ4eaRYK1tKLNNF-Y
[main] INFO Querying Eclipse Foundation for license data for 74 items.
[main] INFO Found 42 items.
[main] INFO Querying ClearlyDefined for license data for 37 items.
[main] INFO Found 37 items.
[main] INFO License information could not be automatically verified for the following content:
[main] INFO 
[main] INFO pypi/pypi/-/license-expression/30.4.4
[main] INFO pypi/pypi/-/pip/25.2
[main] INFO pypi/pypi/-/pylint/3.1.0
[main] INFO pypi/pypi/-/ruff/0.5.5
[main] INFO pypi/pypi/-/typing-extensions/4.14.1
[main] INFO 
[main] INFO This content is either not correctly mapped by the system, or requires review.
[main] INFO A review is required for pypi/pypi/-/typing-extensions/4.14.1.
[main] INFO A review request already exists https://gitlab.eclipse.org/eclipsefdn/emo-team/iplab/-/issues/22860 .
[main] INFO A review is required for pypi/pypi/-/license-expression/30.4.4.
[main] INFO A review request already exists https://gitlab.eclipse.org/eclipsefdn/emo-team/iplab/-/issues/22862 .
[main] INFO A review is required for pypi/pypi/-/pip/25.2.
[main] INFO A review request already exists https://gitlab.eclipse.org/eclipsefdn/emo-team/iplab/-/issues/22866 .
[main] INFO A review is required for pypi/pypi/-/ruff/0.5.5.
[main] INFO A review request already exists https://gitlab.eclipse.org/eclipsefdn/emo-team/iplab/-/issues/22867 .
[main] INFO A review is required for pypi/pypi/-/pylint/3.1.0.
[main] INFO A review request already exists https://gitlab.eclipse.org/eclipsefdn/emo-team/iplab/-/issues/22869 .

@antonkri antonkri self-requested a review August 19, 2025 07:08
antonkri
antonkri previously approved these changes Aug 19, 2025
Setup the bazel workspace, build files and dependencies.
Add a separate bazel workspace intended for testing the bazel
provided integrations.
Add scripts to run linters, formatters and tests.
Add user-facing documentation with the README.md and contributor-focused
documentation with the CONTRIBUTING.md.
Replace the existing copyright header with the eclipse one.
Remove the starlark language server since the underlying rule is broken.

When attempting to invoke the stetup_starpls rule bazel reports
"declared output 'starpls_server_bin' was not created by genrule".

Since the starpls language server is anyhow not used by the project it
is fine to remove it.
Remove the score targets that build the sphinx documentation.

Those targets only work for python 3.12. Since the project has support
for python version from 3.8 up to 3.12 we also run tests for each of the
versions. However, the score docs targets do not allow to restrict them
to only being build for 3.12, hence they are disabled for now.

On top of that those targets take way too many resources to build even
though it doesn't actually have much content. With too many resources
meaning over an hour and up to 40GB memory.
It contains all information regarding secutiry and vulnerabilities
for this project.
Add the test github action that executes the run_all_tests shell script
which in turn performs all tests and checks relevant for the project.
@antonkri antonkri merged commit d6008db into eclipse-score:main Aug 27, 2025
6 of 7 checks passed
@jannowotsch jannowotsch deleted the eclipse-infra branch December 18, 2025 09:53
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.

5 participants