Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
b5511d6
[python] Create our first python bazel quality rule
lucasmuna Jun 26, 2024
55813b9
[black] Add black aspect and runner
lucasmuna Jun 27, 2024
0ea92d4
Toolchains from rules_python and support for both bzlmod and workspace
lucasmuna Jul 11, 2024
620cb40
[python] Improve LinterSubprocessError content
lucasmuna Jun 27, 2024
adb21f0
[isort] Add isort aspect and runner
lucasmuna Jun 27, 2024
ab8fd42
[python] Fix how python_tool_common check for relative paths
lucasmuna Jul 25, 2024
7528679
[python] Add mypy aspect and runner
lucasmuna Aug 7, 2024
b497b7b
[python] Fix mypy findings
lucasmuna Aug 6, 2024
8e7dc9b
[python] Change how we create python aspect output file name
lucasmuna Aug 7, 2024
027c80c
[python] Add ruff aspect and runner
lucasmuna Aug 14, 2024
e3078cc
[python] Create a support directory with a default pyproject file
lucasmuna Aug 14, 2024
da8747c
[python] Fix mypy nomenclature
lucasmuna Aug 21, 2024
2661216
[python] Add more `mypy` types dependencies
lucasmuna Aug 13, 2024
13a5567
[python] Improve mypy configuration
lucasmuna Aug 21, 2024
c2e8895
[python] Make python aspect py38 compatible
lucasmuna Sep 12, 2024
6bd22bf
[python] Improve how python aspect collects information
lucasmuna Sep 12, 2024
cbff0af
[python] Change python modules names that were shadowing libs
lucasmuna Sep 12, 2024
055192b
[python] Add common classes that will standardize every tool output
lucasmuna Aug 7, 2024
d8ee041
[python] Standardize isort output
vitorsorpile Nov 25, 2024
14f1c1b
[python] Add tests for isort runner
vitorsorpile Nov 26, 2024
824d56a
[python] Create test for python black runner.
Nov 28, 2024
f73906e
[python] Standarlize mypy output
Dec 3, 2024
f46227d
[python] Standarlize ruff output
Dec 2, 2024
2d823a5
[python] Remove DeprecatedLinterFindingAsError
Dec 3, 2024
02d76d8
[python] Stardardize pylint output
vitorsorpile Nov 26, 2024
a232ac8
[python] Add tests for pylint_runner
vitorsorpile Dec 2, 2024
0c5271e
[python] Black automated Fix
Dec 5, 2024
dccda33
[python] Isort Automated Fix
Dec 5, 2024
e1300a3
[python] Fix black runner test
Dec 11, 2024
59703aa
[python] Ruff Automated Fix
Dec 11, 2024
99b561f
[docs] Improve our documentation
lucasmuna Dec 3, 2024
03ebeec
[python] Improve compatibility across multiple versions
lucasmuna Jan 7, 2025
15f1a31
[bazel] Adapt every target to the new bazel infra
lucasmuna Jan 15, 2025
95c423e
[python] Add PYTHON_PATH routine to python_common_tool module
vitorsorpile Jan 14, 2025
1d3b556
[python] Fix mypy entry point
vitorsorpile Jan 22, 2025
961a35d
[python] Move tool runners common code to python_tool_common
vitorsorpile Jan 15, 2025
ace3ece
[quality] Fix mypy issues on qac/clang_tidy modules
vitorsorpile Jan 24, 2025
5c1bf51
[python] Add py_pytest rule
Feb 14, 2025
e01b506
[python] Migrate test targets from py_test to py_pytest
Feb 14, 2025
ca8ab37
[pytest] Remove non stable pytest packages
lucasmuna Feb 21, 2025
b990121
[python] Add proper typehints to python tools `execute_runner`
lucasmuna Mar 3, 2025
082193a
[python] Add JSON output to every tool
lucasmuna Mar 3, 2025
35c242b
[python] Improve `LinterFindingAsError` message
lucasmuna Mar 3, 2025
d2729bc
[python] Adequate tests to new JSON output
lucasmuna Mar 3, 2025
2c2b192
[python] Set default Finding line and column to 1
lucasmuna Mar 5, 2025
30f172e
[readme] Python module documentation
Feb 17, 2025
49cbb30
[python] Fix ruff check runner finding path
Mar 18, 2025
efa175b
[python] Improve coverage for python tool
Mar 18, 2025
7fc8d78
[documentation] Hint at --features=refactor
Mar 19, 2025
cedd626
[pylint] Take Windows Paths into account when parsing output
Mar 12, 2025
8222f4e
[pylint] Simplify Windows path handling
Mar 13, 2025
36c067a
[python] Add test to python_tool_common
Mar 11, 2025
f5ea1a7
[quality] Ignore mypy var-annotate check
vitorsorpile Feb 3, 2025
cf5e364
[python] Parse user enabled features and raise error
Apr 17, 2025
25916cc
[coverage] Add coverage to missing lines
Apr 23, 2025
262e68c
[aspects] Add mnemonic to all actions.
Moecker May 8, 2025
41f45fa
[pytest] Remove `pytest-vcr` from default plugins
lucasmuna Jun 18, 2025
7770f46
[python] Create `pip-audit` `pybinary` entry point
lucasmuna Jul 22, 2025
ed3f640
[python] Create pip-audit rule
lucasmuna Jul 22, 2025
54527e6
[pycoverage] Move pycoverage from quality-tools
jannowotsch Jul 24, 2025
539dd0f
[pycoverage] Add entry point
jannowotsch Jul 24, 2025
3fed409
[pycoverage] Adjust generator names
jannowotsch Jul 29, 2025
99bc74e
[pycoverage] Update script exit code handling
jannowotsch Jul 29, 2025
58c41c3
[pycoverage] Refactor report-generator
jannowotsch Jul 29, 2025
3500a72
[all] Rename to bazel-tools-python
jannowotsch Jul 31, 2025
cdc889d
[infra] Add bazel infrastructure
jannowotsch Jul 31, 2025
0310e68
[tests] Add test workspace
jannowotsch Jul 31, 2025
2ce9321
[tests] Add run_all_tests.sh
jannowotsch Jul 31, 2025
b2a810e
[docu] Add user and contributor docs
jannowotsch Jul 31, 2025
424c235
[copyright] Replace copyright headers
jannowotsch Aug 8, 2025
891787c
[buildsys] Remove starpls
jannowotsch Aug 11, 2025
8d37a2b
[buildsys] Remove score sphinx docs targets
jannowotsch Aug 12, 2025
fd9c5cf
[security] Add a SECURITY.md file
jannowotsch Aug 12, 2025
5d9f19b
[ci] Add test github action
jannowotsch Aug 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
56 changes: 50 additions & 6 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,53 @@
build --java_language_version=17
build --tool_java_language_version=17
build --java_runtime_version=remotejdk_17
build --tool_java_runtime_version=remotejdk_17

