Skip to content

Commit

Permalink
Fix toolchain registration call for ScalaTest (#1130)
Browse files Browse the repository at this point in the history
* Fix toolchain registration call for ScalaTest

* Use external name in toolchain registration

* Add example/integration test for ScalaTest repositories

* Use the same skylib version and download it from google mirror

* Update rules_go to support 1.0.3 skylib
  • Loading branch information
Vaidas Pilkauskas authored Oct 30, 2020
1 parent f9fbf4e commit 09d6c74
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 7 deletions.
16 changes: 14 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external")

skylib_version = "1.0.3"

http_archive(
name = "bazel_skylib",
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
type = "tar.gz",
url = "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version),
)

_build_tools_release = "3.3.0"

http_archive(
Expand Down Expand Up @@ -119,8 +128,11 @@ 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",
sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
],
)

load(
Expand Down
Empty file.
35 changes: 35 additions & 0 deletions examples/testing/scalatest_repositories/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
workspace(name = "scalatest_repositories")

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

skylib_version = "1.0.3"

http_archive(
name = "bazel_skylib",
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
type = "tar.gz",
url = "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version),
)

local_repository(
name = "io_bazel_rules_scala",
path = "../../..",
)

load("@io_bazel_rules_scala//:version.bzl", "bazel_version")

bazel_version(name = "bazel_version")

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")

scala_repositories()

load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")

scala_register_toolchains()

load("@io_bazel_rules_scala//testing:scalatest.bzl", "scalatest_repositories", "scalatest_toolchain")

scalatest_repositories()

scalatest_toolchain()
6 changes: 6 additions & 0 deletions examples/testing/scalatest_repositories/example/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_test")

scala_test(
name = "example",
srcs = ["ExampleTest.scala"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package examples.testing.scalatest_repositories.example

import org.scalatest.{FlatSpec, MustMatchers}

class ExampleTest extends FlatSpec with MustMatchers {
"Exmaple" should "pass" in {
1 must be(1)
}
}
11 changes: 11 additions & 0 deletions test/shell/test_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# shellcheck source=./test_runner.sh
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
. "${dir}"/test_runner.sh
. "${dir}"/test_helper.sh
runner=$(get_test_runner "${1:-local}")

function scalatest_repositories_example() {
(cd examples/testing/scalatest_repositories; bazel test //...)
}

$runner scalatest_repositories_example
1 change: 1 addition & 0 deletions test_rules_scala.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ $runner bazel test //test/... --extra_toolchains="//test_expect_failure/plus_one
. "${test_dir}"/test_toolchain.sh
. "${test_dir}"/test_unused_dependency.sh
. "${test_dir}"/test_twitter_scrooge.sh
. "${test_dir}"/test_examples.sh
8 changes: 4 additions & 4 deletions test_version/WORKSPACE.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ workspace(name = "io_bazel_rules_scala_test")

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

# bazel-skylib 0.8.0 released 2019.03.20 (https://github.com/bazelbuild/bazel-skylib/releases/tag/0.8.0)
skylib_version = "0.8.0"
skylib_version = "1.0.3"

http_archive(
name = "bazel_skylib",
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
type = "tar.gz",
url = "https://github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib.{}.tar.gz".format (skylib_version, skylib_version),
sha256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e",
url = "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version),
)

local_repository(
Expand Down
2 changes: 1 addition & 1 deletion testing/scalatest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ def scalatest_repositories():
pass

def scalatest_toolchain():
native.register_toolchain("//testing:scalatest_toolchain")
native.register_toolchains("@io_bazel_rules_scala//testing:scalatest_toolchain")

0 comments on commit 09d6c74

Please sign in to comment.