Skip to content

Commit a479366

Browse files
devversionjelbourn
authored andcommitted
build: test remaining packages with bazel (#13844)
* Sets up Bazel build and testing for the `cdk-experimental`, `material-experimental` and `material-moment-adapter` package.
1 parent 0bd8899 commit a479366

File tree

8 files changed

+66
-57
lines changed

8 files changed

+66
-57
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ jobs:
8383
- *copy_bazel_config
8484

8585
# TODO(jelbourn): Update this command to run all tests if the Bazel issues have been fixed.
86-
- run: bazel build src/cdk/... src/lib/...
87-
- run: bazel test src/cdk/... src/lib/...
86+
- run: bazel build src/...
87+
- run: bazel test src/...
8888

8989
- *save_cache
9090

src/cdk-experimental/BUILD.bazel

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module", "ng_package")
3-
load("//:packages.bzl", "CDK_EXPERIMENTAL_PACKAGES", "CDK_EXPERIMENTAL_TARGETS", "CDK_TARGETS", "ROLLUP_GLOBALS", "VERSION_PLACEHOLDER_REPLACEMENTS")
42

5-
# Export the CDK tsconfig so that subpackages can reference it directly.
6-
exports_files(["tsconfig-build.json"])
3+
load("@angular//:index.bzl", "ng_package")
4+
load("//tools:defaults.bzl", "ng_module")
5+
load("//:packages.bzl", "CDK_EXPERIMENTAL_PACKAGES", "CDK_EXPERIMENTAL_TARGETS",
6+
"CDK_TARGETS", "ROLLUP_GLOBALS", "VERSION_PLACEHOLDER_REPLACEMENTS")
77

88
ng_module(
99
name = "cdk-experimental",
1010
srcs = glob(["*.ts"], exclude=["**/*.spec.ts"]),
1111
module_name = "@angular/cdk-experimental",
1212
deps = ["//src/cdk-experimental/%s" % p for p in CDK_EXPERIMENTAL_PACKAGES],
13-
tsconfig = "//src/lib:tsconfig-build.json",
1413
)
1514

1615
ng_package(
@@ -20,5 +19,8 @@ ng_package(
2019
globals = ROLLUP_GLOBALS,
2120
replacements = VERSION_PLACEHOLDER_REPLACEMENTS,
2221
deps = CDK_EXPERIMENTAL_TARGETS,
23-
tags = ["publish"],
22+
# TODO(devversion): Use the npm package for publishing. Right now this is disabled because
23+
# we build using AOT for serving & testing, but the `ng_package` rule should not include factory
24+
# files.
25+
tags = ["manual"],
2426
)

src/cdk-experimental/dialog/BUILD.bazel

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module")
3-
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library", "sass_binary")
42

3+
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library", "sass_binary")
4+
load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
55

66
ng_module(
77
name = "dialog",
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/cdk-experimental/dialog",
1010
assets = [":dialog-container.css"] + glob(["**/*.html"]),
1111
deps = [
12+
"@angular//packages/animations",
13+
"@angular//packages/common",
14+
"@angular//packages/core",
15+
"@rxjs",
16+
"@rxjs//operators",
1217
"//src/cdk/a11y",
1318
"//src/cdk/bidi",
1419
"//src/cdk/keycodes",
1520
"//src/cdk/overlay",
1621
"//src/cdk/portal",
1722
],
18-
tsconfig = "//src/lib:tsconfig-build.json",
1923
)
2024

2125
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
@@ -29,3 +33,24 @@ sass_binary(
2933
src = "dialog-container.scss",
3034
)
3135

36+
ng_test_library(
37+
name = "dialog_test_sources",
38+
srcs = glob(["**/*.spec.ts"]),
39+
deps = [
40+
"@angular//packages/common",
41+
"@angular//packages/common/testing",
42+
"@angular//packages/platform-browser",
43+
"@angular//packages/platform-browser/animations",
44+
"//src/cdk/bidi",
45+
"//src/cdk/keycodes",
46+
"//src/cdk/overlay",
47+
"//src/cdk/testing",
48+
":dialog",
49+
],
50+
)
51+
52+
ng_web_test_suite(
53+
name = "unit_tests",
54+
deps = [":dialog_test_sources"]
55+
)
56+

src/cdk-experimental/dialog/typings.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,30 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module")
3-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
42

3+
load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
54

65
ng_module(
76
name = "scrolling",
87
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
98
module_name = "@angular/cdk-experimental/scrolling",
109
deps = [
10+
"@angular//packages/core",
11+
"@rxjs",
1112
"//src/cdk/coercion",
1213
"//src/cdk/collections",
1314
"//src/cdk/scrolling",
14-
"@rxjs",
1515
],
16-
tsconfig = "//src/cdk-experimental:tsconfig-build.json",
1716
)
1817

19-
ts_library(
18+
ng_test_library(
2019
name = "scrolling_test_sources",
21-
testonly = 1,
2220
srcs = glob(["**/*.spec.ts"]),
2321
deps = [
24-
":scrolling",
2522
"//src/cdk/scrolling",
26-
"//src/cdk/testing",
27-
"@rxjs",
23+
":scrolling",
2824
],
29-
tsconfig = "//src/cdk-experimental:tsconfig-build.json",
3025
)
3126

32-
ts_web_test(
27+
ng_web_test_suite(
3328
name = "unit_tests",
34-
bootstrap = [
35-
"//:web_test_bootstrap_scripts",
36-
],
37-
# Do not sort
38-
deps = [
39-
"//:tslib_bundle",
40-
"//:angular_bundles",
41-
"//:angular_test_bundles",
42-
"//test:angular_test_init",
43-
":scrolling_test_sources",
44-
],
29+
deps = [":scrolling_test_sources"]
4530
)

src/material-experimental/BUILD.bazel

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@angular//:index.bzl", "ng_module", "ng_package")
3-
load("//:packages.bzl", "CDK_TARGETS", "ROLLUP_GLOBALS", "VERSION_PLACEHOLDER_REPLACEMENTS")
42

3+
load("@angular//:index.bzl", "ng_package")
4+
load("//tools:defaults.bzl", "ng_module")
5+
load("//:packages.bzl", "CDK_TARGETS", "ROLLUP_GLOBALS", "VERSION_PLACEHOLDER_REPLACEMENTS")
56

67
ng_module(
78
name = "material-experimental",
89
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
910
module_name = "@angular/material-experimental",
10-
deps = [
11-
"//src/lib:material",
12-
] + CDK_TARGETS,
13-
tsconfig = "//src/lib:tsconfig-build.json",
11+
deps = ["//src/lib:material"] + CDK_TARGETS,
1412
)
1513

1614
ng_package(
@@ -20,5 +18,6 @@ ng_package(
2018
globals = ROLLUP_GLOBALS,
2119
replacements = VERSION_PLACEHOLDER_REPLACEMENTS,
2220
deps = [":material-experimental"],
23-
tags = ["publish"],
21+
# TODO(devversion): re-enable once we have set up the proper compiler for the ng_package
22+
tags = ["manual"],
2423
)
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
package(default_visibility=["//visibility:public"])
2-
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
2+
33
load("@angular//:index.bzl", "ng_package")
4+
load("//tools:defaults.bzl", "ng_module")
45
load("//:packages.bzl", "ROLLUP_GLOBALS", "VERSION_PLACEHOLDER_REPLACEMENTS")
56

6-
7-
ts_library(
7+
ng_module(
88
name = "material-moment-adapter",
99
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
1010
module_name = "@angular/material-moment-adapter",
11-
deps = ["//src/lib:material"],
12-
tsconfig = "//src/material-moment-adapter:tsconfig-build.json",
11+
deps = [
12+
"@npm//moment",
13+
"//src/lib:material"
14+
],
15+
# Explicitly specify the tsconfig that is also used by Gulp. We need to explicitly use this
16+
# tsconfig because in order to import Moment with TypeScript, we need some special options
17+
# enabled.
18+
tsconfig = ":tsconfig-build.json",
1319
)
1420

1521
ng_package(
@@ -19,5 +25,6 @@ ng_package(
1925
globals = ROLLUP_GLOBALS,
2026
replacements = VERSION_PLACEHOLDER_REPLACEMENTS,
2127
deps = [":material-moment-adapter"],
22-
tags = ["publish"],
28+
# TODO(devversion): re-enable once we have set up the proper compiler for the ng_package
29+
tags = ["manual"],
2330
)

src/material-moment-adapter/adapter/index.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,13 @@
77
*/
88

99
import {NgModule} from '@angular/core';
10-
import {
11-
DateAdapter,
12-
MAT_DATE_LOCALE,
13-
MAT_DATE_FORMATS
14-
} from '@angular/material';
15-
import {
16-
MomentDateAdapter,
17-
MAT_MOMENT_DATE_ADAPTER_OPTIONS
18-
} from './moment-date-adapter';
10+
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material';
11+
import {MAT_MOMENT_DATE_ADAPTER_OPTIONS, MomentDateAdapter} from './moment-date-adapter';
1912
import {MAT_MOMENT_DATE_FORMATS} from './moment-date-formats';
2013

2114
export * from './moment-date-adapter';
2215
export * from './moment-date-formats';
2316

24-
2517
@NgModule({
2618
providers: [
2719
{

0 commit comments

Comments
 (0)