test --test_output=errors
common --lockfile_mode=off
common --enable_platform_specific_config

common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/
common --registry=https://bcr.bazel.build

build --incompatible_default_to_explicit_init_py
build --verbose_failures

test --test_output=errors

common:use_workspace_mode --noenable_bzlmod
common:use_workspace_mode --enable_workspace

coverage --combined_report=lcov
coverage --instrument_test_targets
coverage --instrumentation_filter="[:]"

# Python toolchain configurations
common --flag_alias=python=@rules_python//python/config_settings:python_version
build:python_3_8 --python=3.8
build:python_3_9 --python=3.9
build:python_3_10 --python=3.10
build:python_3_11 --python=3.11
build:python_3_12 --python=3.12
build --config=python_3_12

common --flag_alias=use_bazel_tools_python_toolchains=//bazel/toolchains/python:bazel_tools_python_toolchains
build:use_bazel_tools_python_toolchains --use_bazel_tools_python_toolchains=True
build:do_not_use_bazel_tools_python_toolchains --use_bazel_tools_python_toolchains=False
build --config=use_bazel_tools_python_toolchains

# Pylint configuration
build:pylint --output_groups=python_tool_output
build:pylint --aspects=@bazel_tools_python//quality:defs.bzl%pylint_aspect

# Black configuration
build:black --output_groups=python_tool_output
build:black --aspects=@bazel_tools_python//quality:defs.bzl%black_aspect

# Isort configuration
build:isort --output_groups=python_tool_output
build:isort --aspects=@bazel_tools_python//quality:defs.bzl%isort_aspect

# Mypy configuration
build:mypy --output_groups=python_tool_output
build:mypy --aspects=@bazel_tools_python//quality:defs.bzl%mypy_aspect

