10000 Enable buildifier presubmit check (#245) · PoncinMatthieu/rules_python@230f6d1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 230f6d1

Browse files
Marcel Hlopkobrandjon
authored andcommitted
Enable buildifier presubmit check (bazel-contrib#245)
This migrates the repo to satisfy buildifier and adds buildifier as a presubmit.
1 parent f46e953 commit 230f6d1

File tree

21 files changed

+196
-131
lines changed

21 files changed

+196
-131
lines changed

.bazelci/presubmit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# TODO(#144): When Bazel 0.29 is released, the docgen workflow will work, and
55
# we can go back to using `...` for build_targets.
66
---
7+
buildifier:
8+
version: latest
9+
warnings: "all"
710
all_targets: &all_targets
811
build_targets:
912
- "//examples/..."

BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ package(default_visibility = ["//visibility:public"])
1515

1616
licenses(["notice"]) # Apache 2.0
1717

18-
exports_files(["LICENSE", "version.bzl"])
18+
exports_files([
19+
"LICENSE",
20+
"version.bzl",
21+
])
1922

2023
filegroup(
2124
name = "distribution",

WORKSPACE

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,25 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2222

2323
http_archive(
2424
name = "bazel_federation",
25-
url = "https://github.com/bazelbuild/bazel-federation/releases/download/0.0.1/bazel_federation-0.0.1.tar.gz",
2625
sha256 = "506dfbfd74ade486ac077113f48d16835fdf6e343e1d4741552b450cfc2efb53",
26+
url = "https://github.com/bazelbuild/bazel-federation/releases/download/0.0.1/bazel_federation-0.0.1.tar.gz",
2727
)
2828

2929
load("@bazel_federation//:repositories.bzl", "rules_python_deps")
30+
3031
rules_python_deps()
3132

32-
load("@bazel_federation//setup:rules_python.bzl", "rules_python_setup")
33-
rules_python_setup(use_pip=True)
33+
load("@bazel_federation//setup:rules_python.bzl", "rules_python_setup")
34+
35+
rules_python_setup(use_pip = True)
3436

3537
# Everything below this line is used only for developing rules_python. Users
3638
# should not copy it to their WORKSPACE.
3739

3840
load("//:internal_deps.bzl", "rules_python_internal_deps")
41+
3942
rules_python_internal_deps()
4043

4144
load("//:internal_setup.bzl", "rules_python_internal_setup")
45+
4246
rules_python_internal_setup()

distro/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package(
22
default_visibility = ["//visibility:private"],
33
)
44

5-
load("@rules_python//:version.bzl", "version")
65
load("@rules_pkg//:pkg.bzl", "pkg_tar")
76
load("@rules_pkg//releasing:defs.bzl", "print_rel_notes")
7+
load("@rules_python//:version.bzl", "version")
88

99
# Build the artifact to put on the github release page.
1010
pkg_tar(

docs/BUILD

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ load("@io_bazel_skydoc//stardoc:stardoc.bzl", "stardoc")
3131
bzl_library(
3232
name = "bazel_python_tools",
3333
srcs = [
34+
"@bazel_tools//tools/python:private/defs.bzl",
3435
"@bazel_tools//tools/python:srcs_version.bzl",
3536
"@bazel_tools//tools/python:toolchain.bzl",
3637
"@bazel_tools//tools/python:utils.bzl",
37-
"@bazel_tools//tools/python:private/defs.bzl",
3838
],
3939
)
4040

@@ -49,8 +49,8 @@ bzl_library(
4949

5050
stardoc(
5151
name = "core-docs",
52-
input = "//python:defs.bzl",
5352
out = "python.md",
53+
input = "//python:defs.bzl",
5454
deps = [":defs"],
5555
)
5656

@@ -60,12 +60,12 @@ stardoc(
6060

6161
stardoc(
6262
name = "pip-docs",
63-
input = "//python:pip.bzl",
6463
out = "pip.md",
64+
input = "//python:pip.bzl",
6565
)
6666

6767
stardoc(
6868
name = "whl-docs",
69-
input = "//python:whl.bzl",
7069
out = "whl.md",
70+
input = "//python:whl.bzl",
7171
)

examples/extras/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ load("//python:defs.bzl", "py_test")
2121
py_test(
2222
name = "extras_test",
2323
srcs = ["extras_test.py"],
24+
python_version = "PY2",
2425
deps = [
2526
requirement("google-cloud-language"),
2627
# Make sure that we can resolve the "extra" dependency
2728
requirement("googleapis-common-protos[grpc]"),
2829
],
29-
python_version = "PY2",
3030
)

examples/helloworld/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ py_library(
2727
py_test(
2828
name = "helloworld_test",
2929
srcs = ["helloworld_test.py"],
30-
deps = [":helloworld"],
3130
python_version = "PY2",
31+
deps = [":helloworld"],
3232
)

experimental/examples/wheel/BUILD

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ package(default_visibility = ["//visibility:public"])
1515

1616
licenses(["notice"]) # Apache 2.0
1717

18-
load("//python:defs.bzl", "py_library", "py_test")
1918
load("//experimental/python:wheel.bzl", "py_package", "py_wheel")
19+
load("//python:defs.bzl", "py_library", "py_test")
2020

2121
py_library(
2222
name = "main",
@@ -91,54 +91,54 @@ py_wheel(
9191
# Package data. We're building "custom_package_root-0.0.1-py3-none-any.whl"
9292
distribution = "example_custom_package_root",
9393
python_tag = "py3",
94+
strip_path_prefixes = [
95+
"experimental",
96+
],
9497
version = "0.0.1",
9598
deps = [
96-
":example_pkg"
99+
":example_pkg",
97100
],
98-
strip_path_prefixes = [
99-
"experimental"
100-
]
101101
)
102102

103103
py_wheel(
104104
name = "custom_package_root_multi_prefix",
105105
# Package data. We're building "custom_custom_package_root_multi_prefix-0.0.1-py3-none-any.whl"
106106
distribution = "example_custom_package_root_multi_prefix",
107107
python_tag = "py3",
108+
strip_path_prefixes = [
109+
"experimental/examples/wheel/lib",
110+
"experimental/examples/wheel",
111+
],
108112
version = "0.0.1",
109113
deps = [
110-
":example_pkg"
114+
":example_pkg",
111115
],
112-
strip_path_prefixes = [
113-
"experimental/examples/wheel/lib",
114-
"experimental/examples/wheel"
115-
]
116116
)
117117

118118
py_wheel(
119119
name = "custom_package_root_multi_prefix_reverse_order",
120120
# Package data. We're building "custom_custom_package_root_multi_prefix_reverse_order-0.0.1-py3-none-any.whl"
121121
distribution = "example_custom_package_root_multi_prefix_reverse_order",
122122
python_tag = "py3",
123+
strip_path_prefixes = [
124+
"experimental/examples/wheel",
125+
"experimental/examples/wheel/lib", # this is not effective, because the first prefix takes priority
126+
],
123127
version = "0.0.1",
124128
deps = [
125-
":example_pkg"
129+
":example_pkg",
126130
],
127-
strip_path_prefixes = [
128-
"experimental/examples/wheel" ,
129-
"experimental/examples/wheel/lib" # this is not effective, because the first prefix takes priority
130-
]
131131
)
132132

133133
py_test(
134134
name = "wheel_test",
135135
srcs = ["wheel_test.py"],
136136
data = [
137+
":custom_package_root",
138+
":custom_package_root_multi_prefix",
139+
":custom_package_root_multi_prefix_reverse_order",
137140
":customized",
138141
":minimal_with_py_library",
139142
":minimal_with_py_package",
140-
":custom_package_root",
141-
":custom_package_root_multi_prefix",
142-
":custom_package_root_multi_prefix_reverse_order"
143-
]
143+
],
144144
)

0 commit comments

Comments
 (0)
0