build(bazel): fix bazel integration test after rules_typescript update (#25490)
PR Close #25490
This commit is contained in:
		
							parent
							
								
									22e7f7e99f
								
							
						
					
					
						commit
						a59d4da304
					
				| @ -4,41 +4,33 @@ exports_files([ | ||||
|     "protractor.conf.js", | ||||
| ]) | ||||
| 
 | ||||
| # ts_library and ng_module use the `//:tsconfig.json` target | ||||
| # by default. This alias allows omitting explicit tsconfig | ||||
| # attribute. | ||||
| alias( | ||||
|     name = "tsconfig.json", | ||||
|     actual = "//src:tsconfig.json", | ||||
| ) | ||||
| 
 | ||||
| filegroup( | ||||
|     name = "node_modules", | ||||
|     srcs = glob( | ||||
|         ["node_modules/**/*"], | ||||
|         [ | ||||
|             # Include only .js, .json & .d.ts files to reduce the number of | ||||
|             # files in the //:node_modules filegroup | ||||
|             "node_modules/**/*.js", | ||||
|             "node_modules/**/*.json", | ||||
|             "node_modules/**/*.d.ts", | ||||
|             # All the files in the http-server package are necesssary | ||||
|             "node_modules/http-server/**", | ||||
|             # All the files in the protractor package are necesssary | ||||
|             "node_modules/protractor/**", | ||||
|             # Also include all files in node_modules/.bin | ||||
|             "node_modules/.bin/*", | ||||
|         ], | ||||
|         exclude = [ | ||||
|             # Exclude rxjs because we build it from sources using the label @rxjs//:rxjs | ||||
|             "node_modules/rxjs/**", | ||||
| 
 | ||||
|             # Exclude directories that commonly contain filenames which are | ||||
|             # illegal bazel labels | ||||
|             # e.g. node_modules/adm-zip/test/assets/attributes_test/New folder/hidden.txt | ||||
|             "node_modules/**/test/**", | ||||
|             # e.g. node_modules/xpath/docs/function resolvers.md | ||||
|             "node_modules/**/docs/**", | ||||
|             # Exclude files with spaces which are illegal bazel labels | ||||
|             "node_modules/**/* *", | ||||
|         ], | ||||
|     ), | ||||
| ) | ||||
| 
 | ||||
| ANGULAR_TESTING = [ | ||||
|     "node_modules/@angular/*/bundles/*-testing.umd.js", | ||||
|     # We use AOT, so the dynamic platform-browser should be visible only in tests | ||||
|     # NOTE that we still need to include the compiler because the core depends on it | ||||
|     "node_modules/@angular/platform-browser-dynamic/bundles/*.umd.js", | ||||
| ] | ||||
| 
 | ||||
| filegroup( | ||||
|     name = "angular_bundles", | ||||
|     srcs = glob( | ||||
|         ["node_modules/@angular/*/bundles/*.umd.js"], | ||||
|         exclude = ANGULAR_TESTING, | ||||
|     ), | ||||
| ) | ||||
| 
 | ||||
| filegroup( | ||||
|     name = "angular_test_bundles", | ||||
|     testonly = 1, | ||||
|     srcs = glob(ANGULAR_TESTING), | ||||
| ) | ||||
|  | ||||
| @ -4,11 +4,9 @@ workspace(name = "bazel_integration_test") | ||||
| # Download Bazel toolchain dependencies as needed by build actions | ||||
| # | ||||
| 
 | ||||
| http_archive( | ||||
| local_repository( | ||||
|     name = "build_bazel_rules_typescript", | ||||
|     url = "https://github.com/bazelbuild/rules_typescript/archive/0.16.1.zip", | ||||
|     strip_prefix = "rules_typescript-0.16.1", | ||||
|     sha256 = "5b2b0bc63cfcffe7bf97cad2dad3b26a73362f806de66207051f66c87956a995", | ||||
|     path = "node_modules/@bazel/typescript", | ||||
| ) | ||||
| load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies") | ||||
| rules_typescript_dependencies() | ||||
| @ -26,7 +24,7 @@ http_archive( | ||||
| 
 | ||||
| local_repository( | ||||
|     name = "angular", | ||||
|     path = "node_modules/@angular/bazel", | ||||
|     path = "../..", | ||||
| ) | ||||
| 
 | ||||
| local_repository( | ||||
|  | ||||
| @ -4,27 +4,21 @@ | ||||
|   "version": "0.0.0", | ||||
|   "license": "MIT", | ||||
|   "dependencies": { | ||||
|     "@angular/animations": "file:../../dist/packages-dist/animations", | ||||
|     "@angular/common": "file:../../dist/packages-dist/common", | ||||
|     "@angular/compiler": "file:../../dist/packages-dist/compiler", | ||||
|     "@angular/core": "file:../../dist/packages-dist/core", | ||||
|     "@angular/platform-browser": "file:../../dist/packages-dist/platform-browser", | ||||
|     "@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic", | ||||
|     "reflect-metadata": "file:../../node_modules/reflect-metadata", | ||||
|     "rxjs": "file:../../node_modules/rxjs", | ||||
|     "tslib": "file:../../node_modules/tslib", | ||||
|     "zone.js": "file:../../node_modules/zone.js" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@angular/bazel": "file:../../dist/packages-dist/bazel", | ||||
|     "@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli", | ||||
|     "@types/jasmine": "2.8.7", | ||||
|     "@bazel/typescript": "0.16.1", | ||||
|     "@types/jasmine": "file:../../node_modules/@types/jasmine", | ||||
|     "@types/source-map": "0.5.1", | ||||
|     "http-server": "0.11.1", | ||||
|     "protractor": "file:../../node_modules/protractor", | ||||
|     "tsutils": "file:../../node_modules/tsutils", | ||||
|     "tsickle": "file:../../node_modules/tsickle", | ||||
|     "typescript": "file:../../node_modules/typescript" | ||||
|   }, | ||||
|   "scripts": { | ||||
|     "postinstall": "ngc -p angular.tsconfig.json", | ||||
|     "test": "bazel build ... --noshow_progress && bazel test ..." | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -8,8 +8,12 @@ exports_files(["tsconfig.json"]) | ||||
| ng_module( | ||||
|     name = "src", | ||||
|     srcs = glob(["*.ts"]), | ||||
|     tsconfig = ":tsconfig.json", | ||||
|     deps = ["//src/hello-world"], | ||||
|     deps = [ | ||||
|         "//src/hello-world", | ||||
|         "@angular//packages/common/http", | ||||
|         "@angular//packages/core", | ||||
|         "@angular//packages/platform-browser", | ||||
|     ], | ||||
| ) | ||||
| 
 | ||||
| load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver") | ||||
| @ -17,12 +21,13 @@ load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver") | ||||
| ts_devserver( | ||||
|     name = "devserver", | ||||
|     additional_root_paths = [ | ||||
|         "bazel_integration_test/node_modules/tslib", | ||||
|         "bazel_integration_test/node_modules/zone.js/dist", | ||||
|     ], | ||||
|     entry_module = "bazel_integration_test/src/main", | ||||
|     scripts = ["//:angular_bundles"], | ||||
|     serving_path = "/bundle.min.js", | ||||
|     static_files = [ | ||||
|         "//:node_modules/tslib/tslib.js", | ||||
|         "//:node_modules/zone.js/dist/zone.min.js", | ||||
|         "index.html", | ||||
|     ], | ||||
|  | ||||
| @ -16,10 +16,9 @@ ng_module( | ||||
|         exclude = ["*.spec.ts"], | ||||
|     ), | ||||
|     assets = [":hello-world-styles"], | ||||
|     tsconfig = "//src:tsconfig.json", | ||||
|     # FIXME(alexeagle): the rxjs dep should come from Angular, but if we use the | ||||
|     # npm distro of angular there is no ts_library rule to propagate the dep. | ||||
|     deps = ["@rxjs"], | ||||
|     deps = [ | ||||
|         "@angular//packages/core", | ||||
|     ], | ||||
| ) | ||||
| 
 | ||||
| ng_package( | ||||
| @ -32,20 +31,27 @@ ts_library( | ||||
|     name = "test_lib", | ||||
|     testonly = 1, | ||||
|     srcs = glob(["*.spec.ts"]), | ||||
|     tsconfig = "//src:tsconfig.json", | ||||
|     deps = [":hello-world"], | ||||
|     deps = [ | ||||
|         ":hello-world", | ||||
|         "@angular//packages/core", | ||||
|         "@angular//packages/core/testing", | ||||
|         "@angular//packages/platform-browser", | ||||
|         "@angular//packages/platform-browser-dynamic/testing", | ||||
|     ], | ||||
| ) | ||||
| 
 | ||||
| ts_web_test_suite( | ||||
|     name = "test", | ||||
|     bootstrap = ["//:node_modules/zone.js/dist/zone-testing-bundle.js"], | ||||
|     srcs = ["//:node_modules/tslib/tslib.js"], | ||||
|     bootstrap = [ | ||||
|         "//:node_modules/zone.js/dist/zone-testing-bundle.js", | ||||
|         "//:node_modules/reflect-metadata/Reflect.js", | ||||
|     ], | ||||
|     browsers = [ | ||||
|         "@io_bazel_rules_webtesting//browsers:chromium-local", | ||||
|         "@io_bazel_rules_webtesting//browsers:firefox-local", | ||||
|     ], | ||||
|     deps = [ | ||||
|         ":test_lib", | ||||
|         "//:angular_bundles", | ||||
|         "//:angular_test_bundles", | ||||
|     ], | ||||
| ) | ||||
|  | ||||
| @ -13,13 +13,13 @@ ts_library( | ||||
|     testonly = 1, | ||||
|     srcs = ["on-prepare.ts"], | ||||
|     tsconfig = ":tsconfig.json", | ||||
|     deps = ["@angular//src/protractor/utils"], | ||||
|     deps = ["@angular//packages/bazel/src/protractor/utils"], | ||||
| ) | ||||
| 
 | ||||
| protractor_web_test_suite( | ||||
|     name = "devserver_test", | ||||
|     configuration = "//:protractor.conf.js", | ||||
|     data = ["@angular//src/protractor/utils"], | ||||
|     data = ["@angular//packages/bazel/src/protractor/utils"], | ||||
|     on_prepare = ":ts_on_prepare", | ||||
|     server = "//src:devserver", | ||||
|     deps = [":e2e"], | ||||
| @ -28,7 +28,7 @@ protractor_web_test_suite( | ||||
| protractor_web_test_suite( | ||||
|     name = "prodserver_test", | ||||
|     configuration = "//:protractor.conf.js", | ||||
|     data = ["@angular//src/protractor/utils"], | ||||
|     data = ["@angular//packages/bazel/src/protractor/utils"], | ||||
|     on_prepare = ":ts_on_prepare", | ||||
|     server = "//src:prodserver", | ||||
|     deps = [":e2e"], | ||||
|  | ||||
| @ -8,3 +8,6 @@ test --test_output=errors | ||||
| # Workaround https://github.com/bazelbuild/bazel/issues/3645 | ||||
| # Limit Bazel to consuming 3072K of RAM | ||||
| build --local_resources=3072,2.0,1.0 | ||||
| 
 | ||||
| # Use the Angular 6 compiler | ||||
| build --define=compile=legacy | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user