From d4c3742e25068ad7df531e893b2f82bf2ad0a42f Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 19 Oct 2018 14:41:26 -0700 Subject: [PATCH] build: don't depend on npm packages from public api tests (#26602) We need only the inputs from ng_module. PR Close #26602 --- tools/public_api_guard/BUILD.bazel | 32 ++------------------- tools/public_api_guard/public_api_guard.bzl | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 30 deletions(-) create mode 100644 tools/public_api_guard/public_api_guard.bzl diff --git a/tools/public_api_guard/BUILD.bazel b/tools/public_api_guard/BUILD.bazel index 275b3e8d04..bee1b28835 100644 --- a/tools/public_api_guard/BUILD.bazel +++ b/tools/public_api_guard/BUILD.bazel @@ -1,31 +1,3 @@ -load("//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test") +load(":public_api_guard.bzl", "generate_targets") -[ts_api_guardian_test( - name = "%s_%s_api" % ( - bundle[0], - bundle[1].replace("/", "_"), - ), - actual = "packages/%s/npm_package/%s.d.ts" % ( - bundle[0], - bundle[1], - ), - data = glob([ - "%s/**/*.d.ts" % bundle[0], - ]) + [ - "//packages/%s:npm_package" % bundle[0], - ], - golden = "tools/public_api_guard/%s/%s.d.ts" % ( - bundle[0], - bundle[1], - ), - # https://github.com/angular/angular/pull/26602 might be enough to fix the fixme-ivy-jit and fixme-ivy-aot issues - tags = [ - "fixme-ivy-aot", - "fixme-ivy-jit", - ], -) for bundle in [b[:-len(".d.ts")].split("/", 1) for b in glob( - ["**/*.d.ts"], - # The API surface of the compiler is currently unstable - all of the important APIs are exposed - # via @angular/core, @angular/platform-browser or @angular/platform-browser-dynamic instead. - exclude = ["compiler/*"], -)]] +generate_targets(glob(["**/*.d.ts"])) diff --git a/tools/public_api_guard/public_api_guard.bzl b/tools/public_api_guard/public_api_guard.bzl new file mode 100644 index 0000000000..cf4f0d5a68 --- /dev/null +++ b/tools/public_api_guard/public_api_guard.bzl @@ -0,0 +1,29 @@ +# Copyright Google Inc. All Rights Reserved. +# +# Use of this source code is governed by an MIT-style license that can be +# found in the LICENSE file at https://angular.io/license + +"""public_api_guard bazel target generator +""" + +load("//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test") + +def generate_targets(golden_files): + """Generates a list of targets to check based on the golden files passed in. + """ + for golden_file in golden_files: + entry_point = golden_file[:-len(".d.ts")] + [package_name, entry_point_tail] = entry_point.split("/", 1) + directory_name = entry_point_tail.split("/")[-1] + target_suffix = "/" + entry_point_tail if package_name != entry_point_tail else "" + actual_file = "packages/%s%s/%s.d.ts" % (package_name, target_suffix, directory_name) + label_name = package_name + target_suffix.replace("/", "_") + + ts_api_guardian_test( + name = "%s_api" % label_name, + actual = actual_file, + data = [golden_file] + [ + "//packages/%s:%s" % (package_name + target_suffix, directory_name), + ], + golden = "tools/public_api_guard/%s" % golden_file, + )