| load("@npm//http-server:index.bzl", "http_server") |
| load("@npm_bazel_labs//:index.bzl", "ts_proto_library") |
| load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite") |
| load("@npm_bazel_rollup//:index.bzl", "rollup_bundle") |
| load("@npm_bazel_terser//:index.bzl", "terser_minified") |
| load("@npm_bazel_typescript//:index.bzl", "ts_config", "ts_devserver", "ts_library") |
| load("//:defaults.bzl", "karma_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", |
| ], |
| ) |
| |
| karma_web_test_suite( |
| name = "test", |
| bootstrap = ["@npm_bazel_labs//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_labs//protobufjs:bootstrap_scripts"], |
| entry_module = "examples_protocol_buffers/app", |
| deps = [":app"], |
| ) |
| |
| # Test for production mode |
| rollup_bundle( |
| name = "bundle", |
| config_file = "rollup.config.js", |
| entry_point = ":app.ts", |
| format = "iife", |
| deps = [":app"], |
| ) |
| |
| terser_minified( |
| name = "bundle.min", |
| src = ":bundle", |
| ) |
| |
| # 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.min", |
| ":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"], |
| ) |