fix(bazel): only providing stamping information if the --stamp flag is used (#39392)
Previously the volatile status file was always provided to the ng_rollup action which prevented it from being cacheable remotely. This change to only provide this file as an input when the --stamp flag is used will allow for the action to be remotely cached and prevent needing to run the action on every CI run. PR Close #39392
This commit is contained in:
parent
27a4adebcb
commit
67069ce42a
@ -13,7 +13,7 @@ It packages your library following the Angular Package Format, see the
|
|||||||
specification of this format at https://goo.gl/jB3GVv
|
specification of this format at https://goo.gl/jB3GVv
|
||||||
"""
|
"""
|
||||||
|
|
||||||
load("@build_bazel_rules_nodejs//:providers.bzl", "JSEcmaScriptModuleInfo", "JSNamedModuleInfo", "NpmPackageInfo", "node_modules_aspect")
|
load("@build_bazel_rules_nodejs//:providers.bzl", "JSEcmaScriptModuleInfo", "JSNamedModuleInfo", "NodeContextInfo", "NpmPackageInfo", "node_modules_aspect")
|
||||||
load(
|
load(
|
||||||
"@build_bazel_rules_nodejs//internal/pkg_npm:pkg_npm.bzl",
|
"@build_bazel_rules_nodejs//internal/pkg_npm:pkg_npm.bzl",
|
||||||
"PKG_NPM_ATTRS",
|
"PKG_NPM_ATTRS",
|
||||||
@ -230,6 +230,9 @@ def _write_rollup_config(
|
|||||||
if not include_tslib:
|
if not include_tslib:
|
||||||
external.append("tslib")
|
external.append("tslib")
|
||||||
|
|
||||||
|
# Whether the --stamp flag is applied in the context of the action's execution.
|
||||||
|
stamp = ctx.attr.node_context_data[NodeContextInfo].stamp
|
||||||
|
|
||||||
# Pass external & globals through a templated config file because on Windows there is
|
# Pass external & globals through a templated config file because on Windows there is
|
||||||
# an argument limit and we there might be a lot of globals which need to be passed to
|
# an argument limit and we there might be a lot of globals which need to be passed to
|
||||||
# rollup.
|
# rollup.
|
||||||
@ -242,7 +245,7 @@ def _write_rollup_config(
|
|||||||
"TMPL_module_mappings": str(mappings),
|
"TMPL_module_mappings": str(mappings),
|
||||||
"TMPL_node_modules_root": _compute_node_modules_root(ctx),
|
"TMPL_node_modules_root": _compute_node_modules_root(ctx),
|
||||||
"TMPL_root_dir": root_dir,
|
"TMPL_root_dir": root_dir,
|
||||||
"TMPL_stamp_data": "\"%s\"" % ctx.version_file.path if ctx.version_file else "undefined",
|
"TMPL_stamp_data": "\"%s\"" % ctx.version_file.path if (stamp and ctx.version_file) else "undefined",
|
||||||
"TMPL_workspace_name": ctx.workspace_name,
|
"TMPL_workspace_name": ctx.workspace_name,
|
||||||
"TMPL_external": ", ".join(["'%s'" % e for e in external]),
|
"TMPL_external": ", ".join(["'%s'" % e for e in external]),
|
||||||
"TMPL_globals": ", ".join(["'%s': '%s'" % g for g in globals.items()]),
|
"TMPL_globals": ", ".join(["'%s': '%s'" % g for g in globals.items()]),
|
||||||
@ -289,10 +292,13 @@ def _run_rollup(ctx, bundle_name, rollup_config, entry_point, inputs, js_output,
|
|||||||
# bazel rule prints nothing on success.
|
# bazel rule prints nothing on success.
|
||||||
args.add("--silent")
|
args.add("--silent")
|
||||||
|
|
||||||
|
# Whether the --stamp flag is applied in the context of the action's execution.
|
||||||
|
stamp = ctx.attr.node_context_data[NodeContextInfo].stamp
|
||||||
|
|
||||||
other_inputs = [rollup_config]
|
other_inputs = [rollup_config]
|
||||||
if ctx.file.license_banner:
|
if ctx.file.license_banner:
|
||||||
other_inputs.append(ctx.file.license_banner)
|
other_inputs.append(ctx.file.license_banner)
|
||||||
if ctx.version_file:
|
if stamp and ctx.version_file:
|
||||||
other_inputs.append(ctx.version_file)
|
other_inputs.append(ctx.version_file)
|
||||||
ctx.actions.run(
|
ctx.actions.run(
|
||||||
progress_message = "ng_package: Rollup %s %s" % (bundle_name, ctx.label),
|
progress_message = "ng_package: Rollup %s %s" % (bundle_name, ctx.label),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user