Skip to content

Commit

Permalink
Add aspect_rules_lint Python formatting with Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnrt committed Jun 12, 2024
1 parent d021345 commit 33907ce
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/licence-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ jobs:
with:
# TODO: Check on Python 3.8 too
python-version: 3.6
- name: Check formatting with Ruff
run: bazel run :format.check
- name: Run Licence Checker
run: bazel run //:licence-check
16 changes: 16 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

load("//rules:rules.bzl", "licence_check")
load("@aspect_rules_lint//format:defs.bzl", "format_multirun")

licence_check(
name = "licence-check",
Expand All @@ -13,3 +14,18 @@ licence_check(
SPDX-License-Identifier: Apache-2.0
""",
)

alias(
name = "ruff",
actual = select({
"@bazel_tools//src/conditions:linux_x86_64": "@ruff_x86_64-unknown-linux-gnu//:ruff",
"@bazel_tools//src/conditions:linux_aarch64": "@ruff_aarch64-unknown-linux-gnu//:ruff",
"@bazel_tools//src/conditions:darwin_arm64": "@ruff_aarch64-apple-darwin//:ruff",
"@bazel_tools//src/conditions:darwin_x86_64": "@ruff_x86_64-apple-darwin//:ruff",
}),
)

format_multirun(
name = "format",
python = ":ruff",
)
26 changes: 26 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,29 @@ lowrisc_misc_linters_dependencies()

load("//rules:pip.bzl", "lowrisc_misc_linters_pip_dependencies")
lowrisc_misc_linters_pip_dependencies()

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "aspect_rules_lint",
sha256 = "6da562afb6e328757eb29f3ad044e273317371139d245eac0a74b60173d36025",
strip_prefix = "rules_lint-1.0.0-rc3",
url = "https://github.com/aspect-build/rules_lint/releases/download/v1.0.0-rc3/rules_lint-v1.0.0-rc3.tar.gz",
)

# aspect_rules_lint depends on aspect_bazel_lib. Either 1.x or 2.x works.
http_archive(
name = "aspect_bazel_lib",
sha256 = "6d758a8f646ecee7a3e294fbe4386daafbe0e5966723009c290d493f227c390b",
strip_prefix = "bazel-lib-2.7.7",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.7/bazel-lib-v2.7.7.tar.gz",
)
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")

# aspect_bazel_lib depends on bazel_skylib
aspect_bazel_lib_dependencies()

load("@aspect_rules_lint//format:repositories.bzl", "rules_lint_dependencies")
rules_lint_dependencies()

load("@aspect_rules_lint//lint:ruff.bzl", "fetch_ruff")
fetch_ruff()

0 comments on commit 33907ce

Please sign in to comment.