Skip to content

Commit

Permalink
feat: upgrade to rules_js 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Apr 27, 2024
1 parent 5af5d38 commit 2aa171d
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 78 deletions.
7 changes: 0 additions & 7 deletions .aspect/bazelrc/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion .bazeliskrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BAZELISK_BASE_URL=https://github.com/aspect-build/aspect-cli/releases/download
USE_BAZEL_VERSION=aspect/5.8.19
USE_BAZEL_VERSION=aspect/5.9.25
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
7.0.2
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.
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/buildifier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Buildifier

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: buildifier
run: bazel run --enable_bzlmod //:buildifier.check
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: buildifier-lint
# Enforce that commit messages allow for later changelog generation
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.14.1
rev: v3.24.0
hooks:
# Requires that commitizen is already installed
- id: commitizen
Expand Down
14 changes: 8 additions & 6 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ module(
compatibility_level = 1,
)

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")
# Lower-bounds (minimum) versions for direct runtime dependencies
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1")
bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.2")
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 ########

bazel_dep(name = "aspect_rules_lint", version = "0.11.0", dev_dependency = True)
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.4.1", dev_dependency = True)
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
bazel_dep(name = "gazelle", version = "0.35.0", dev_dependency = True, repo_name = "bazel_gazelle")
bazel_dep(name = "gazelle", version = "0.36.0", dev_dependency = True, repo_name = "bazel_gazelle")
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc")
13 changes: 3 additions & 10 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion e2e/jasmine_test/MODULE.bazel

This file was deleted.

17 changes: 17 additions & 0 deletions e2e/jasmine_test/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
bazel_dep(name = "aspect_rules_jasmine", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_jasmine",
path = "../..",
)

bazel_dep(name = "aspect_bazel_lib", version = "2.7.1", dev_dependency = True)
bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.2", dev_dependency = True)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm.npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "@aspect_rules_jasmine//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions e2e/jasmine_test/WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Marker file that this is the root of a Bazel workspace.
# This file replaces WORKSPACE.bazel under --enable_bzlmod.
12 changes: 6 additions & 6 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"Bazel dependencies"

bazel_dep(name = "aspect_rules_jasmine", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "aspect_rules_jasmine",
path = "../..",
)

bazel_dep(name = "aspect_rules_js", version = "1.37.1")

bazel_dep(name = "aspect_rules_jasmine", version = "0.0.0", dev_dependency = True)
bazel_dep(name = "aspect_bazel_lib", version = "2.7.1", dev_dependency = True)
bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.2", dev_dependency = True)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm.npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "@aspect_rules_jasmine//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")
9 changes: 3 additions & 6 deletions e2e/smoke/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions internal_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ def rules_jasmine_internal_deps():
"Fetch deps needed for local development"
http_archive(
name = "io_bazel_rules_go",
sha256 = "6734a719993b1ba4ebe9806e853864395a8d3968ad27f9dd759c196b3eb3abe8",
urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.45.1/rules_go-v0.45.1.zip"],
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip"],
)

http_archive(
name = "bazel_gazelle",
sha256 = "32938bda16e6700063035479063d9d24c60eda8d79fd4739563f50d331cb3209",
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz"],
integrity = "sha256-dd8ojEsxyB61D1Hi4U9HY8t1SNquEmgXJHBkY3/Z6mI=",
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.36.0/bazel-gazelle-v0.36.0.tar.gz"],
)

http_archive(
name = "bazel_skylib_gazelle_plugin",
sha256 = "0a466b61f331585f06ecdbbf2480b9edf70e067a53f261e0596acd573a7d2dc3",
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-gazelle-plugin-1.4.1.tar.gz"],
sha256 = "747addf3f508186234f6232674dd7786743efb8c68619aece5fb0cac97b8f415",
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-gazelle-plugin-1.5.0.tar.gz"],
)

http_archive(
Expand Down
6 changes: 1 addition & 5 deletions jasmine/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 9 additions & 15 deletions jasmine/dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "b554eb7942a5ab44c90077df6a0c76fc67c5874c9446a007e9ba68be82bd4796",
strip_prefix = "bazel-lib-2.7.1",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.1/bazel-lib-v2.7.1.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 = "b627acf34f928507dfabae69d3fd8702ce3d45bed568ad4c44b243cb789f08c6",
strip_prefix = "rules_js-2.0.0-alpha.2",
url = "https://github.com/aspect-build/rules_js/releases/download/v2.0.0-alpha.2/rules_js-v2.0.0-alpha.2.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",
)
13 changes: 6 additions & 7 deletions jasmine/private/jasmine_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 2aa171d

Please sign in to comment.