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", |     "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( | filegroup( | ||||||
|     name = "node_modules", |     name = "node_modules", | ||||||
|     srcs = glob( |     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 = [ | ||||||
|             # Exclude rxjs because we build it from sources using the label @rxjs//:rxjs |             # Exclude files with spaces which are illegal bazel labels | ||||||
|             "node_modules/rxjs/**", |             "node_modules/**/* *", | ||||||
| 
 |  | ||||||
|             # 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/**", |  | ||||||
|         ], |         ], | ||||||
|     ), |     ), | ||||||
| ) | ) | ||||||
| 
 |  | ||||||
| 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 | # Download Bazel toolchain dependencies as needed by build actions | ||||||
| # | # | ||||||
| 
 | 
 | ||||||
| http_archive( | local_repository( | ||||||
|     name = "build_bazel_rules_typescript", |     name = "build_bazel_rules_typescript", | ||||||
|     url = "https://github.com/bazelbuild/rules_typescript/archive/0.16.1.zip", |     path = "node_modules/@bazel/typescript", | ||||||
|     strip_prefix = "rules_typescript-0.16.1", |  | ||||||
|     sha256 = "5b2b0bc63cfcffe7bf97cad2dad3b26a73362f806de66207051f66c87956a995", |  | ||||||
| ) | ) | ||||||
| load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies") | load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies") | ||||||
| rules_typescript_dependencies() | rules_typescript_dependencies() | ||||||
| @ -26,7 +24,7 @@ http_archive( | |||||||
| 
 | 
 | ||||||
| local_repository( | local_repository( | ||||||
|     name = "angular", |     name = "angular", | ||||||
|     path = "node_modules/@angular/bazel", |     path = "../..", | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| local_repository( | local_repository( | ||||||
|  | |||||||
| @ -4,27 +4,21 @@ | |||||||
|   "version": "0.0.0", |   "version": "0.0.0", | ||||||
|   "license": "MIT", |   "license": "MIT", | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@angular/animations": "file:../../dist/packages-dist/animations", |     "reflect-metadata": "file:../../node_modules/reflect-metadata", | ||||||
|     "@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", |  | ||||||
|     "rxjs": "file:../../node_modules/rxjs", |     "rxjs": "file:../../node_modules/rxjs", | ||||||
|  |     "tslib": "file:../../node_modules/tslib", | ||||||
|     "zone.js": "file:../../node_modules/zone.js" |     "zone.js": "file:../../node_modules/zone.js" | ||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "@angular/bazel": "file:../../dist/packages-dist/bazel", |     "@bazel/typescript": "0.16.1", | ||||||
|     "@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli", |     "@types/jasmine": "file:../../node_modules/@types/jasmine", | ||||||
|     "@types/jasmine": "2.8.7", |  | ||||||
|     "@types/source-map": "0.5.1", |     "@types/source-map": "0.5.1", | ||||||
|     "http-server": "0.11.1", |     "http-server": "0.11.1", | ||||||
|     "protractor": "file:../../node_modules/protractor", |     "protractor": "file:../../node_modules/protractor", | ||||||
|     "tsutils": "file:../../node_modules/tsutils", |     "tsickle": "file:../../node_modules/tsickle", | ||||||
|     "typescript": "file:../../node_modules/typescript" |     "typescript": "file:../../node_modules/typescript" | ||||||
|   }, |   }, | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "postinstall": "ngc -p angular.tsconfig.json", |  | ||||||
|     "test": "bazel build ... --noshow_progress && bazel test ..." |     "test": "bazel build ... --noshow_progress && bazel test ..." | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,8 +8,12 @@ exports_files(["tsconfig.json"]) | |||||||
| ng_module( | ng_module( | ||||||
|     name = "src", |     name = "src", | ||||||
|     srcs = glob(["*.ts"]), |     srcs = glob(["*.ts"]), | ||||||
|     tsconfig = ":tsconfig.json", |     deps = [ | ||||||
|     deps = ["//src/hello-world"], |         "//src/hello-world", | ||||||
|  |         "@angular//packages/common/http", | ||||||
|  |         "@angular//packages/core", | ||||||
|  |         "@angular//packages/platform-browser", | ||||||
|  |     ], | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver") | load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver") | ||||||
| @ -17,12 +21,13 @@ load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver") | |||||||
| ts_devserver( | ts_devserver( | ||||||
|     name = "devserver", |     name = "devserver", | ||||||
|     additional_root_paths = [ |     additional_root_paths = [ | ||||||
|  |         "bazel_integration_test/node_modules/tslib", | ||||||
|         "bazel_integration_test/node_modules/zone.js/dist", |         "bazel_integration_test/node_modules/zone.js/dist", | ||||||
|     ], |     ], | ||||||
|     entry_module = "bazel_integration_test/src/main", |     entry_module = "bazel_integration_test/src/main", | ||||||
|     scripts = ["//:angular_bundles"], |  | ||||||
|     serving_path = "/bundle.min.js", |     serving_path = "/bundle.min.js", | ||||||
|     static_files = [ |     static_files = [ | ||||||
|  |         "//:node_modules/tslib/tslib.js", | ||||||
|         "//:node_modules/zone.js/dist/zone.min.js", |         "//:node_modules/zone.js/dist/zone.min.js", | ||||||
|         "index.html", |         "index.html", | ||||||
|     ], |     ], | ||||||
|  | |||||||
| @ -16,10 +16,9 @@ ng_module( | |||||||
|         exclude = ["*.spec.ts"], |         exclude = ["*.spec.ts"], | ||||||
|     ), |     ), | ||||||
|     assets = [":hello-world-styles"], |     assets = [":hello-world-styles"], | ||||||
|     tsconfig = "//src:tsconfig.json", |     deps = [ | ||||||
|     # FIXME(alexeagle): the rxjs dep should come from Angular, but if we use the |         "@angular//packages/core", | ||||||
|     # npm distro of angular there is no ts_library rule to propagate the dep. |     ], | ||||||
|     deps = ["@rxjs"], |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| ng_package( | ng_package( | ||||||
| @ -32,20 +31,27 @@ ts_library( | |||||||
|     name = "test_lib", |     name = "test_lib", | ||||||
|     testonly = 1, |     testonly = 1, | ||||||
|     srcs = glob(["*.spec.ts"]), |     srcs = glob(["*.spec.ts"]), | ||||||
|     tsconfig = "//src:tsconfig.json", |     deps = [ | ||||||
|     deps = [":hello-world"], |         ":hello-world", | ||||||
|  |         "@angular//packages/core", | ||||||
|  |         "@angular//packages/core/testing", | ||||||
|  |         "@angular//packages/platform-browser", | ||||||
|  |         "@angular//packages/platform-browser-dynamic/testing", | ||||||
|  |     ], | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| ts_web_test_suite( | ts_web_test_suite( | ||||||
|     name = "test", |     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 = [ |     browsers = [ | ||||||
|         "@io_bazel_rules_webtesting//browsers:chromium-local", |         "@io_bazel_rules_webtesting//browsers:chromium-local", | ||||||
|         "@io_bazel_rules_webtesting//browsers:firefox-local", |         "@io_bazel_rules_webtesting//browsers:firefox-local", | ||||||
|     ], |     ], | ||||||
|     deps = [ |     deps = [ | ||||||
|         ":test_lib", |         ":test_lib", | ||||||
|         "//:angular_bundles", |  | ||||||
|         "//:angular_test_bundles", |  | ||||||
|     ], |     ], | ||||||
| ) | ) | ||||||
|  | |||||||
| @ -13,13 +13,13 @@ ts_library( | |||||||
|     testonly = 1, |     testonly = 1, | ||||||
|     srcs = ["on-prepare.ts"], |     srcs = ["on-prepare.ts"], | ||||||
|     tsconfig = ":tsconfig.json", |     tsconfig = ":tsconfig.json", | ||||||
|     deps = ["@angular//src/protractor/utils"], |     deps = ["@angular//packages/bazel/src/protractor/utils"], | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| protractor_web_test_suite( | protractor_web_test_suite( | ||||||
|     name = "devserver_test", |     name = "devserver_test", | ||||||
|     configuration = "//:protractor.conf.js", |     configuration = "//:protractor.conf.js", | ||||||
|     data = ["@angular//src/protractor/utils"], |     data = ["@angular//packages/bazel/src/protractor/utils"], | ||||||
|     on_prepare = ":ts_on_prepare", |     on_prepare = ":ts_on_prepare", | ||||||
|     server = "//src:devserver", |     server = "//src:devserver", | ||||||
|     deps = [":e2e"], |     deps = [":e2e"], | ||||||
| @ -28,7 +28,7 @@ protractor_web_test_suite( | |||||||
| protractor_web_test_suite( | protractor_web_test_suite( | ||||||
|     name = "prodserver_test", |     name = "prodserver_test", | ||||||
|     configuration = "//:protractor.conf.js", |     configuration = "//:protractor.conf.js", | ||||||
|     data = ["@angular//src/protractor/utils"], |     data = ["@angular//packages/bazel/src/protractor/utils"], | ||||||
|     on_prepare = ":ts_on_prepare", |     on_prepare = ":ts_on_prepare", | ||||||
|     server = "//src:prodserver", |     server = "//src:prodserver", | ||||||
|     deps = [":e2e"], |     deps = [":e2e"], | ||||||
|  | |||||||
| @ -8,3 +8,6 @@ test --test_output=errors | |||||||
| # Workaround https://github.com/bazelbuild/bazel/issues/3645 | # Workaround https://github.com/bazelbuild/bazel/issues/3645 | ||||||
| # Limit Bazel to consuming 3072K of RAM | # Limit Bazel to consuming 3072K of RAM | ||||||
| build --local_resources=3072,2.0,1.0 | 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