# Ruff configuration
build:ruff_check --output_groups=python_tool_output
build:ruff_check --aspects=@bazel_tools_python//quality:defs.bzl%ruff_check_aspect
build:ruff_format --output_groups=python_tool_output
build:ruff_format --aspects=@bazel_tools_python//quality:defs.bzl%ruff_format_aspect
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.3.0
7.5.0
10 changes: 10 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: test
on: push

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bazelbuild/setup-bazelisk@v3
- run: scripts/run_all_tests.sh
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.orig
.vscode
/out
__pycache__
bazel-*
/.coverage
/dist
*.stamp
34 changes: 34 additions & 0 deletions .gitlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Available rules:
#
# T1: title-max-length
# T2: title-trailing-whitespace
# T3: title-trailing-punctuation (disabled)
# T4: title-hard-tab
# T5: title-must-not-contain-word (disabled)
# T6: title-leading-whitespace
# T7: title-match-regex
# B1: body-max-line-length
# B2: body-trailing-whitespace
# B3: body-hard-tab
# B4: body-first-line-empty
# B5: body-min-length (disabled)
# B6: body-is-missing (disabled)
# B7: body-changed-file-mention (disabled)
#
# See http://jorisroovers.github.io/gitlint/rules/ for a full description.
[general]
ignore=T3,T5,B5,B6,B7
# Ensure every title starts with a capital letter
[title-match-regex]
regex=^([A-Z]|(\[[a-z-]+\]))\w*

[body-max-line-length]
line-length=80

[title-max-length]
line-length=80

# Allow lines starting with URLs to pass line length limit
[ignore-by-body]
regex=^https?:\/\/
ignore=body-max-line-length
20 changes: 9 additions & 11 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@
# *******************************************************************************
load("@score_cr_checker//:cr_checker.bzl", "copyright_checker")
load("@score_dash_license_checker//:dash.bzl", "dash_license_checker")
load("@score_docs_as_code//:docs.bzl", "docs")
load("@score_format_checker//:macros.bzl", "use_format_targets")
load("@score_starpls_lsp//:starpls.bzl", "setup_starpls")
load("//:project_config.bzl", "PROJECT_CONFIG")

setup_starpls(
name = "starpls_server",
visibility = ["//visibility:public"],
)

