Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: do not double process lifecycle_hooks* attributes in bzlmod #1805

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

jbedard
Copy link
Member

@jbedard jbedard commented Jun 13, 2024

These are processed differently in bzlmod in extensions.bzl where the bzlmod invocation of npm_import is done.

See what is no longer unnecessarily duplicated in bzlmod:

# Gather undocumented attributes
root_package = kwargs.pop("root_package", None)
additional_file_contents = kwargs.pop("additional_file_contents", {})
repositories_bzl_filename = kwargs.pop("repositories_bzl_filename", None)
defs_bzl_filename = kwargs.pop("defs_bzl_filename", None)
generate_bzl_library_targets = kwargs.pop("generate_bzl_library_targets", None)
bzlmod = kwargs.pop("bzlmod", False)
if len(kwargs):
msg = "Invalid npm_translate_lock parameter '{}'".format(kwargs.keys()[0])
fail(msg)
if not bzlmod and pnpm_version != None:
_pnpm_repository(name = "pnpm", pnpm_version = pnpm_version)
if yarn_lock:
data = data + [yarn_lock]
if npm_package_lock:
data = data + [npm_package_lock]
# convert bins to a string_list_dict to satisfy attr type in repository rule
bins_string_list_dict = {}
if type(bins) != "dict":
fail("Expected bins to be a dict")
for key, value in bins.items():
if type(value) == "list":
# The passed 'bins' value is already in the dict-of-string-list
# form needed by the rule. This is undocumented but necessary for
# the bzlmod interface to use this macro since dict-of-dicts attributes
# cannot be passed into module extension attrs.
bins_string_list_dict = bins
break
if type(value) != "dict":
fail("Expected values in bins to be a dicts")
if key not in bins_string_list_dict:
bins_string_list_dict[key] = []
for value_key, value_value in value.items():
bins_string_list_dict[key].append("{}={}".format(value_key, value_value))
if not update_pnpm_lock and preupdate:
fail("expected update_pnpm_lock to be True when preupdate are specified")
lifecycle_hooks, lifecycle_hooks_execution_requirements, lifecycle_hooks_use_default_shell_env = macro_helpers.macro_lifecycle_args_to_rule_attrs(
lifecycle_hooks,
lifecycle_hooks_exclude,
run_lifecycle_hooks,
lifecycle_hooks_no_sandbox,
lifecycle_hooks_execution_requirements,
lifecycle_hooks_use_default_shell_env,
)


Changes are visible to end-users: no

Test plan

  • Covered by existing test cases

Copy link

aspect-workflows bot commented Jun 13, 2024

Test

All tests were cache hits

193 tests (100.0%) were fully cached saving 42s.


Test

e2e/bzlmod

All tests were cache hits

4 tests (100.0%) were fully cached saving 486ms.


Test

e2e/gyp_no_install_script

Buildkite build #4712 is running...


Test

e2e/js_image_oci

All tests were cache hits

1 test (100.0%) was fully cached saving 7s.


Test

e2e/npm_link_package

Buildkite build #4712 is running...


Test

e2e/npm_link_package-esm

Buildkite build #4712 is running...


Test

e2e/npm_translate_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 73ms.


Test

e2e/npm_translate_lock_empty

Buildkite build #4712 is running...


Test

e2e/npm_translate_lock_multi

All tests were cache hits

2 tests (100.0%) were fully cached saving 271ms.


Test

e2e/npm_translate_lock_partial_clone

All tests were cache hits

1 test (100.0%) was fully cached saving 117ms.


Test

e2e/npm_translate_lock_subdir_patch

Buildkite build #4712 is running...


Test

e2e/npm_translate_package_lock

Buildkite build #4712 is running...


Test

e2e/npm_translate_yarn_lock

Buildkite build #4712 is running...


Test

e2e/package_json_module

All tests were cache hits

1 test (100.0%) was fully cached saving 566ms.


Test

e2e/pnpm_lockfiles

Buildkite build #4712 is running...


Test

e2e/pnpm_workspace

Buildkite build #4712 is running...


Test

e2e/pnpm_workspace_rerooted

Buildkite build #4712 is running...


Test

e2e/repo_mapping

All tests were cache hits

2 tests (100.0%) were fully cached saving 453ms.


Test

e2e/rules_foo

Buildkite build #4712 is running...


Test

e2e/vendored_node

Waiting for runner...


Buildifier      Format

Copy link
Member

@gregmagolan gregmagolan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦖

@jbedard jbedard merged commit 67dca0d into aspect-build:main Jun 21, 2024
98 checks passed
@jbedard jbedard deleted the bzlmod-dedupe-0 branch June 21, 2024 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants