Skip to content

Commit 820a72e

Browse files
committed
lint: fix linting of starlark files
1 parent c4990a7 commit 820a72e

7 files changed

Lines changed: 10 additions & 12 deletions

File tree

BUILD

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
load("@gazelle//:def.bzl", "gazelle")
2-
load("@rules_python//python:defs.bzl", "py_runtime_pair")
3-
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
4-
load("@rules_go//go:def.bzl", "TOOLS_NOGO", "nogo")
52
load("@npm//:defs.bzl", "npm_link_all_packages")
3+
load("@rules_go//go:def.bzl", "TOOLS_NOGO", "nogo")
4+
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
65

76
# gazelle:map_kind go_binary ${project}_go_binary //tools/rules/golang:defs.bzl
87
# gazelle:map_kind go_library ${project}_go_library //tools/rules/golang:defs.bzl

lint.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,17 @@ BAZEL_FILES=$(find ${REPO_ROOT} -type f \
2424
-o -name "*.BUILD" \
2525
-o -name "BUILD.*.bazel" \
2626
-o -name "BUILD.*.oss" \
27+
-o -name "MODULE.bazel" \
2728
-o -name "WORKSPACE" \
2829
-o -name "WORKSPACE.bazel" \
2930
-o -name "WORKSPACE.oss" \
3031
-o -name "WORKSPACE.*.bazel" \
3132
-o -name "WORKSPACE.*.oss" \) \
32-
-o -name "MODULE.bazel" \
3333
-print)
34-
BUILDIFIER_ARGS=("-mode=fix" "-v=false")
34+
BUILDIFIER_ARGS=("-lint=fix" "-mode=fix" "-v=false")
3535
BUILDIFIER_INVOCATION="bazel run -- //tools/buildifier ${BUILDIFIER_ARGS[@]}"
3636
echo $BAZEL_FILES | xargs ${BUILDIFIER_INVOCATION}
3737

38-
3938
#################
4039
# Python linting
4140
#################
@@ -46,7 +45,6 @@ bazel run -- //tools/black ${REPO_ROOT}
4645
# Ensure flake8 compliance
4746
bazel run -- //tools/flake8 ${REPO_ROOT}
4847

49-
5048
#################
5149
# Go linting
5250
#################
@@ -55,7 +53,6 @@ GOFMT_ARGS=("")
5553
GOFMT_INVOCATION="bazel run -- @rules_go//go fmt ${GOFMT_ARGS[@]}"
5654
echo $GO_FILES | xargs ${GOFMT_INVOCATION}
5755

58-
5956
#################
6057
# Markdown Linting
6158
#################

project/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
load("@pip//:requirements.bzl", "requirement")
21
load("//tools/rules/python:defs.bzl", "${project}_py_binary", "${project}_py_image", "${project}_py_test")
32

43
# gazelle:prefix github.com/example/${project}

project/golang-example/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//tools/rules/golang:defs.bzl", "${project}_go_binary", "${project}_go_library", "${project}_go_test", "${project}_go_image")
1+
load("//tools/rules/golang:defs.bzl", "${project}_go_binary", "${project}_go_image", "${project}_go_library", "${project}_go_test")
22

33
${project}_go_library(
44
name = "golang-example_lib",

tools/platforms/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
platform(
32
name = "container_aarch64_linux",
43
constraint_values = [

tools/rules/golang/defs.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def _go_layers(name, binary):
6969
Returns:
7070
A list of labels for the generated layers, which are tar files.
7171
"""
72+
7273
# The order of the layers here should be from least to most frequently changing.
7374
layers = ["app"]
7475

@@ -147,6 +148,7 @@ def ${project}_go_image(name, binary, image_tags, include_runfiles = True, tars
147148
workspace_path = binary.split(":")[0][2:]
148149
else:
149150
workspace_path = native.package_name()
151+
150152
# Outputs from go_binary targets add an extra directory with a random underscore to the path
151153
entrypoint = entrypoint or ["/{}/{}_/{}".format(workspace_path, bin_name, bin_name)]
152154

tools/rules/python/defs.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")
22
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
3-
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
43
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball")
4+
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
55

66
# These rules exist primarily as a way to provide a simple `main` wrapper for
77
# py_test rules, so we don't have to provide a main stub for every test target.
@@ -74,6 +74,7 @@ def _py_layers(name, binary):
7474
Returns:
7575
A list of labels for the layers, which are tar files
7676
"""
77+
7778
# Produce layers in this order, as the app changes most often
7879
layers = ["interpreter", "packages", "app"]
7980

@@ -160,6 +161,7 @@ def ${project}_py_image(name, binary, image_tags, tars = [], base = None, entryp
160161
image_tags = ["my-tag:latest"],
161162
)
162163
"""
164+
163165
# NOTE: We would ideally use the @distroless_base image here, which is about 140MB smaller,
164166
# but rules_python depends on the host python toolchain to start a py_binary, so we need to
165167
# use a base image that ships python.

0 commit comments

Comments
 (0)