Skip to content

Commit e4b9803

Browse files
committed
chore(lint): enable buf lint test, expand buildifier lint, and fix docs
- Add `//api:protos_lint_test` (`buf_lint_test`) and `lint:` config (`STANDARD` with multi-directory package exceptions and descriptor-path `ignore_only` baseline) in `api/buf.yaml`. - Expand `buildifier` to `-lint=warn` in `.githooks/pre-commit` and `.github/workflows/lint.yml` with a runtime probe excluding Google-only `-LANG_proto_library-single-deps,-inline-deps` when supported, use `git ls-files` cleanly in `check_bazel`, fix `make-location` (`$(execpath)`) and `constant-glob` warnings across 9 `BUILD.bazel` files + `oci.bzl`, and add `oci.bzl` docstrings. - Replace dead `deploy/ctk_v1/README.md` link in `docs/design/topologies.md` and document `//api:protos_lint_test` and `buildifier -lint=warn` in `docs/developer.md`. TAG=agy CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
1 parent ce31da0 commit e4b9803

16 files changed

Lines changed: 133 additions & 38 deletions

File tree

‎.githooks/pre-commit‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,34 @@ check_bazel() {
4040
fi
4141

4242
echo "--> Running Bazel Formatter & Linter (Buildifier)..."
43-
local bazel_files
44-
bazel_files=$(find . -type f \( -name "BUILD" -o -name "BUILD.bazel" -o -name "*.bzl" -o -name "WORKSPACE" -o -name "MODULE.bazel" \) -not -path "*/node_modules/*")
45-
if [ -n "$bazel_files" ]; then
46-
if [ "$MODE" = "check" ]; then
47-
if ! $buildifier_bin -lint=warn -warnings=unused-variable -mode=check $bazel_files; then
48-
echo "❌ Bazel buildifier check failed."
49-
FAILED=1
50-
fi
51-
else
52-
$buildifier_bin -lint=fix -warnings=unused-variable -mode=fix $bazel_files
43+
local bazel_files=()
44+
local file
45+
while IFS= read -r file; do
46+
if [ -n "${file}" ]; then bazel_files+=("${file}"); fi
47+
done < <(git -c core.quotePath=false ls-files --cached --others --exclude-standard -- \
48+
'BUILD' ':(glob)**/BUILD' 'BUILD.bazel' ':(glob)**/BUILD.bazel' '*.bzl' ':(glob)**/*.bzl' 'WORKSPACE' 'MODULE.bazel' \
49+
| sort -u || true)
50+
if [ "${#bazel_files[@]}" -eq 0 ]; then
51+
return
52+
fi
53+
54+
# LANG_proto_library-single-deps and inline-deps are Google-internal buildifier warnings
55+
# (unrecognized by upstream OSS buildifier, e.g., CI v8.0.3), so only exclude them when supported.
56+
local buildifier_warn_args=()
57+
local google_warnings="-LANG_proto_library-single-deps,-inline-deps"
58+
if "${buildifier_bin}" -lint=warn -warnings="${google_warnings}" -mode=check -type=build </dev/null >/dev/null 2>&1; then
59+
buildifier_warn_args=(-warnings="${google_warnings}")
60+
fi
61+
62+
if [ "${MODE}" = "fix" ]; then
63+
if ! "${buildifier_bin}" -lint=fix ${buildifier_warn_args[@]+"${buildifier_warn_args[@]}"} -mode=fix "${bazel_files[@]}"; then
64+
FAILED=1
5365
fi
5466
fi
67+
if ! "${buildifier_bin}" -lint=warn ${buildifier_warn_args[@]+"${buildifier_warn_args[@]}"} -mode=check "${bazel_files[@]}"; then
68+
echo "❌ Bazel buildifier check failed."
69+
FAILED=1
70+
fi
5571
}
5672

