Skip to content

Tags

Tags

v0.1.3

Toggle v0.1.3's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
[version] Increment to version 0.1.3 (#10)

v0.1.2

Toggle v0.1.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
[version] Increment to version 0.1.2 (#6)

v0.1.1

Toggle v0.1.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
[bazel] Fix compatibility_level (#3)

0.1.0

Toggle 0.1.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Eclipse infra (#2)

* [python] Create our first python bazel quality rule

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.

* [black] Add black aspect and runner

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.

* Toolchains from rules_python and support for both bzlmod and workspace

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

* [python] Improve LinterSubprocessError content

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.

* [isort] Add isort aspect and runner

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.

* [python] Fix how python_tool_common check for relative paths

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.

* [python] Add mypy aspect and runner

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.

* [python] Fix mypy findings

This commit fixes every finding that doesn't come from clang-tidy or qac
 targets. Later PRs can fix those as well.

* [python] Change how we create python aspect output file name

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.

* [python] Add ruff aspect and runner

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.

* [python] Create a support directory with a default pyproject file

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.

* [python] Fix mypy nomenclature

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.

* [python] Add more `mypy` types dependencies

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.

* [python] Improve mypy configuration

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.

* [python] Make python aspect py38 compatible

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

* [python] Improve how python aspect collects information

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.

* [python] Change python modules names that were shadowing libs

Naming files with the same name as libraries is a bad practice and can
 lead some tools to undefined behaviour.

* [python] Add common classes that will standardize every tool output

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.

* [python] Standardize isort output

This commit standardizes isort_runner output, which
is part of a bigger effort to standardize every
python tool output.

* [python] Add tests for isort runner

* [python] Create test for python black runner.

This commit will add test coverage to the current black runner.

* [python] Standarlize mypy output

This commit standardizes mypy_runner output, which
is part of a bigger effort to standardize every
python tool output.

* [python] Standarlize ruff 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.

* [python] Remove DeprecatedLinterFindingAsError

This commit will be removing the DeprecatedLinterFindingAsError
function from the python_tool_common, since it should not be
used by the tools anymore.

* [python] Stardardize pylint output

This commit standardizes pylint_runner output, which
is part of a bigger effort to standardize every
python tool output.

* [python] Add tests for pylint_runner

* [python] Black automated Fix

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.

* [python] Isort Automated Fix

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.

* [python] Fix black runner test

This commit goal is to fix test_black_output_with_refactor test,
fixing the assert case to assert against the correct variable.

* [python] Ruff Automated Fix

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.

* [docs] Improve our documentation

Simplify our main README.md into `Offered Tools`, `How to use BRQ`
 and `Contributing`.

 Create a `CONTRIBUTING.md`.

 Split, and slighty refactor, each specific tool section into its own
  README.md file.

* [python] Improve compatibility across multiple versions

Minor improvements that improve compatibility for multiple versions of python.

* [bazel] Adapt every target to the new bazel infra

With this we adapt a lot BUILD files (mainly labels) to the new bazel
 infrastructure.

Also, py_version_printer was upgraded to supply more information.

* [python] Add PYTHON_PATH routine to python_common_tool module

* [python] Fix mypy entry point

With the changes introduced in previous commits,
 the mypy runner wasn't working as expected due to
 it's entry point.

* [python] Move tool runners common code to python_tool_common

Currently, there is some duplicated code between the tool runners, so
this commit splits the tool runners behavior in three functions
(get_command, output_parser and exception_handler) and adds a function
that handles the interaction between them.

* [quality] Fix mypy issues on qac/clang_tidy modules

In order to fix all issues pointed by mypy, this commit adds missing
type hints and refactors code to match the expected types.
It also re-enables the qac and clang_tidy modules at the
playbook that runs the mypy check on CI.

* [python] Add py_pytest rule

* [python] Migrate test targets from py_test to py_pytest

* [pytest] Remove non stable pytest packages

While adding tests for python 3.8 and 3.12 a lot of non stable pytest packages
 failed to comply with both versions.

This aims to remove all non stable packages. If the end user wants, it is
 allowed to add more packages to our custom py_pytest rule as necessary.

Link to pytest plugins:
https://docs.pytest.org/en/stable/reference/plugin_list.html

* [python] Add proper typehints to python tools `execute_runner`

* [python] Add JSON output to every tool

This is needed to ease the a quality-tools metrics template creation for BRQ
 python tools. The new JSON file will ease file conversion while the the new
 output file names are going to ease file collection.

* [python] Improve `LinterFindingAsError` message

* [python] Adequate tests to new JSON output

* [python] Set default Finding line and column to 1

This is expected from findings-converter perspectve.

* [readme] Python module documentation

This commit will add a documentation to the python
README

* [python] Fix ruff check runner finding path

This commit will fix a bug found in the ruff check runner
where the Finding path was supposed of type Path but instead
it was of type string.

* [python] Improve coverage for python tool

This commit will add tests for mypy, ruff_check and ruff_format
runner, improving the coverage.

* [documentation] Hint at --features=refactor

* [pylint] Take Windows Paths into account when parsing output

* [pylint] Simplify Windows path handling

* [python] Add test to python_tool_common

This commit will add tests to the Python tool common.

* [quality] Ignore mypy var-annotate check

* [python] Parse user enabled features and raise error

This commit add a parse in the python aspect which will
raise an error or print a message when non compliant features are used
with python tools.

* [coverage] Add coverage to missing lines

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.

* [aspects] Add mnemonic to all actions.

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.

* [pytest] Remove `pytest-vcr` from default plugins

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.

* [python] Create `pip-audit` `pybinary` entry point

* [python] Create pip-audit rule

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.

* [pycoverage] Move pycoverage from quality-tools

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.

* [pycoverage] Add entry point

Add entry point, allowing pycoverage to be called as a py_binary.

* [pycoverage] Adjust generator names

Update the names of output- and report generators in log messages and
tests according to the actual file name.

* [pycoverage] Update script exit code handling

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.

* [pycoverage] Refactor report-generator

Update the report-generator implementation that identifies coverage data
files.

* [all] Rename to bazel-tools-python

Adjust identifiers to new repository.

* [infra] Add bazel infrastructure

Setup the bazel workspace, build files and dependencies.

* [tests] Add test workspace

Add a separate bazel workspace intended for testing the bazel
provided integrations.

* [tests] Add run_all_tests.sh

Add scripts to run linters, formatters and tests.

* [docu] Add user and contributor docs

Add user-facing documentation with the README.md and contributor-focused
documentation with the CONTRIBUTING.md.

* [copyright] Replace copyright headers

Replace the existing copyright header with the eclipse one.

* [buildsys] Remove starpls

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.

* [buildsys] Remove score sphinx docs targets

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.

* [security] Add a SECURITY.md file

It contains all information regarding secutiry and vulnerabilities
for this project.

* [ci] Add test github action

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.

---------

Co-authored-by: Lucas Munaretto <[email protected]>
Co-authored-by: Vitor Sorpile Geraldo <[email protected]>
Co-authored-by: Yuri.Barboza <[email protected]>
Co-authored-by: Daniel Merget <[email protected]>
Co-authored-by: João Paulo Taylor Ienczak Zanette <[email protected]>
Co-authored-by: Sascha Moecker <[email protected]>