blob: cdb55889e3824eec5d5683a1f844d52429510a90 [file]
load("@build_bazel_rules_nodejs//:defs.bzl", "http_server", "rollup_bundle")
load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite")
load("@npm_bazel_typescript//:index.bzl", "ts_config", "ts_devserver", "ts_library", "ts_proto_library")
load("//:defaults.bzl", "ts_web_test_suite")
proto_library(
name = "tire_proto",
srcs = ["tire.proto"],
)
proto_library(
name = "car_proto",
srcs = ["car.proto"],
deps = [":tire_proto"],
)
ts_proto_library(
# The result will be "car.d.ts" named after this target.
# We could use the output_name attribute if we want the output named
# differently than the target.
name = "car",
deps = [":car_proto"],
)
ts_config(
name = "tsconfig-test",
src = "tsconfig-test.json",
deps = [":tsconfig.json"],
)
ts_library(
name = "test_lib",
testonly = True,
srcs = ["car.spec.ts"],
tsconfig = "//:tsconfig-test",
deps = [
":car",
"@npm//@types/jasmine",
"@npm//@types/long",
"@npm//@types/node",
"@npm//long",
],
)
ts_web_test_suite(
name = "test",
bootstrap = ["@npm_bazel_typescript//:protobufjs_bootstrap_scripts"],
browsers = [
"@io_bazel_rules_webtesting//browsers:chromium-local",
"@io_bazel_rules_webtesting//browsers:firefox-local",
],
tags = ["native"],
deps = ["test_lib"],
)
ts_library(
name = "app",
srcs = ["app.ts"],
deps = [":car"],
)
ts_devserver(
name = "devserver",
bootstrap = ["@npm_bazel_typescript//:protobufjs_bootstrap_scripts"],
entry_module = "examples_protocol_buffers/app",
deps = [":bundle"],
)
# Test for production mode
rollup_bundle(
name = "bundle",
enable_code_splitting = False,
entry_point = ":app.ts",
# TODO(alexeagle): we should be able to get this from //:protobufjs_bootstrap_scripts
# and automatically plumb it through to Rollup.
globals = {
"long": "Long",
"protobufjs/minimal": "protobuf",
},
deps = [":app"],
)
# Needed because the prodserver only loads static files that appear under this
# package.
genrule(
name = "protobufjs",
srcs = [
"@build_bazel_rules_typescript_protobufs_compiletime_deps//:node_modules/protobufjs/dist/minimal/protobuf.min.js",
"@build_bazel_rules_typescript_protobufs_compiletime_deps//:node_modules/long/dist/long.js",
],
outs = [
"protobuf.min.js",
"long.js",
],
cmd = "outs=($(OUTS)); d=$$(dirname $${outs[0]}); for s in $(SRCS); do cp $$s $$d; done",
)
http_server(
name = "prodserver",
data = [
"index.html",
":bundle",
":protobufjs",
],
)
ts_library(
name = "e2e",
testonly = 1,
srcs = ["app.e2e-spec.ts"],
tsconfig = ":tsconfig-test",
deps = [
"@npm//@types/jasmine",
"@npm//jasmine",
"@npm//protractor",
],
)
proto_library(
name = "rules_typescript_proto",
srcs = [
"car.proto",
"tire.proto",
],
visibility = ["//visibility:public"],
)
# BazelCI docker images are missing shares libs to run a subset browser tests:
# mac: firefox does not work, chrome works
# ubuntu: firefox and chrome do not work --- there are 0 tests to run
# windows: firefox works, chrome does not work
# TODO(gregmagolan): support firefox in protractor rule
protractor_web_test_suite(
name = "prodserver_test",
on_prepare = ":protractor.on-prepare.js",
server = "//:prodserver",
tags = [
"no-bazelci-ubuntu",
"no-bazelci-windows",
],
deps = [":e2e"],
)
# BazelCI docker images are missing shares libs to run a subset browser tests:
# mac: firefox does not work, chrome works
# ubuntu: firefox and chrome do not work --- there are 0 tests to run
# windows: firefox works, chrome does not work
# TODO(gregmagolan): support firefox in protractor rule
protractor_web_test_suite(
name = "devserver_test",
on_prepare = ":protractor.on-prepare.js",
server = "//:devserver",
tags = [
"no-bazelci-ubuntu",
"no-bazelci-windows",
],
deps = [":e2e"],
)
# Just a dummy test so that we have a test target for //... on certain bazelci platforms with bazel_integration_test
sh_test(
name = "dummy_test",
srcs = ["dummy_test.sh"],
)
# For testing from the root workspace of this repository with bazel_integration_test.
filegroup(
name = "all_files",
srcs = glob(
include = ["**/*"],
exclude = [
"bazel-out/**/*",
"dist/**/*",
"node_modules/**/*",
],
),
visibility = ["//visibility:public"],
)