chore: bring in aspect_rules_lint and add format task to Aspect Workflows (#681)

This commit is contained in:
Greg Magolan 2023-12-07 23:34:24 -08:00 committed by GitHub
parent d1642aa020
commit bb64a79dc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 92 additions and 20 deletions

View File

@ -5,27 +5,40 @@ env:
workspaces:
- .
- e2e/smoke:
gazelle:
without: true
buildifier:
without: true
tasks:
format:
without: true
gazelle:
without: true
buildifier:
without: true
- e2e/coreutils:
gazelle:
without: true
buildifier:
without: true
tasks:
format:
without: true
gazelle:
without: true
buildifier:
without: true
- e2e/copy_to_directory:
gazelle:
without: true
buildifier:
without: true
tasks:
format:
without: true
gazelle:
without: true
buildifier:
without: true
- e2e/external_copy_to_directory:
gazelle:
without: true
buildifier:
without: true
tasks:
format:
without: true
gazelle:
without: true
buildifier:
without: true
tasks:
branch_freshness:
format:
soft_fail: false
gazelle:
buildifier:
test:

View File

@ -36,3 +36,10 @@ repos:
exclude: &exclude_pattern "^(docs|e2e|lib/tests)/"
- id: mixed-line-ending
- id: trailing-whitespace
- repo: local
hooks:
- id: aspect_rules_lint
name: Format
language: system
entry: bazel run //:format
files: .*

View File

@ -63,6 +63,11 @@ buildifier(
tags = ["manual"], # tag as manual so windows ci does not build it by default
)
alias(
name = "format",
actual = "//tools:format",
)
bzl_library(
name = "internal_deps",
srcs = ["internal_deps.bzl"],

View File

@ -66,3 +66,14 @@ buildifier_prebuilt_deps()
load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")
buildifier_prebuilt_register_toolchains()
# rules_lint
load(
"@aspect_rules_lint//format:repositories.bzl",
"fetch_shfmt",
"fetch_terraform",
)
fetch_shfmt()
fetch_terraform()

View File

@ -57,9 +57,14 @@ def bazel_lib_internal_deps():
name = "buildifier_prebuilt",
sha256 = "72b5bb0853aac597cce6482ee6c62513318e7f2c0050bc7c319d75d03d8a3875",
strip_prefix = "buildifier-prebuilt-6.3.3",
urls = [
"https://github.com/keith/buildifier-prebuilt/archive/6.3.3.tar.gz",
],
urls = ["https://github.com/keith/buildifier-prebuilt/archive/6.3.3.tar.gz"],
)
http_archive(
name = "aspect_rules_lint",
sha256 = "604666ec7ffd4f5f2636001ae892a0fbc29c77401bb33dd10601504e3ba6e9a7",
strip_prefix = "rules_lint-0.6.1",
url = "https://github.com/aspect-build/rules_lint/releases/download/v0.6.1/rules_lint-v0.6.1.tar.gz",
)
# Register toolchains for tests

View File

@ -1,3 +1,4 @@
load("@aspect_rules_lint//format:defs.bzl", "multi_formatter_binary")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//lib:utils.bzl", "is_bazel_6_or_greater")
load("//lib:write_source_files.bzl", "write_source_files")
@ -7,6 +8,36 @@ exports_files([
"create_version.sh",
])
alias(
name = "shfmt",
actual = select({
"@bazel_tools//src/conditions:darwin_arm64": "@shfmt_darwin_aarch64//file:shfmt",
"@bazel_tools//src/conditions:darwin_x86_64": "@shfmt_darwin_x86_64//file:shfmt",
"@bazel_tools//src/conditions:linux_aarch64": "@shfmt_linux_aarch64//file:shfmt",
"@bazel_tools//src/conditions:linux_x86_64": "@shfmt_linux_x86_64//file:shfmt",
}),
visibility = ["//:__subpackages__"],
)
alias(
name = "terraform",
actual = select({
"@bazel_tools//src/conditions:darwin_arm64": "@terraform_macos_aarch64//:terraform",
"@bazel_tools//src/conditions:darwin_x86_64": "@terraform_macos_x86_64//:terraform",
"@bazel_tools//src/conditions:linux": "@terraform_linux_x86_64//:terraform",
}),
visibility = ["//:__subpackages__"],
)
multi_formatter_binary(
name = "format",
go = "@go_sdk//:bin/gofmt",
sh = ":shfmt",
starlark = "@buildifier_prebuilt//:buildifier",
terraform = ":terraform",
visibility = ["//:__subpackages__"],
)
write_source_files(
name = "releases_versions_check_in",
files = {