5773
check_go() {

‎.github/workflows/lint.yml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,18 @@ jobs:
182182
curl -sSfL https://github.com/bazelbuild/buildtools/releases/download/v8.0.3/buildifier-linux-amd64 -o "$GOPATH_BIN/buildifier"
183183
chmod +x "$GOPATH_BIN/buildifier"
184184
fi
185-
mapfile -t BAZEL_FILES < <(find . -type f \( -name "BUILD" -o -name "BUILD.bazel" -o -name "*.bzl" -o -name "WORKSPACE" -o -name "MODULE.bazel" \) -not -path "*/node_modules/*" | sort)
185+
mapfile -t BAZEL_FILES < <(git -c core.quotePath=false ls-files --cached --others --exclude-standard -- \
186+
'BUILD' ':(glob)**/BUILD' 'BUILD.bazel' ':(glob)**/BUILD.bazel' '*.bzl' ':(glob)**/*.bzl' 'WORKSPACE' 'MODULE.bazel' \
187+
| sort -u)
188+
# LANG_proto_library-single-deps and inline-deps are Google-internal buildifier warnings
189+
# (unrecognized by upstream OSS buildifier, e.g., CI v8.0.3), so only exclude them when supported.
190+
BUILDIFIER_WARN_ARGS=()
191+
GOOGLE_WARNINGS="-LANG_proto_library-single-deps,-inline-deps"
192+
if buildifier -lint=warn -warnings="${GOOGLE_WARNINGS}" -mode=check -type=build </dev/null >/dev/null 2>&1; then
193+
BUILDIFIER_WARN_ARGS=(-warnings="${GOOGLE_WARNINGS}")
194+
fi
186195
if [ "${#BAZEL_FILES[@]}" -gt 0 ]; then
187-
buildifier -lint=warn -warnings=unused-variable -mode=check "${BAZEL_FILES[@]}"
196+
buildifier -lint=warn ${BUILDIFIER_WARN_ARGS[@]+"${BUILDIFIER_WARN_ARGS[@]}"} -mode=check "${BAZEL_FILES[@]}"
188197
fi
189198
190199
- name: 'Install & Run addlicense'

‎api/BUILD.bazel‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("@rules_buf//buf:defs.bzl", "buf_breaking_test")
15+
load("@rules_buf//buf:defs.bzl", "buf_breaking_test", "buf_lint_test")
1616
load("@rules_proto//proto:defs.bzl", "proto_descriptor_set")
1717

1818
# Every //api proto_library. The `cloud_xmanager_v1_proto` targets duplicate
@@ -55,3 +55,10 @@ buf_breaking_test(
5555
limit_to_input_files = False,
5656
targets = _PROTOS,
5757
)
58+
59+
buf_lint_test(
60+
name = "protos_lint_test",
61+
config = "buf.yaml",
62+
error_format = "msvs",
63+
targets = _PROTOS,
64+
)

‎api/buf.yaml‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# Breaking-change rules for //api:protos_breaking_test.
15+
# Breaking-change and lint rules for //api:protos_breaking_test and //api:protos_lint_test.
1616
version: v2
1717
breaking:
1818
# FILE, the strictest category, also protects generated code (e.g. moving types).
@@ -23,3 +23,49 @@ breaking:
2323
# Off on purpose: components v1alpha1 messages are persisted with proto.Marshal
2424
# (internal/storage/data/component.go), so unstable packages must stay compatible.
2525
ignore_unstable_packages: false
26+
lint:
27+
use: [STANDARD]
28+
# Proto sources are grouped by service directory with distinct go_package/java options
29+
# even where messages share package cloud.xmanager.v1.
30+
except:
31+
- PACKAGE_DIRECTORY_MATCH
32+
- PACKAGE_SAME_DIRECTORY
33+
- PACKAGE_SAME_GO_PACKAGE
34+
- PACKAGE_SAME_JAVA_MULTIPLE_FILES
35+
# buf_lint_test lints FileDescriptorSet images via protoc-gen-buf-lint, so ignore_only paths
36+
# must match compiled descriptor names (api/... and xmanager_cloud/...) rather than api/-relative paths.
37+
ignore_only:
38+
ENUM_VALUE_PREFIX:
39+
- api/filter/filter_expression.proto
40+
- api/protos/task_queue/task.proto
41+
- xmanager_cloud/dashboard_service/proto/messages.proto
42+
- xmanager_cloud/experiment_state_server/proto/artifact.proto
43+
- xmanager_cloud/experiment_state_server/proto/experiment.proto
44+
- xmanager_cloud/experiment_state_server/proto/operations.proto
45+
- xmanager_cloud/experiment_state_server/proto/priority.proto
46+
- xmanager_cloud/experiment_state_server/proto/status.proto
47+
- xmanager_cloud/experiment_state_server/proto/structured_message.proto
48+
- xmanager_cloud/experiment_state_server/proto/study.proto
49+
- xmanager_cloud/experiment_state_server/proto/work_unit.proto
50+
- xmanager_cloud/experiment_state_server/proto/work_unit_execution.proto
51+
- xmanager_cloud/xid_service/proto/messages.proto
52+
ENUM_ZERO_VALUE_SUFFIX:
53+
- xmanager_cloud/dashboard_service/proto/messages.proto
54+
# TODO: Remove unused structured_message.proto import from api/protos/experiment/api.proto
55+
# when proto cleanup is scheduled (not modified here to preserve frozen API files).
56+
IMPORT_USED:
57+
- xmanager_cloud/experiment_state_server/proto/api.proto
58+
PACKAGE_VERSION_SUFFIX:
59+
- api/filter/filter_expression.proto
60+
RPC_REQUEST_RESPONSE_UNIQUE:
61+
- xmanager_cloud/dashboard_service/proto/dashboard_service.proto
62+
- xmanager_cloud/experiment_state_server/proto/api.proto
63+
- xmanager_cloud/xid_service/proto/api.proto
64+
RPC_REQUEST_STANDARD_NAME:
65+
- xmanager_cloud/experiment_state_server/proto/api.proto
66+
- xmanager_cloud/xid_service/proto/api.proto
67+
RPC_RESPONSE_STANDARD_NAME:
68+
- api/protos/health/api.proto
69+
- xmanager_cloud/dashboard_service/proto/dashboard_service.proto
70+
- xmanager_cloud/experiment_state_server/proto/api.proto
71+
- xmanager_cloud/xid_service/proto/api.proto

‎cmd/ui/BUILD.bazel‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ genrule(
3030
"*.html",
3131
"*.json",
3232
"*.svg",
33-
"nginx.conf",
34-
"generate_config.sh",
3533
],
3634
allow_empty = True,
37-
) + [":build_ui_oci.py"],
35+
) + [
36+
"nginx.conf",
37+
"generate_config.sh",
38+
":build_ui_oci.py",
39+
],
3840
outs = ["ui_image_tarball.tar"],
39-
cmd = "python3 $(location :build_ui_oci.py) $@",
41+
cmd = "python3 $(execpath :build_ui_oci.py) $@",
4042
tools = [":build_ui_oci.py"],
4143
visibility = ["//visibility:public"],
4244
)
@@ -141,9 +143,9 @@ py_test(
141143
"*.html",
142144
"*.json",
143145
"*.svg",
144-
"package-lock.json",
146+
]) + [
145147
"karma.conf.js",
146-
]),
148+
],
147149
main = "run_ui_tests.py",
148150
tags = [
149151
"local",

‎deploy/helm/BUILD.bazel‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414

1515
filegroup(
1616
name = "chart",
17-
srcs = glob([
17+
srcs = [
1818
"Chart.yaml",
1919
"values.yaml",
2020
"values-local.yaml",
21+
] + glob([
2122
"templates/**",
2223
]),
2324
visibility = ["//visibility:public"],

‎deploy/profiles/stable-2026a/components/clickhouse/BUILD.bazel‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
filegroup(
1616
name = "chart",
17-
srcs = glob([
17+
srcs = [
1818
"Chart.yaml",
1919
"values.yaml",
20+
] + glob([
2021
"templates/**",
2122
]),
2223
visibility = ["//visibility:public"],

‎deploy/profiles/stable-2026a/components/hpo/BUILD.bazel‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
filegroup(
55
name = "chart",
6-
srcs = glob([
6+
srcs = [
77
"Chart.yaml",
88
"values.yaml",
9+
] + glob([
910
"templates/**",
1011
]),
1112
visibility = ["//visibility:public"],

‎deploy/profiles/stable-2026a/components/ingestion-gateway/BUILD.bazel‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
filegroup(
55
name = "chart",
6-
srcs = glob([
6+
srcs = [
77
"Chart.yaml",
88
"values.yaml",
9+
] + glob([
910
"templates/**",
1011
]),
1112
visibility = ["//visibility:public"],

‎deploy/profiles/stable-2026a/components/redpanda/BUILD.bazel‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
filegroup(
1616
name = "chart",
17-
srcs = glob([
17+
srcs = [
1818
"Chart.yaml",
1919
"values.yaml",
20+
] + glob([
2021
"templates/**",
2122
]),
2223
visibility = ["//visibility:public"],

0 commit comments

Comments
 (0)