Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 8 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@ jobs:
with:
python-version: "3.10"

- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.15.0

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
echo "6.5.0" > .bazelversion

- name: Analysing the code with pylint
run: pylint .

- name: Analyzing the code with Buildifier
run: |
pylint .
bazel test //:buildifier --test_output=errors

# TODO: Add more linters here
31 changes: 31 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@aspect_rules_lint//format:defs.bzl", "format_test")
load("@buildifier_prebuilt//:rules.bzl", "buildifier_test")

buildifier_test(
name = "buildifier_native",
diff_command = "diff -u",
exclude_patterns = [
"./.git/*",
],
mode = "diff",
lint_mode = "warn",
no_sandbox = True,
workspace = "//:WORKSPACE",
)

format_test(
name = "format_test",
no_sandbox = True,
# TODO: extend with pylint
starlark = "@buildifier_prebuilt//:buildifier",
starlark_check_args = [
"-lint=warn",
"-warnings=all",
"-mode=diff",
# -u will always get passed to buildifier not diff_command
#"-diff_command=\"diff -u\"",
],
workspace = "//:WORKSPACE",
# Temporary workaround for not being able to use -diff_command
env = ["BUILDIFIER_DIFF='diff -u'"],
)
7 changes: 7 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ limitations under the License.

module(name = "rules_codechecker")

bazel_dep(
name = "buildifier_prebuilt",
version = "6.4.0",
dev_dependency = True,
)
bazel_dep(name = "aspect_rules_lint", version = "1.11.0", dev_dependency = True)

python_extension = use_extension(
"//src:tools.bzl",
"module_register_default_python_toolchain",
Expand Down
51 changes: 51 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,54 @@ register_default_python_toolchain()
register_toolchains("@default_python_tools//:python_toolchain")

register_default_codechecker()

# Dev dependencies

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "buildifier_prebuilt",
sha256 = "8ada9d88e51ebf5a1fdff37d75ed41d51f5e677cdbeafb0a22dda54747d6e07e",
strip_prefix = "buildifier-prebuilt-6.4.0",
urls = [
"http://github.com/keith/buildifier-prebuilt/archive/6.4.0.tar.gz",
],
)

load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")

buildifier_prebuilt_deps()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")

buildifier_prebuilt_register_toolchains()

http_archive(
name = "aspect_rules_lint",
sha256 = "329cf5ba776a75b70049a5695e9ca29a25113230f4f447aff7102b62afe7c24a",
strip_prefix = "rules_lint-1.11.0",
url = "https://github.com/aspect-build/rules_lint/releases/download/v1.11.0/rules_lint-v1.11.0.tar.gz",
)

http_archive(
name = "bazel_lib",
sha256 = "0758ace949a93f709230a8e08ef35c5f0aacae2ff5d219b27da1d21d8233a709",
strip_prefix = "bazel-lib-3.0.0-rc.0",
url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v3.0.0-rc.0/bazel-lib-v3.0.0-rc.0.tar.gz",
)

load("@bazel_lib//lib:repositories.bzl", "bazel_lib_dependencies")

bazel_lib_dependencies()

load(
"@aspect_rules_lint//format:repositories.bzl",
# Fetch additional formatter binaries you need:
"rules_lint_dependencies",
)

rules_lint_dependencies()
Loading