Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bzlmod support #35

Merged
merged 6 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
11 changes: 5 additions & 6 deletions .github/workflows/licence-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
# TODO: Check on Python 3.8 too
python-version: 3.6
- name: Lint with yapf
run: bazel run //:yapf
python-version: 3.9
jwnrt marked this conversation as resolved.
Show resolved Hide resolved
- name: Check formatting with Ruff
run: bazel run :format.check
- name: Run Licence Checker
run: bazel run //:licence-check
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
bazel-*
MODULE.bazel.lock
6 changes: 0 additions & 6 deletions .style.yapf

This file was deleted.

19 changes: 15 additions & 4 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

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

licence_check(
name = "licence-check",
Expand All @@ -14,7 +15,17 @@ licence_check(
""",
)

yapf_check(
name = "yapf",
mode = "diff",
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",
)
19 changes: 19 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module(name = "lowrisc_misc_linters")

bazel_dep(name = "rules_python", version = "0.32.2")
bazel_dep(
name = "aspect_rules_lint",
version = "1.0.0-rc3",
dev_dependency = True,
)

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.9")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pip",
python_version = "3.9",
requirements_lock = "//:requirements.txt",
)
use_repo(pip, lowrisc_misc_linters_pip="pip")
37 changes: 26 additions & 11 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@

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

http_archive(
name = "bazel_skylib",
urls = [
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
],
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
)
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()

load("//rules:repos.bzl", "lowrisc_misc_linters_repos")
lowrisc_misc_linters_repos()

Expand All @@ -23,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()
2 changes: 2 additions & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
load("@aspect_rules_lint//lint:ruff.bzl", "fetch_ruff")
fetch_ruff()
Loading