copyright_checker(
name = "copyright",
srcs = [
"bazel",
"quality",
"scripts",
"test",
"third_party",
"//:BUILD",
"//:MODULE.bazel",
],
Expand All @@ -34,7 +32,7 @@ copyright_checker(
)

dash_license_checker(
src = "//examples:cargo_lock",
src = "//third_party/pip:requirement_locks",
file_type = "", # let it auto-detect based on project_config
project_config = PROJECT_CONFIG,
visibility = ["//visibility:public"],
Expand All @@ -43,6 +41,6 @@ dash_license_checker(
# Add target for formatting checks
use_format_targets()

docs(
source_dir = "docs",
)
exports_files([
"pyproject.toml",
])
68 changes: 68 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Eclipse Safe Open Vehicle Core (SCORE)
The [Eclipse Safe Open Vehicle Core](https://projects.eclipse.org/projects/automotive.score) project aims to develop an open-source core stack for Software Defined Vehicles (SDVs), specifically targeting embedded high-performance Electronic Control Units (ECUs).
Please check the [documentation](https://eclipse-score.github.io) for more information.
The source code is hosted at [GitHub](https://github.com/eclipse-score).

The communication mainly takes place via the [`score-dev` mailing list](https://accounts.eclipse.org/mailing-list/score-dev) and GitHub issues & pull requests (PR). And we have a chatroom for community discussions here [Eclipse SCORE chatroom](https://chat.eclipse.org/#/room/#automotive.score:matrix.eclipse.org).

Please note that for the project the [Eclipse Foundation’s Terms of Use](https://www.eclipse.org/legal/terms-of-use/) apply.
In addition, you need to sign the [ECA](https://www.eclipse.org/legal/ECA.php) and the [DCO](https://www.eclipse.org/legal/dco/) to contribute to the project.

## Contributing

Want to contribute? You're welcoe and we're happy to accept your pull requests!

- [Development](#development)
- [Updating python dependencies](#updating-python-dependencies)
- [Local quality check](#local-quality-check)

### Getting involved

#### Setup Phase
This phase is part of the eclipse Incubation Phase and shall establish all the processes needed for a safe development of functions. Only after this phase it will be possible to contribute code to the project. As the development in this project is driven by requirements, the processes and needed infrastructure incl. tooling will be established based on non-functional Stakeholder_Requirements<!-- TODO: fill link to correct page with requirements -->. During setup phase the contributions are Bug Fixes and Improvements (both on processes and infrastructure).

#### Bug Fixes and Improvements
Improvements are adding/changing processes and infrastructure, bug fixes can be also on development work products like code.
In case you want to fix a bug or contribute an improvement, please perform the following steps:
1) Create a PR by using the corresponding template ([Bugfix PR template](.github/PULL_REQUEST_TEMPLATE/bug_fix.md) or [Improvement PR template](.github/PULL_REQUEST_TEMPLATE/improvement.md)). Please mark your PR as draft until it's ready for review by the Committers (see the [Eclipse Foundation Project Handbook](https://www.eclipse.org/projects/handbook/#contributing-committers) for more information on the role definitions).
2) Initiate content review by opening a corresponding issue for the PR when it is ready for review. Review of the PR and final merge into the project repository is in responsibility of the Committers. Use the [Bugfix Issue template](.github/ISSUE_TEMPLATE/bug_fix.md) or [Improvement Issue template](.github/ISSUE_TEMPLATE/improvement.md) for this.

Please check here for our Git Commit Rules in the [Configuration_Tool_Guidelines](https://eclipse-score.github.io/score/process_description/guidelines/index.html).

Please use the [Stakeholder and Tool Requirements Template](https://eclipse-score.github.io/score/process_description/templates/index.html) when defining these requirements.

#### Additional Information
Please note, that all Git commit messages must adhere the rules described in the [Eclipse Foundation Project Handbook](https://www.eclipse.org/projects/handbook/#resources-commit).

Please find process descriptions here: [process description](https://eclipse-score.github.io/score/process_description/).

### Development

#### Updating python dependencies

This repository uses Bazel `rules_python` pip integration plus a [custom pip hub implementation](bazel/rules/rules_python_pip_hub.bzl). Therefore, to add, remove or modify python pip dependencies, one should do as follows:

1. Update the dependency and its version under [requirements.in](third_party/pip/requirements.in);
2. Lock pip requirements by executing `bazel run //third_party/pip:update.sh`. This will update all `requirements_lock_3_*.txt` files under `third_party/pip`;
3. Test the updated requirements by executing `bazel run //third_party/pip:test.sh`.

After this was successfully done, it is possible to load pip packges into bazel targets. To load the pip dependency package itself (common use case), one can use our pip hub `pkg` alias.

```python
load("@bazel_tools_python_pip_hub//:loaders.bzl", "pkg")

py_binary(
...
deps = [
pkg("pip_package_name"),
],
...
)
```

Other options are also available through other pip hub aliases, for example, the dependency data can be accessed using the `data` alias.

#### Local quality check

Ideally, one should verify code quality locally before pushing changes to the CI. This avoids unecessary CI jobs and can even speed up development.
To do that, simply run [`scripts/run_all_tests.sh`](scripts/run_all_tests.sh).
138 changes: 102 additions & 36 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,55 +11,121 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
module(
name = "cpp_rust_template_repository",
version = "1.0",
name = "bazel_tools_python",
version = "0.1.0",
compatibility_level = 1,
)

bazel_dep(name = "rules_python", version = "1.4.1")
# Checker rule for CopyRight checks/fixs
bazel_dep(name = "score_cr_checker", version = "0.3.1", dev_dependency = True)
bazel_dep(name = "score_python_basics", version = "0.3.4", dev_dependency = True)

# Dash license checker
bazel_dep(name = "score_dash_license_checker", version = "0.1.2", dev_dependency = True)

PYTHON_VERSION = "3.12"
# Format checker
bazel_dep(name = "score_format_checker", version = "0.1.1", dev_dependency = True)
bazel_dep(name = "aspect_rules_lint", version = "1.4.4", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2", dev_dependency = True)

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
is_default = True,
python_version = PYTHON_VERSION,
# docs-as-code
bazel_dep(name = "score_docs_as_code", version = "1.0.1", dev_dependency = True)
bazel_dep(name = "platforms", version = "0.0.11", dev_dependency = True)

# Unfortunately bazel_skylib can not be dev_dependency because we use some of its libraries.
bazel_dep(name = "bazel_skylib", version = "1.7.1")

# Unfortunately rules_python can not be dev_dependency because we provide our pip hub using it.
bazel_dep(name = "rules_python", version = "1.4.1")

# We patch rules_python patch to python coverage files.
# This enable us to select our own .coveragerc file when issuing a bazel coverage command.
# Reference: https://github.com/bazelbuild/rules_python/blob/main/python/private/coverage.patch
single_version_override(
module_name = "rules_python",
patches = ["@bazel_tools_python//third_party/rules_python:rules_python.patch"],
)
use_repo(python)

# Add GoogleTest dependency
bazel_dep(name = "googletest", version = "1.14.0")
# Python toolchain and dependencies

# Rust rules for Bazel
bazel_dep(name = "rules_rust", version = "0.56.0")
PYTHON_VERSIONS = [
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
]

# Checker rule for CopyRight checks/fixs
bazel_dep(name = "score_cr_checker", version = "0.3.1")
bazel_dep(name = "score_python_basics", version = "0.3.4")
bazel_dep(name = "score_starpls_lsp", version = "0.1.0")
# By default, one can't add `dev_dependency = True` to `python` extension from
# `@rules_python//python/extensions:python.bzl` if python dependencies are
# provided to the end user. To circumvent that, we rely on a conditional
# statement by the mentioned extension, see:
# https://github.com/bazelbuild/rules_python/blob/89d850aab819eb2dea9d6340beab1ca810dbe18d/python/private/pypi/extension.bzl#L111

# C/C++ rules for Bazel
bazel_dep(name = "rules_cc", version = "0.1.1")
# The result is that `dev_dependency` can only be added to `python` extension
# if every `pip_parse` has `python_interpreter` set. We set `python_interpreter`
# to `python3` value because every hermetic toolchain has it as a symlink to
# the real executable.

# LLVM Toolchains Rules - host configuration
bazel_dep(name = "toolchains_llvm", version = "1.2.0")
# More info about this can be found at:
# https://github.com/bazelbuild/rules_python/issues/1818#issuecomment-2271227487

llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
cxx_standard = {"": "c++17"},
llvm_version = "19.1.0",
python = use_extension("@rules_python//python/extensions:python.bzl", "python")

[
python.toolchain(
configure_coverage_tool = True,
ignore_root_user_error = True,
is_default = False,
python_version = "{}".format(version),
)
for version in PYTHON_VERSIONS
]

# We can't use a loop for the following `use_repo` because we change the name of each toolchain.
# buildifier: leave-alone
use_repo(
python,
bazel_tools_python_python_3_8 = "python_3_8",
bazel_tools_python_python_3_9 = "python_3_9",
bazel_tools_python_python_3_10 = "python_3_10",
bazel_tools_python_python_3_11 = "python_3_11",
bazel_tools_python_python_3_12 = "python_3_12",
)
use_repo(llvm, "llvm_toolchain")
use_repo(llvm, "llvm_toolchain_llvm")

register_toolchains("@llvm_toolchain//:all")
[
register_toolchains(
"@bazel_tools_python//bazel/toolchains/python:bazel_tools_python_python_{}_toolchain".format(version.replace(".", "_")),
dev_dependency = True,
)
for version in PYTHON_VERSIONS
]

# Dash license checker
bazel_dep(name = "score_dash_license_checker", version = "0.1.2")
register_toolchains(
"@bazel_tools_python//bazel/toolchains/python:py_undefined_trap",
dev_dependency = True,
)

# Format checker
bazel_dep(name = "score_format_checker", version = "0.1.1")
bazel_dep(name = "aspect_rules_lint", version = "1.4.4")
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")
register_toolchains(
"@bazel_tools_python//bazel/toolchains/python:do_not_use_bazel_tools_python_toolchains_trap",
dev_dependency = True,
)

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")

[
pip.parse(
hub_name = "bazel_tools_python_pip_{}".format(version.replace(".", "_")),
python_version = "{}".format(version),
requirements_lock = "//third_party/pip:requirements_lock_{}.txt".format(version.replace(".", "_")),
)
for version in PYTHON_VERSIONS
]

[
use_repo(pip, "bazel_tools_python_pip_{}".format(version.replace(".", "_")))
for version in PYTHON_VERSIONS
]

#docs-as-code
bazel_dep(name = "score_docs_as_code", version = "1.0.1")
rules_python_pip_hub = use_extension("@bazel_tools_python//third_party:extensions.bzl", "rules_python_pip_hub")
use_repo(rules_python_pip_hub, "bazel_tools_python_pip_hub")
Loading
Loading