From 3fc9304d9a464cd0b6606480d92b7ab68e556911 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Fri, 19 Apr 2024 19:38:17 -0700 Subject: [PATCH] feat: upgrade to rules_js 2.0 --- .aspect/bazelrc/ci.bazelrc | 7 ------ .aspect/bazelrc/javascript.bazelrc | 1 + .bazelversion | 6 ----- .gitattributes | 3 +-- MODULE.bazel | 7 +++--- WORKSPACE | 13 +++------- e2e/jasmine_test/MODULE.bazel | 3 ++- .../{WORKSPACE => WORKSPACE.bazel} | 9 +++---- e2e/smoke/MODULE.bazel | 3 ++- e2e/smoke/WORKSPACE.bazel | 9 +++---- jasmine/defs.bzl | 6 +---- jasmine/dependencies.bzl | 24 +++++++------------ jasmine/private/jasmine_test.bzl | 13 +++++----- 13 files changed, 34 insertions(+), 70 deletions(-) rename e2e/jasmine_test/{WORKSPACE => WORKSPACE.bazel} (64%) diff --git a/.aspect/bazelrc/ci.bazelrc b/.aspect/bazelrc/ci.bazelrc index 4d91ee0..11aae33 100644 --- a/.aspect/bazelrc/ci.bazelrc +++ b/.aspect/bazelrc/ci.bazelrc @@ -1,10 +1,3 @@ -# We recommend enforcing a policy that keeps your CI from being slowed down -# by individual test targets that should be optimized -# or split up into multiple test targets with sharding or manually. -# Set this flag to exclude targets that have their timeout set to eternal (>15m) from running on CI. -# Docs: https://bazel.build/docs/user-manual#test-timeout-filters -test --test_timeout_filters=-eternal - # Set this flag to enable re-tries of failed tests on CI. # When any test target fails, try one or more times. This applies regardless of whether the "flaky" # tag appears on the target definition. diff --git a/.aspect/bazelrc/javascript.bazelrc b/.aspect/bazelrc/javascript.bazelrc index 474ec63..ace9d60 100644 --- a/.aspect/bazelrc/javascript.bazelrc +++ b/.aspect/bazelrc/javascript.bazelrc @@ -8,3 +8,4 @@ # details. # Docs: https://nodejs.org/en/docs/guides/debugging-getting-started/#command-line-options run:debug -- --node_options=--inspect-brk +test:debug --test_env=NODE_OPTIONS=--inspect-brk diff --git a/.bazelversion b/.bazelversion index 2b1ea10..21c8c7b 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1,7 +1 @@ 7.1.1 -# The first line of this file is used by Bazelisk and Bazel to be sure -# the right version of Bazel is used to build and test this repo. -# This also defines which version is used on CI. -# -# Note that you should also run integration_tests against other Bazel -# versions you support. diff --git a/.gitattributes b/.gitattributes index 5377947..0df11ad 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,7 +5,6 @@ pnpm-lock.yaml linguist-generated=true # Configuration for 'git archive' # See https://git-scm.com/docs/git-archive#ATTRIBUTES -# Don't include e2e & examples in the distribution artifact, to reduce size. +# Don't include examples in the distribution artifact, to reduce size. # You may want to add additional exclusions for folders or files that users don't need. -e2e export-ignore examples export-ignore diff --git a/MODULE.bazel b/MODULE.bazel index 5c1a344..2a46ac6 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -7,11 +7,10 @@ module( ) # Lower-bounds (minimum) versions for direct runtime dependencies -bazel_dep(name = "aspect_bazel_lib", version = "1.40.2") -bazel_dep(name = "aspect_rules_js", version = "1.37.1") -bazel_dep(name = "bazel_features", version = "1.4.1") +bazel_dep(name = "aspect_bazel_lib", version = "2.7.3") +bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.5") bazel_dep(name = "bazel_skylib", version = "1.5.0") -bazel_dep(name = "rules_nodejs", version = "5.8.3") +bazel_dep(name = "rules_nodejs", version = "6.1.0") ####### Dev dependencies ######## diff --git a/WORKSPACE b/WORKSPACE index b62215d..e31a50c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -10,18 +10,11 @@ load("//jasmine:dependencies.bzl", "rules_jasmine_dependencies") # Fetch dependencies which users need as well rules_jasmine_dependencies() -load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") +load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains") -aspect_bazel_lib_dependencies() +rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION) -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") - -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) - -load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock") +load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") npm_translate_lock( name = "npm", diff --git a/e2e/jasmine_test/MODULE.bazel b/e2e/jasmine_test/MODULE.bazel index 3e0396d..c12c486 100644 --- a/e2e/jasmine_test/MODULE.bazel +++ b/e2e/jasmine_test/MODULE.bazel @@ -4,7 +4,8 @@ local_path_override( path = "../..", ) -bazel_dep(name = "aspect_rules_js", version = "1.37.1", dev_dependency = True) +bazel_dep(name = "aspect_bazel_lib", version = "2.7.3", dev_dependency = True) +bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.5", dev_dependency = True) npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True) npm.npm_translate_lock( diff --git a/e2e/jasmine_test/WORKSPACE b/e2e/jasmine_test/WORKSPACE.bazel similarity index 64% rename from e2e/jasmine_test/WORKSPACE rename to e2e/jasmine_test/WORKSPACE.bazel index 9fec8f9..ae54675 100644 --- a/e2e/jasmine_test/WORKSPACE +++ b/e2e/jasmine_test/WORKSPACE.bazel @@ -8,14 +8,11 @@ load("@aspect_rules_jasmine//jasmine:dependencies.bzl", "rules_jasmine_dependenc rules_jasmine_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION) -load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock") +load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") npm_translate_lock( name = "npm", diff --git a/e2e/smoke/MODULE.bazel b/e2e/smoke/MODULE.bazel index 3e0396d..c12c486 100644 --- a/e2e/smoke/MODULE.bazel +++ b/e2e/smoke/MODULE.bazel @@ -4,7 +4,8 @@ local_path_override( path = "../..", ) -bazel_dep(name = "aspect_rules_js", version = "1.37.1", dev_dependency = True) +bazel_dep(name = "aspect_bazel_lib", version = "2.7.3", dev_dependency = True) +bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.5", dev_dependency = True) npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True) npm.npm_translate_lock( diff --git a/e2e/smoke/WORKSPACE.bazel b/e2e/smoke/WORKSPACE.bazel index 3d11491..a83db4a 100644 --- a/e2e/smoke/WORKSPACE.bazel +++ b/e2e/smoke/WORKSPACE.bazel @@ -20,14 +20,11 @@ load("@aspect_rules_jasmine//jasmine:dependencies.bzl", "rules_jasmine_dependenc # Fetch dependencies which users need as well rules_jasmine_dependencies() -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION) -load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock") +load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") npm_translate_lock( name = "npm", diff --git a/jasmine/defs.bzl b/jasmine/defs.bzl index f70cb36..919bcfa 100644 --- a/jasmine/defs.bzl +++ b/jasmine/defs.bzl @@ -69,11 +69,7 @@ def jasmine_test( name = name, config = config, enable_runfiles = select({ - "@aspect_rules_js//js:enable_runfiles": True, - "//conditions:default": False, - }), - unresolved_symlinks_enabled = select({ - "@aspect_rules_js//js:allow_unresolved_symlinks": True, + "@aspect_bazel_lib//lib:enable_runfiles": True, "//conditions:default": False, }), entry_point = entry_point, diff --git a/jasmine/dependencies.bzl b/jasmine/dependencies.bzl index 31e4199..eebc861 100644 --- a/jasmine/dependencies.bzl +++ b/jasmine/dependencies.bzl @@ -16,27 +16,21 @@ def rules_jasmine_dependencies(): http_archive( name = "aspect_bazel_lib", - sha256 = "04feedcd06f71d0497a81fdd3220140a373ff9d2bff94620fbd50b774f96d8e0", - strip_prefix = "bazel-lib-1.40.2", - url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.40.2/bazel-lib-v1.40.2.tar.gz", + sha256 = "87ab4ec479ebeb00d286266aca2068caeef1bb0b1765e8f71c7b6cfee6af4226", + strip_prefix = "bazel-lib-2.7.3", + url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.3/bazel-lib-v2.7.3.tar.gz", ) http_archive( name = "aspect_rules_js", - sha256 = "630a71aba66c4023a5b16ab3efafaeed8b1a2865ccd168a34611eb73876b3fc4", - strip_prefix = "rules_js-1.37.1", - url = "https://github.com/aspect-build/rules_js/releases/download/v1.37.1/rules_js-v1.37.1.tar.gz", + sha256 = "d6a91bb85fcc97c18d929829c8e85ba59ce21c06aa28ca0b6dbc8d3a3ca8e6fa", + strip_prefix = "rules_js-2.0.0-alpha.5", + url = "https://github.com/aspect-build/rules_js/releases/download/v2.0.0-alpha.5/rules_js-v2.0.0-alpha.5.tar.gz", ) http_archive( name = "rules_nodejs", - sha256 = "8fc8e300cb67b89ceebd5b8ba6896ff273c84f6099fc88d23f24e7102319d8fd", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.4/rules_nodejs-core-5.8.4.tar.gz"], - ) - - http_archive( - name = "bazel_features", - sha256 = "0f23d75c7623d6dba1fd30513a94860447de87c8824570521fcc966eda3151c2", - strip_prefix = "bazel_features-1.4.1", - url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.4.1/bazel_features-v1.4.1.tar.gz", + sha256 = "dddd60acc3f2f30359bef502c9d788f67e33814b0ddd99aa27c5a15eb7a41b8c", + strip_prefix = "rules_nodejs-6.1.0", + url = "https://github.com/bazelbuild/rules_nodejs/releases/download/v6.1.0/rules_nodejs-v6.1.0.tar.gz", ) diff --git a/jasmine/private/jasmine_test.bzl b/jasmine/private/jasmine_test.bzl index aa79b03..7e47128 100644 --- a/jasmine/private/jasmine_test.bzl +++ b/jasmine/private/jasmine_test.bzl @@ -17,10 +17,7 @@ def _impl(ctx): files = ctx.files.data[:] fixed_args = [] - - # TODO(2.0): we can assume fixed_args exists on attr for the 2.0 major release (it comes from rules_js 1.27.0) - if hasattr(ctx.attr, "fixed_args"): - fixed_args.extend(ctx.attr.fixed_args) + fixed_args.extend(ctx.attr.fixed_args) if ctx.attr.junit_reporter: files.append(ctx.file.junit_reporter) @@ -47,11 +44,13 @@ def _impl(ctx): runfiles = ctx.runfiles( files = files, - transitive_files = js_lib_helpers.gather_files_from_js_providers( + transitive_files = js_lib_helpers.gather_files_from_js_infos( targets = ctx.attr.data, + include_sources = ctx.attr.include_sources, + include_types = ctx.attr.include_types, include_transitive_sources = ctx.attr.include_transitive_sources, - include_declarations = ctx.attr.include_declarations, - include_npm_linked_packages = ctx.attr.include_npm_linked_packages, + include_transitive_types = ctx.attr.include_transitive_types, + include_npm_sources = ctx.attr.include_npm_sources, ), ).merge(launcher.runfiles).merge_all([ target[DefaultInfo].default_runfiles