Skip to content

Commit

Permalink
Buildifier as the only lint (#826)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
andyscott authored and johnynek committed Aug 21, 2019
1 parent 0328df3 commit 1e25872
Show file tree
Hide file tree
Showing 49 changed files with 216 additions and 487 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ env:
# Linting is broken. Disable until fixed.
# See https://github.com/bazelbuild/rules_scala/pull/622
# we want to test the last release
#- TEST_SCRIPT=test_lint.sh
- TEST_SCRIPT=test_lint
- TEST_SCRIPT=test_rules_scala
#- TEST_SCRIPT=test_intellij_aspect.sh
- TEST_SCRIPT=test_reproducibility
Expand Down
61 changes: 42 additions & 19 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
workspace(name = "io_bazel_rules_scala")


load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("//scala:scala.bzl", "scala_repositories")

scala_repositories()

load("//scala:scala_maven_import_external.bzl", "scala_maven_import_external")
load("//twitter_scrooge:twitter_scrooge.bzl", "twitter_scrooge", "scrooge_scala_library")
load("//twitter_scrooge:twitter_scrooge.bzl", "scrooge_scala_library", "twitter_scrooge")

twitter_scrooge()

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

specs2_junit_repositories()

load("//scala:scala_cross_version.bzl", "scala_mvn_artifact", "default_scala_major_version")
load("//scala:scala_cross_version.bzl", "default_scala_major_version", "scala_mvn_artifact")

# test adding a scala jar:
maven_jar(
Expand Down Expand Up @@ -76,8 +75,8 @@ maven_jar(
scala_maven_import_external(
name = "com_github_jnr_jffi_native",
artifact = "com.github.jnr:jffi:jar:native:1.2.17",
fetch_sources = True,
artifact_sha256 = "4eb582bc99d96c8df92fc6f0f608fd123d278223982555ba16219bf8be9f75a9",
fetch_sources = True,
licenses = ["notice"],
server_urls = [
"https://repo.maven.apache.org/maven2/",
Expand Down Expand Up @@ -108,23 +107,21 @@ load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_unused_deps_

scala_register_unused_deps_toolchains()


register_toolchains("@io_bazel_rules_scala//test/proto:scalapb_toolchain")


load("//scala:scala_maven_import_external.bzl", "scala_maven_import_external", "java_import_external")
load("//scala:scala_maven_import_external.bzl", "java_import_external", "scala_maven_import_external")

scala_maven_import_external(
name = "com_google_guava_guava_21_0",
artifact = "com.google.guava:guava:21.0",
artifact_sha256 = "972139718abc8a4893fa78cba8cf7b2c903f35c97aaf44fa3031b0669948b480",
srcjar_sha256 = "b186965c9af0a714632fe49b33378c9670f8f074797ab466f49a67e918e116ea",
fetch_sources = True,
licenses = ["notice"], # Apache 2.0
server_urls = [
"https://repo1.maven.org/maven2/",
"https://mirror.bazel.build/repo1.maven.org/maven2",
],
],
srcjar_sha256 = "b186965c9af0a714632fe49b33378c9670f8f074797ab466f49a67e918e116ea",
)

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

format_repositories()

http_archive(
name = "io_bazel_rules_go",
sha256 = "45409e6c4f748baa9e05f8f6ab6efaa05739aa064e3ab94e5a1a09849c51806a",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.18.7/rules_go-0.18.7.tar.gz",
)

http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "cdaac537b56375f658179ee2f27813cac19542443f4722b6730d84e4125355e6",
strip_prefix = "buildtools-f27d1753c8b3210d9e87cdc9c45bc2739ae2c2db",
url = "https://github.com/bazelbuild/buildtools/archive/f27d1753c8b3210d9e87cdc9c45bc2739ae2c2db.zip",
)

load(
"@io_bazel_rules_go//go:deps.bzl",
"go_register_toolchains",
"go_rules_dependencies",
)

go_rules_dependencies()

go_register_toolchains()

load("@com_github_bazelbuild_buildtools//buildifier:deps.bzl", "buildifier_dependencies")

buildifier_dependencies()

http_archive(
name = "bazel_toolchains",
sha256 = "5962fe677a43226c409316fcb321d668fc4b7fa97cb1f9ef45e7dc2676097b26",
Expand All @@ -158,6 +182,10 @@ http_archive(
],
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")

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

git_repository(
name = "bazel_skylib",
remote = "https://github.com/bazelbuild/bazel-skylib.git",
tag = "0.6.0",
)

## deps for tests of limited deps support

scala_maven_import_external(
name = "org_springframework_spring_core",
artifact = "org.springframework:spring-core:5.1.5.RELEASE",
Expand All @@ -181,7 +204,7 @@ scala_maven_import_external(
server_urls = [
"https://repo1.maven.org/maven2/",
"https://mirror.bazel.build/repo1.maven.org/maven2",
],
],
)

scala_maven_import_external(
Expand All @@ -192,10 +215,10 @@ scala_maven_import_external(
server_urls = [
"https://repo1.maven.org/maven2/",
"https://mirror.bazel.build/repo1.maven.org/maven2",
],
],
deps = [
"@org_springframework_spring_core"
]
"@org_springframework_spring_core",
],
)

## deps for tests of compiler plugin
Expand Down
2 changes: 2 additions & 0 deletions jmh/jmh.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ def jmh_repositories(maven_servers = ["http://central.maven.org/maven2"]):
def _scala_generate_benchmark(ctx):
# we use required providers to ensure JavaInfo exists
info = ctx.attr.src[JavaInfo]

# TODO, if we emit more than one jar, which scala_library does not,
# this might fail. We could possibly extend the BenchmarkGenerator
# to accept more than one jar to scan, and then allow multiple labels
# in ctx.attr.src
outs = info.outputs.jars
if len(outs) != 1:
print("expected exactly 1 output jar in: " + ctx.label)

# just try to take the first one and see if that works
class_jar = outs[0].class_jar
classpath = info.transitive_runtime_deps
Expand Down
Loading

0 comments on commit 1e25872

Please sign in to comment.