Skip to content

Commit 1e25872

Browse files
andyscottjohnynek
authored andcommitted
Buildifier as the only lint (#826)
* Load buildifier directly * update lint scripts * let buildifier reformat everything * Test lints in CI * remove accidental file extension * use skylib version compatible with rules_go and buildifier
1 parent 0328df3 commit 1e25872

File tree

49 files changed

+216
-487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+216
-487
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ env:
4444
# Linting is broken. Disable until fixed.
4545
# See https://github.com/bazelbuild/rules_scala/pull/622
4646
# we want to test the last release
47-
#- TEST_SCRIPT=test_lint.sh
47+
- TEST_SCRIPT=test_lint
4848
- TEST_SCRIPT=test_rules_scala
4949
#- TEST_SCRIPT=test_intellij_aspect.sh
5050
- TEST_SCRIPT=test_reproducibility

WORKSPACE

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
workspace(name = "io_bazel_rules_scala")
22

3-
43
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
54
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
65
load("//scala:scala.bzl", "scala_repositories")
76

87
scala_repositories()
98

109
load("//scala:scala_maven_import_external.bzl", "scala_maven_import_external")
11-
load("//twitter_scrooge:twitter_scrooge.bzl", "twitter_scrooge", "scrooge_scala_library")
10+
load("//twitter_scrooge:twitter_scrooge.bzl", "scrooge_scala_library", "twitter_scrooge")
1211

1312
twitter_scrooge()
1413

@@ -28,7 +27,7 @@ load("//specs2:specs2_junit.bzl", "specs2_junit_repositories")
2827

2928
specs2_junit_repositories()
3029

31-
load("//scala:scala_cross_version.bzl", "scala_mvn_artifact", "default_scala_major_version")
30+
load("//scala:scala_cross_version.bzl", "default_scala_major_version", "scala_mvn_artifact")
3231

3332
# test adding a scala jar:
3433
maven_jar(
@@ -76,8 +75,8 @@ maven_jar(
7675
scala_maven_import_external(
7776
name = "com_github_jnr_jffi_native",
7877
artifact = "com.github.jnr:jffi:jar:native:1.2.17",
79-
fetch_sources = True,
8078
artifact_sha256 = "4eb582bc99d96c8df92fc6f0f608fd123d278223982555ba16219bf8be9f75a9",
79+
fetch_sources = True,
8180
licenses = ["notice"],
8281
server_urls = [
8382
"https://repo.maven.apache.org/maven2/",
@@ -108,23 +107,21 @@ load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_unused_deps_
108107

109108
scala_register_unused_deps_toolchains()
110109

111-
112110
register_toolchains("@io_bazel_rules_scala//test/proto:scalapb_toolchain")
113111

114-
115-
load("//scala:scala_maven_import_external.bzl", "scala_maven_import_external", "java_import_external")
112+
load("//scala:scala_maven_import_external.bzl", "java_import_external", "scala_maven_import_external")
116113

117114
scala_maven_import_external(
118115
name = "com_google_guava_guava_21_0",
119116
artifact = "com.google.guava:guava:21.0",
120117
artifact_sha256 = "972139718abc8a4893fa78cba8cf7b2c903f35c97aaf44fa3031b0669948b480",
121-
srcjar_sha256 = "b186965c9af0a714632fe49b33378c9670f8f074797ab466f49a67e918e116ea",
122118
fetch_sources = True,
123119
licenses = ["notice"], # Apache 2.0
124120
server_urls = [
125121
"https://repo1.maven.org/maven2/",
126122
"https://mirror.bazel.build/repo1.maven.org/maven2",
127-
],
123+
],
124+
srcjar_sha256 = "b186965c9af0a714632fe49b33378c9670f8f074797ab466f49a67e918e116ea",
128125
)
129126

130127
# bazel's java_import_external has been altered in rules_scala to be a macro based on jvm_import_external
@@ -148,6 +145,33 @@ load("//private:format.bzl", "format_repositories")
148145

149146
format_repositories()
150147

148+
http_archive(
149+
name = "io_bazel_rules_go",
150+
sha256 = "45409e6c4f748baa9e05f8f6ab6efaa05739aa064e3ab94e5a1a09849c51806a",
151+
url = "https://github.com/bazelbuild/rules_go/releases/download/0.18.7/rules_go-0.18.7.tar.gz",
152+
)
153+
154+
http_archive(
155+
name = "com_github_bazelbuild_buildtools",
156+
sha256 = "cdaac537b56375f658179ee2f27813cac19542443f4722b6730d84e4125355e6",
157+
strip_prefix = "buildtools-f27d1753c8b3210d9e87cdc9c45bc2739ae2c2db",
158+
url = "https://github.com/bazelbuild/buildtools/archive/f27d1753c8b3210d9e87cdc9c45bc2739ae2c2db.zip",
159+
)
160+
161+
load(
162+
"@io_bazel_rules_go//go:deps.bzl",
163+
"go_register_toolchains",
164+
"go_rules_dependencies",
165+
)
166+
167+
go_rules_dependencies()
168+
169+
go_register_toolchains()
170+
171+
load("@com_github_bazelbuild_buildtools//buildifier:deps.bzl", "buildifier_dependencies")
172+
173+
buildifier_dependencies()
174+
151175
http_archive(
152176
name = "bazel_toolchains",
153177
sha256 = "5962fe677a43226c409316fcb321d668fc4b7fa97cb1f9ef45e7dc2676097b26",
@@ -158,6 +182,10 @@ http_archive(
158182
],
159183
)
160184

185+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
186+
187+
bazel_skylib_workspace()
188+
161189
load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
162190

163191
# Creates toolchain configuration for remote execution with BuildKite CI
@@ -166,13 +194,8 @@ rbe_autoconfig(
166194
name = "buildkite_config",
167195
)
168196

169-
git_repository(
170-
name = "bazel_skylib",
171-
remote = "https://github.com/bazelbuild/bazel-skylib.git",
172-
tag = "0.6.0",
173-
)
174-
175197
## deps for tests of limited deps support
198+
176199
scala_maven_import_external(
177200
name = "org_springframework_spring_core",
178201
artifact = "org.springframework:spring-core:5.1.5.RELEASE",
@@ -181,7 +204,7 @@ scala_maven_import_external(
181204
server_urls = [
182205
"https://repo1.maven.org/maven2/",
183206
"https://mirror.bazel.build/repo1.maven.org/maven2",
184-
],
207+
],
185208
)
186209

187210
scala_maven_import_external(
@@ -192,10 +215,10 @@ scala_maven_import_external(
192215
server_urls = [
193216
"https://repo1.maven.org/maven2/",
194217
"https://mirror.bazel.build/repo1.maven.org/maven2",
195-
],
218+
],
196219
deps = [
197-
"@org_springframework_spring_core"
198-
]
220+
"@org_springframework_spring_core",
221+
],
199222
)
200223

201224
## deps for tests of compiler plugin

jmh/jmh.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,15 @@ def jmh_repositories(maven_servers = ["http://central.maven.org/maven2"]):
7878
def _scala_generate_benchmark(ctx):
7979
# we use required providers to ensure JavaInfo exists
8080
info = ctx.attr.src[JavaInfo]
81+
8182
# TODO, if we emit more than one jar, which scala_library does not,
8283
# this might fail. We could possibly extend the BenchmarkGenerator
8384
# to accept more than one jar to scan, and then allow multiple labels
8485
# in ctx.attr.src
8586
outs = info.outputs.jars
8687
if len(outs) != 1:
8788
print("expected exactly 1 output jar in: " + ctx.label)
89+
8890
# just try to take the first one and see if that works
8991
class_jar = outs[0].class_jar
9092
classpath = info.transitive_runtime_deps

0 commit comments

Comments
 (0)