Skip to content

Commit

Permalink
feat: update to rules_js 1.27.0 and pickup fixed_args feature (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan authored May 24, 2023
1 parent 22ebf19 commit e133bc1
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 14 deletions.
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module(
version = "0.0.0",
)

bazel_dep(name = "aspect_bazel_lib", version = "1.30.2")
bazel_dep(name = "aspect_rules_js", version = "1.26.0")
bazel_dep(name = "aspect_bazel_lib", version = "1.32.1")
bazel_dep(name = "aspect_rules_js", version = "1.27.0")
bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "rules_nodejs", version = "5.8.2")

Expand Down
4 changes: 2 additions & 2 deletions e2e/npm_packages/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"Bazel dependencies"
bazel_dep(name = "aspect_bazel_lib", dev_dependency = True, version = "1.30.2")
bazel_dep(name = "aspect_bazel_lib", dev_dependency = True, version = "1.32.1")
bazel_dep(name = "aspect_rules_jest", dev_dependency = True, version = "0.0.0")
bazel_dep(name = "aspect_rules_js", dev_dependency = True, version = "1.26.0")
bazel_dep(name = "aspect_rules_js", dev_dependency = True, version = "1.27.0")

local_path_override(
module_name = "aspect_rules_jest",
Expand Down
4 changes: 2 additions & 2 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"Bazel dependencies"
bazel_dep(name = "aspect_bazel_lib", dev_dependency = True, version = "1.30.2")
bazel_dep(name = "aspect_bazel_lib", dev_dependency = True, version = "1.32.1")
bazel_dep(name = "aspect_rules_jest", dev_dependency = True, version = "0.0.0")
bazel_dep(name = "aspect_rules_js", dev_dependency = True, version = "1.26.0")
bazel_dep(name = "aspect_rules_js", dev_dependency = True, version = "1.27.0")

local_path_override(
module_name = "aspect_rules_jest",
Expand Down
12 changes: 6 additions & 6 deletions jest/dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ def rules_jest_dependencies():

http_archive(
name = "aspect_bazel_lib",
sha256 = "97fa63d95cc9af006c4c7b2123ddd2a91fb8d273012f17648e6423bae2c69470",
strip_prefix = "bazel-lib-1.30.2",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.30.2/bazel-lib-v1.30.2.tar.gz",
sha256 = "e3151d87910f69cf1fc88755392d7c878034a69d6499b287bcfc00b1cf9bb415",
strip_prefix = "bazel-lib-1.32.1",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.32.1/bazel-lib-v1.32.1.tar.gz",
)

http_archive(
name = "aspect_rules_js",
sha256 = "dcd1567d4a93a8634ec0b888b371a60b93c18d980f77dace02eb176531a71fcf",
strip_prefix = "rules_js-1.26.0",
url = "https://github.com/aspect-build/rules_js/releases/download/v1.26.0/rules_js-v1.26.0.tar.gz",
sha256 = "d8827db3c34fe47607a0668e86524fd85d5bd74f2bfca93046d07f890b5ad4df",
strip_prefix = "rules_js-1.27.0",
url = "https://github.com/aspect-build/rules_js/releases/download/v1.27.0/rules_js-v1.27.0.tar.gz",
)

http_archive(
Expand Down
9 changes: 7 additions & 2 deletions jest/private/jest_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ def _impl(ctx):
if ctx.attr.chdir:
unwind_chdir_prefix = "/".join([".."] * len(ctx.attr.chdir.split("/"))) + "/"

fixed_args = [
fixed_args = []

# TODO(1.0): we can assume fixed_args exists on attr for the 1.0 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([
# https://jestjs.io/docs/cli#--cache. Whether to use the cache. Defaults to true. Disable
# the cache using --no-cache. Caching is Bazel's job, we don't want non-hermeticity
"--no-cache",
Expand All @@ -78,7 +83,7 @@ def _impl(ctx):
# find and execute tests.
"--config",
paths.join(unwind_chdir_prefix, generated_config.short_path),
]
])
if ctx.attr.log_level == "debug":
fixed_args.append("--debug")
if ctx.attr.colors:
Expand Down
16 changes: 16 additions & 0 deletions jest/tests/fixed_args/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("//jest:defs.bzl", "jest_test")
load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains")

jest_test(
name = "test",
data = ["fixed_args.test.js"],
fixed_args = ["--silent"],
node_modules = "//:node_modules",
)

# assert that the launcher script contains the fixed arg --silent
assert_contains(
name = "fixed_args_test",
actual = ":test",
expected = "--silent",
)
3 changes: 3 additions & 0 deletions jest/tests/fixed_args/fixed_args.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test("2+2==4", () => {
expect(2 + 2).toEqual(4);
});

0 comments on commit e133bc1

Please sign in to comment.