From 6b5a8602a2dd2ae2c03682ad305bb9c35ca9041e Mon Sep 17 00:00:00 2001 From: "F.Tibor" Date: Fri, 15 May 2026 18:10:20 +0200 Subject: [PATCH 1/2] Initial idea for pylint through bazel --- BUILD | 28 ++++++++++++++++++++++++++++ test/pylint_runner.py | 25 +++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 test/pylint_runner.py diff --git a/BUILD b/BUILD index f273f1fd..291cd5b3 100644 --- a/BUILD +++ b/BUILD @@ -1,5 +1,6 @@ load("@aspect_rules_lint//format:defs.bzl", "format_test") load("@buildifier_prebuilt//:rules.bzl", "buildifier_test") +load("@rules_python//python:defs.bzl", "py_test") buildifier_test( name = "buildifier_native", @@ -31,3 +32,30 @@ format_test( ], workspace = "//:WORKSPACE", ) + +filegroup( + name = "all_py_files", + srcs = glob( + ["**/*.py"], + exclude = [ + "bazel-*/**", + "venv/**", + ".ci/**", + ], + ), +) + +py_test( + name = "pylint_test", + srcs = ["test/pylint_runner.py"], + args = [ + "--rcfile=$(location .pylintrc)", + "$(locations :all_py_files)", + ], + data = [ + ".pylintrc", + ":all_py_files", + ], + main = "test/pylint_runner.py", + #deps = ["@pypi//pylint"], +) diff --git a/test/pylint_runner.py b/test/pylint_runner.py new file mode 100644 index 00000000..b56fab2c --- /dev/null +++ b/test/pylint_runner.py @@ -0,0 +1,25 @@ +# Copyright 2023 Ericsson AB +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Wrapper for running pylint inside bazel's sandbox +using the provided python toolchain +""" + +import sys +from pylint import lint + +if __name__ == "__main__": + args = sys.argv[1:] + lint.Run(args) From 45ddd02100c9801d65d151f95cf0e587297abbbc Mon Sep 17 00:00:00 2001 From: "F.Tibor" Date: Fri, 15 May 2026 18:13:46 +0200 Subject: [PATCH 2/2] CI fixes --- .github/workflows/lint.yaml | 4 ++++ BUILD | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 33885a8d..fcb106da 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -27,6 +27,10 @@ jobs: - name: Analysing the code with pylint run: pylint . + - name: Analyzing the code with Buildifier + run: | + bazel test //:pylint_test --test_output=errors + - name: Analyzing the code with Buildifier run: | bazel test //:format_test --test_output=errors diff --git a/BUILD b/BUILD index 291cd5b3..0db4bf05 100644 --- a/BUILD +++ b/BUILD @@ -1,6 +1,5 @@ load("@aspect_rules_lint//format:defs.bzl", "format_test") load("@buildifier_prebuilt//:rules.bzl", "buildifier_test") -load("@rules_python//python:defs.bzl", "py_test") buildifier_test( name = "buildifier_native",