Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • bazel/pre-commit-hooks
1 result
Show changes
Commits on Source (6)
# Use pre-release registry. Remove when available in BCR
common --registry https://bcr.bazel.build
common --registry=https://gitlab.arm.com/bazel/pre-commit/-/releases/v1.0.1/downloads
common --registry=https://gitlab.arm.com/bazel/pre-commit/-/releases/v1.0.4/downloads
# Enable hermetic `rules_python`
common --@rules_python//python/config_settings:bootstrap_impl=script
......
......@@ -24,6 +24,8 @@ pre_commit_hooks(
srcs = [
"//buildifier",
"//ruff",
"//shellcheck",
"//shfmt",
],
visibility = ["//visibility:public"],
)
# [1.1.0](https://git.gitlab.arm.com/bazel/pre-commit-hooks/compare/v1.0.0...v1.1.0) (2025-03-10)
### Bug Fixes
- **ruff:** check and format by default ([697bff3](https://git.gitlab.arm.com/bazel/pre-commit-hooks/commit/697bff38b6067e6703824395f3017ca16dbf2ed3))
### Features
- add 'shellcheck' hook ([273920e](https://git.gitlab.arm.com/bazel/pre-commit-hooks/commit/273920e95b17636bc7737244356067a24317caf1))
- add `shfmt` hook ([bb97eb9](https://git.gitlab.arm.com/bazel/pre-commit-hooks/commit/bb97eb9dba0e5269f2fd65c66b644575c75fa1fd))
# 1.0.0 (2025-03-05)
### Features
......
module(
name = "pre-commit-hooks",
version = "1.0.0",
version = "1.1.0",
compatibility_level = 1,
)
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "pre-commit", version = "1.0.1")
bazel_dep(name = "pre-commit", version = "1.0.4")
bazel_dep(name = "buildifier_prebuilt", version = "8.0.0")
bazel_dep(name = "download_utils", version = "1.0.1")
bazel_dep(name = "toolchain_utils", version = "1.2.0")
bazel_dep(name = "rules_shellcheck", version = "0.3.3")
bazel_dep(name = "rules_python", version = "1.0.0", dev_dependency = True)
bazel_dep(name = "hermetic_cc_toolchain", version = "3.1.0", dev_dependency = True)
......@@ -23,6 +24,8 @@ python.toolchain(
download_archive = use_repo_rule("@download_utils//download/archive:defs.bzl", "download_archive")
download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "download_file")
# Ruff binaries
[
download_archive(
......@@ -40,3 +43,22 @@ download_archive = use_repo_rule("@download_utils//download/archive:defs.bzl", "
("arm64-windows", "aarch64-pc-windows-msvc", ".zip", "sha256-ckodh0IeEldZ6bfbqxak0QNIks5BgKqvYePrvn5nr6I="),
)
]
# Shfmt binaries
[
download_file(
name = "shfmt-{}".format(name),
executable = True,
integrity = integrity,
output = "shfmt-{}".format(name),
urls = ["https://github.com/mvdan/sh/releases/download/v3.10.0/shfmt_v3.10.0_{}{}".format(couplet, ext)],
)
for name, couplet, ext, integrity in (
("amd64-linux", "linux_amd64", "", "sha256-H1ejhNWVQvj6xfUD2h8+pEJC9G3/lpVp6AtSTWS3Hbw="),
("arm64-linux", "linux_arm64", "", "sha256-nSMBPVZkDiKHMv0qBKnt4KtGvC12S/IqSjX7GxTXB6g="),
("amd64-macos", "darwin_amd64", "", "sha256-742XCz9pWn6OfUBzDu3S2TWrlZn3ijZfMZxRW8WdTIM="),
("arm64-macos", "darwin_arm64", "", "sha256-hgMFM6gjwKfNkt7g90CU5bkBwyd7Q972M31eGeVv5VM="),
("amd64-windows", "windows_amd64", ".exe", "sha256-bkxqzTjee0sbqPgIK55ojfjJuGHT+LLnuxtycCAaNYc="),
# ("arm64-windows", "windows_arm64", ".exe", ""), Currently doesn't have binary for arm64 Windows.
)
]
......@@ -52,13 +52,14 @@
"https://bcr.bazel.build/modules/jsoncpp/1.9.5/source.json": "4108ee5085dd2885a341c7fab149429db457b3169b86eb081fa245eadf69169d",
"https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902",
"https://bcr.bazel.build/modules/platforms/0.0.10/MODULE.bazel": "8cb8efaf200bdeb2150d93e162c40f388529a25852b332cec879373771e48ed5",
"https://bcr.bazel.build/modules/platforms/0.0.10/source.json": "f22828ff4cf021a6b577f1bf6341cb9dcd7965092a439f64fc1bb3b7a5ae4bd5",
"https://bcr.bazel.build/modules/platforms/0.0.11/MODULE.bazel": "0daefc49732e227caa8bfa834d65dc52e8cc18a2faf80df25e8caea151a9413f",
"https://bcr.bazel.build/modules/platforms/0.0.11/source.json": "f7e188b79ebedebfe75e9e1d098b8845226c7992b307e28e1496f23112e8fc29",
"https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee",
"https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37",
"https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615",
"https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814",
"https://bcr.bazel.build/modules/platforms/0.0.8/MODULE.bazel": "9f142c03e348f6d263719f5074b21ef3adf0b139ee4c5133e2aa35664da9eb2d",
"https://bcr.bazel.build/modules/pre-commit/1.0.1/MODULE.bazel": "not found",
"https://bcr.bazel.build/modules/pre-commit/1.0.4/MODULE.bazel": "not found",
"https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7",
"https://bcr.bazel.build/modules/protobuf/27.0/MODULE.bazel": "7873b60be88844a0a1d8f80b9d5d20cfbd8495a689b8763e76c6372998d3f64c",
"https://bcr.bazel.build/modules/protobuf/27.1/MODULE.bazel": "703a7b614728bb06647f965264967a8ef1c39e09e8f167b3ca0bb1fd80449c0d",
......@@ -137,6 +138,8 @@
"https://bcr.bazel.build/modules/rules_python/1.0.0/source.json": "b0162a65c6312e45e7912e39abd1a7f8856c2c7e41ecc9b6dc688a6f6400a917",
"https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c",
"https://bcr.bazel.build/modules/rules_shell/0.2.0/source.json": "7f27af3c28037d9701487c4744b5448d26537cc66cdef0d8df7ae85411f8de95",
"https://bcr.bazel.build/modules/rules_shellcheck/0.3.3/MODULE.bazel": "c1bf29938855c84c5f7ebaf7fa9b41bae42df25bda10c10eda9db36e1611d819",
"https://bcr.bazel.build/modules/rules_shellcheck/0.3.3/source.json": "eeb41efe82a0c27ddbac79cb68c98be1d39241481046485783cfa7d7be385b91",
"https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8",
"https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c",
"https://bcr.bazel.build/modules/stardoc/0.5.6/MODULE.bazel": "c43dabc564990eeab55e25ed61c07a1aadafe9ece96a4efabb3f8bf9063b71ef",
......@@ -152,9 +155,9 @@
"https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79",
"https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d",
"https://bcr.bazel.build/modules/zlib/1.3.1/MODULE.bazel": "751c9940dcfe869f5f7274e1295422a34623555916eb98c174c1e945594bf198",
"https://gitlab.arm.com/bazel/pre-commit/-/releases/v1.0.1/downloads/bazel_registry.json": "not found",
"https://gitlab.arm.com/bazel/pre-commit/-/releases/v1.0.1/downloads/modules/pre-commit/1.0.1/MODULE.bazel": "7d346c84a1f9438b3f46396db54375a7ffec879ac7c833bfe6be51d689e97f00",
"https://gitlab.arm.com/bazel/pre-commit/-/releases/v1.0.1/downloads/modules/pre-commit/1.0.1/source.json": "7899f4e0c85d4acf7ae9a9c36ae99cb05d72eab8411f7fbe311c7e8fa2421e96"
"https://gitlab.arm.com/bazel/pre-commit/-/releases/v1.0.4/downloads/bazel_registry.json": "not found",
"https://gitlab.arm.com/bazel/pre-commit/-/releases/v1.0.4/downloads/modules/pre-commit/1.0.4/MODULE.bazel": "9ddc49b4ae6b198c5d3a7a95f8f2881b3cac8c18403f61a0f40dc508a3ee284d",
"https://gitlab.arm.com/bazel/pre-commit/-/releases/v1.0.4/downloads/modules/pre-commit/1.0.4/source.json": "6963c89df725aed7cc090885297af63a434c7d930fae455606fc702842a94a5a"
},
"selectedYankedVersions": {},
"moduleExtensions": {
......@@ -345,20 +348,121 @@
]
}
},
"@@platforms//host:extension.bzl%host_platform": {
"@@pybind11_bazel+//:python_configure.bzl%extension": {
"general": {
"bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=",
"usagesDigest": "SeQiIN/f8/Qt9vYQk7qcXp4I4wJeEC0RnQDiaaJ4tb8=",
"bzlTransitiveDigest": "d4N/SZrl3ONcmzE98rcV0Fsro0iUbjNQFTIiLiGuH+k=",
"usagesDigest": "fycyB39YnXIJkfWCIXLUKJMZzANcuLy9ZE73hRucjFk=",
"recordedFileInputs": {
"@@pybind11_bazel+//MODULE.bazel": "88af1c246226d87e65be78ed49ecd1e6f5e98648558c14ce99176da041dc378e"
},
"recordedDirentsInputs": {},
"envVariables": {},
"generatedRepoSpecs": {
"local_config_python": {
"repoRuleId": "@@pybind11_bazel+//:python_configure.bzl%python_configure",
"attributes": {}
},
"pybind11": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"build_file": "@@pybind11_bazel+//:pybind11.BUILD",
"strip_prefix": "pybind11-2.11.1",
"urls": [
"https://github.com/pybind/pybind11/archive/v2.11.1.zip"
]
}
}
},
"recordedRepoMappingEntries": [
[
"pybind11_bazel+",
"bazel_tools",
"bazel_tools"
]
]
}
},
"@@rules_fuzzing+//fuzzing/private:extensions.bzl%non_module_dependencies": {
"general": {
"bzlTransitiveDigest": "mGiTB79hRNjmeDTQdzkpCHyzXhErMbufeAmySBt7s5s=",
"usagesDigest": "wy6ISK6UOcBEjj/mvJ/S3WeXoO67X+1llb9yPyFtPgc=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
"generatedRepoSpecs": {
"host_platform": {
"repoRuleId": "@@platforms//host:extension.bzl%host_platform_repo",
"platforms": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz"
],
"sha256": "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74"
}
},
"rules_python": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"sha256": "d70cd72a7a4880f0000a6346253414825c19cdd40a28289bdf67b8e6480edff8",
"strip_prefix": "rules_python-0.28.0",
"url": "https://github.com/bazelbuild/rules_python/releases/download/0.28.0/rules_python-0.28.0.tar.gz"
}
},
"bazel_skylib": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"sha256": "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
"urls": [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"
]
}
},
"com_google_absl": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.1.zip"
],
"strip_prefix": "abseil-cpp-20240116.1",
"integrity": "sha256-7capMWOvWyoYbUaHF/b+I2U6XLMaHmky8KugWvfXYuk="
}
},
"rules_fuzzing_oss_fuzz": {
"repoRuleId": "@@rules_fuzzing+//fuzzing/private/oss_fuzz:repository.bzl%oss_fuzz_repository",
"attributes": {}
},
"honggfuzz": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"build_file": "@@rules_fuzzing+//:honggfuzz.BUILD",
"sha256": "6b18ba13bc1f36b7b950c72d80f19ea67fbadc0ac0bb297ec89ad91f2eaa423e",
"url": "https://github.com/google/honggfuzz/archive/2.5.zip",
"strip_prefix": "honggfuzz-2.5"
}
},
"rules_fuzzing_jazzer": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_jar",
"attributes": {
"sha256": "ee6feb569d88962d59cb59e8a31eb9d007c82683f3ebc64955fd5b96f277eec2",
"url": "https://repo1.maven.org/maven2/com/code-intelligence/jazzer/0.20.1/jazzer-0.20.1.jar"
}
},
"rules_fuzzing_jazzer_api": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_jar",
"attributes": {
"sha256": "f5a60242bc408f7fa20fccf10d6c5c5ea1fcb3c6f44642fec5af88373ae7aa1b",
"url": "https://repo1.maven.org/maven2/com/code-intelligence/jazzer-api/0.20.1/jazzer-api-0.20.1.jar"
}
}
},
"recordedRepoMappingEntries": []
"recordedRepoMappingEntries": [
[
"rules_fuzzing+",
"bazel_tools",
"bazel_tools"
]
]
}
},
"@@rules_java+//java:rules_java_deps.bzl%compatibility_proxy": {
......@@ -450,7 +554,7 @@
"@@rules_python+//python/extensions:pip.bzl%pip": {
"general": {
"bzlTransitiveDigest": "2ZGbLzEhJiYeTL/HLcIGGr/4T4YIvqiLTBDeEGjVdFE=",
"usagesDigest": "9h8YW/WLJ3yXmQDXq+uhSGxppdoTUgIWH+s/kRtsZtY=",
"usagesDigest": "PXxD9LvCd3yjLLb8/legZ8QFcirNczOIKxnCiyDA2fU=",
"recordedFileInputs": {
"@@pre-commit+//pre-commit/config/requirements/lock.txt": "c4df528d05090e2268c3f64b30c016de5175939606c1ebc14088f888f5d93dd0",
"@@pre-commit+//pre-commit/hook/requirements/lock.txt": "5f20fd61af75464158a62d2d3739cefca20d6963130c6cb37e345bcfef567424",
......@@ -4180,6 +4284,95 @@
]
]
}
},
"@@rules_shellcheck+//internal:extensions.bzl%shellcheck_dependencies": {
"general": {
"bzlTransitiveDigest": "l1LMECmx4plQ9lFhLWL56vMXzWyiMP0X7m8FSnSbprs=",
"usagesDigest": "dB1tqxp4QomnAlt2Na7AnDC2qZdvV3Sjc3OCSEyzwdQ=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
"generatedRepoSpecs": {
"shellcheck_darwin_aarch64": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"build_file_content": "exports_files([\"shellcheck\"])\n",
"sha256": "a75b912015aaa5b2a48698b63f3619783d90abda4d32a31362209315e6c1cdf6",
"urls": [
"https://mirror.bazel.build/github.com/vscode-shellcheck/shellcheck-binaries/releases/download/v0.9.0/shellcheck-v0.9.0.darwin.aarch64.tar.gz",
"https://github.com/vscode-shellcheck/shellcheck-binaries/releases/download/v0.9.0/shellcheck-v0.9.0.darwin.aarch64.tar.gz"
]
}
},
"shellcheck_darwin_x86_64": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"build_file_content": "exports_files([\"shellcheck\"])\n",
"sha256": "d1244da2aa5d0c2874f3a4a680c6ac79a488ff6dbf9928e12dc80ff3fdc294db",
"urls": [
"https://mirror.bazel.build/github.com/vscode-shellcheck/shellcheck-binaries/releases/download/v0.9.0/shellcheck-v0.9.0.darwin.x86_64.tar.gz",
"https://github.com/vscode-shellcheck/shellcheck-binaries/releases/download/v0.9.0/shellcheck-v0.9.0.darwin.x86_64.tar.gz"
]
}
},
"shellcheck_linux_aarch64": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"build_file_content": "exports_files([\"shellcheck\"])\n",
"sha256": "b5633bd195cfe61a310bd8dcff2514855afefea908942a0fd4d01fa6451cb4e6",
"urls": [
"https://mirror.bazel.build/github.com/vscode-shellcheck/shellcheck-binaries/releases/download/v0.9.0/shellcheck-v0.9.0.linux.aarch64.tar.gz",
"https://github.com/vscode-shellcheck/shellcheck-binaries/releases/download/v0.9.0/shellcheck-v0.9.0.linux.aarch64.tar.gz"
]
}
},
"shellcheck_linux_armv6hf": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"build_file_content": "exports_files([\"shellcheck\"])\n",
"sha256": "4791d36d84a626c4366746d14ad68daf2c07f502da09319c45fa6c5c0a847aa9",
"urls": [
"https://mirror.bazel.build/github.com/vscode-shellcheck/shellcheck-binaries/releases/download/v0.9.0/shellcheck-v0.9.0.linux.armv6hf.tar.gz",
"https://github.com/vscode-shellcheck/shellcheck-binaries/releases/download/v0.9.0/shellcheck-v0.9.0.linux.armv6hf.tar.gz"
]
}
},
"shellcheck_linux_x86_64": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"build_file_content": "exports_files([\"shellcheck\"])\n",
"sha256": "0ab5711861e6fcafad5aa21587ee75bbd2b16505d56f41c9ba1191a83d314074",
"urls": [
"https://mirror.bazel.build/github.com/vscode-shellcheck/shellcheck-binaries/releases/download/v0.9.0/shellcheck-v0.9.0.linux.x86_64.tar.gz",
"https://github.com/vscode-shellcheck/shellcheck-binaries/releases/download/v0.9.0/shellcheck-v0.9.0.linux.x86_64.tar.gz"
]
}
},
"shellcheck_windows_x86_64": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"build_file_content": "exports_files([\"shellcheck\"])\n",
"sha256": "a0f021057b6d6a69a22f6b0db0187bcaca3f5195385e92a7555ad63a6e39ee15",
"urls": [
"https://mirror.bazel.build/github.com/vscode-shellcheck/shellcheck-binaries/releases/download/v0.9.0/shellcheck-v0.9.0.windows.x86_64.tar.gz",
"https://github.com/vscode-shellcheck/shellcheck-binaries/releases/download/v0.9.0/shellcheck-v0.9.0.windows.x86_64.tar.gz"
]
}
}
},
"recordedRepoMappingEntries": [
[
"rules_shellcheck+",
"bazel_tools",
"bazel_tools"
],
[
"rules_shellcheck+",
"rules_shellcheck",
"rules_shellcheck+"
]
]
}
}
}
}
# Use pre-release registry. Remove when available in BCR
common --registry https://bcr.bazel.build
common --registry=https://gitlab.arm.com/bazel/pre-commit/-/releases/v1.0.1/downloads
common --registry=https://gitlab.arm.com/bazel/pre-commit/-/releases/v1.0.4/downloads
# Enable hermetic `rules_python`
common --@rules_python//python/config_settings:bootstrap_impl=script
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
#!/usr/bin/env sh
set -o errexit
set -o nounset
builtin echo "$@"
load("@bazel_skylib//rules:build_test.bzl", "build_test")
build_test(
name = "shellcheck",
size = "small",
targets = [
"@pre-commit-hooks//shellcheck",
],
)
load("@bazel_skylib//rules:build_test.bzl", "build_test")
build_test(
name = "shfmt",
size = "small",
targets = [
"@pre-commit-hooks//shfmt",
],
)
......@@ -27,7 +27,7 @@ repos:
entry: bazel run --config=pre-commit -- //buildifier:lint
types_or:
- bazel
- id: //ruff
- id: //ruff:check
name: Check Python files with `ruff`
description: Performs checks with `ruff` against Python files. Will read a `ruff.toml`
for configuration.
......@@ -35,9 +35,40 @@ repos:
require_serial: true
stages:
- pre-commit
entry: bazel run --config=pre-commit -- //ruff
entry: bazel run --config=pre-commit -- //ruff:check
types:
- python
- id: //ruff:format
name: Format Python files with `ruff`
description: Performs formatting with `ruff` against Python files. Will read a
`ruff.toml` for configuration.
language: system
require_serial: true
stages:
- pre-commit
entry: bazel run --config=pre-commit -- //ruff:format
types:
- python
- id: //shellcheck
name: Lint Shell files with `shellcheck`
description: Performs linting with `shellcheck` against Shell files.
language: system
require_serial: true
stages:
- pre-commit
entry: bazel run --config=pre-commit -- //shellcheck
types:
- shell
- id: //shfmt
name: Format Shell files with `shfmt`
description: Performs formatting with `shfmt` against Shell files.
language: system
require_serial: true
stages:
- pre-commit
entry: bazel run --config=pre-commit -- //shfmt
types:
- shell
- id: //hooks:config
name: Update `pre-commit` config
description: Keeps the `.pre-commit-config.yaml` in sync with any changes to the
......
load("@pre-commit//pre-commit/hook:defs.bzl", "pre_commit_hook")
load("@pre-commit//pre-commit/hooks:defs.bzl", "pre_commit_hooks")
load("@toolchain_utils//toolchain/symlink/target:defs.bzl", "toolchain_symlink_target")
alias(
......@@ -22,7 +23,7 @@ toolchain_symlink_target(
)
pre_commit_hook(
name = "ruff",
name = "check",
src = ":cli",
args = [
"check",
......@@ -35,3 +36,27 @@ pre_commit_hook(
types = ["@pre-commit//pre-commit/tag:python"],
visibility = ["//visibility:public"],
)
pre_commit_hook(
name = "format",
src = ":cli",
args = [
"format",
"--cache-dir=.cache/ruff",
],
description = "Performs formatting with `ruff` against Python files. Will read a `ruff.toml` for configuration.",
stages = ["@pre-commit//pre-commit/stage:pre-commit"],
summary = "Format Python files with `ruff`",
types = ["@pre-commit//pre-commit/tag:python"],
visibility = ["//visibility:public"],
)
pre_commit_hooks(
name = "ruff",
srcs = [
# do not sort
":check",
":format",
],
visibility = ["//visibility:public"],
)
load("@pre-commit//pre-commit/hook:defs.bzl", "pre_commit_hook")
load("@toolchain_utils//toolchain/symlink/target:defs.bzl", "toolchain_symlink_target")
toolchain_symlink_target(
name = "cli",
target = "@rules_shellcheck//:shellcheck",
)
pre_commit_hook(
name = "shellcheck",
src = ":cli",
args = [
"-o",
"all",
],
description = "Performs linting with `shellcheck` against Shell files.",
stages = ["@pre-commit//pre-commit/stage:pre-commit"],
summary = "Lint Shell files with `shellcheck`",
types = ["@pre-commit//pre-commit/tag:shell"],
visibility = ["//visibility:public"],
)
load("@pre-commit//pre-commit/hook:defs.bzl", "pre_commit_hook")
load("@toolchain_utils//toolchain/symlink/target:defs.bzl", "toolchain_symlink_target")
alias(
name = "exe",
actual = select(
{
"@toolchain_utils//toolchain/constraint:amd64-linux": "@shfmt-amd64-linux//:shfmt-amd64-linux",
"@toolchain_utils//toolchain/constraint:arm64-linux": "@shfmt-arm64-linux//:shfmt-arm64-linux",
"@toolchain_utils//toolchain/constraint:amd64-macos": "@shfmt-amd64-macos//:shfmt-amd64-macos",
"@toolchain_utils//toolchain/constraint:arm64-macos": "@shfmt-arm64-macos//:shfmt-arm64-macos",
"@toolchain_utils//toolchain/constraint:amd64-windows": "@shfmt-amd64-windows//:shfmt-amd64-windows",
# "@toolchain_utils//toolchain/constraint:arm64-windows": "@shfmt-arm64-windows//:shfmt-arm64-windows",
},
no_match_error = "No hermetic `shfmt` found for `//pre-commit/hook/shfmt:cli`. Please set it to a hermetic `shfmt` download in `MODULE.bazel` for the current host platform.",
),
)
toolchain_symlink_target(
name = "cli",
target = ":exe",
)
pre_commit_hook(
name = "shfmt",
src = ":cli",
args = [
"-w",
],
description = "Performs formatting with `shfmt` against Shell files.",
stages = ["@pre-commit//pre-commit/stage:pre-commit"],
summary = "Format Shell files with `shfmt`",
types = ["@pre-commit//pre-commit/tag:shell"],
visibility = ["//visibility:public"],
)