Skip to content

Commit

Permalink
feat: import toolchains to use for copy actions
Browse files Browse the repository at this point in the history
  • Loading branch information
kormide committed Nov 16, 2023
1 parent 5211558 commit 7090261
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ jobs:
include:
- os: windows-latest
config: local
bazelversion: 6.2.0
bazelversion: 6.3.2
folder: e2e/bzlmod
bzlmodEnabled: true
- os: macos-latest
config: local
bazelversion: 6.2.0
bazelversion: 6.3.2
folder: e2e/bzlmod
bzlmodEnabled: true
- os: ubuntu-latest
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,14 @@ EOF

awk 'f;/--SNIP--/{f=1}' e2e/workspace/WORKSPACE
echo "\`\`\`"

cat << EOF
To use rules_js with bazel-lib 2.0, you must additionally register the coreutils toolchain.
\`\`\`starlark
load("@aspect_bazel_lib//lib:repositories.bzl", "register_coreutils_toolchains")
register_coreutils_toolchains()
\`\`\`
EOF
14 changes: 8 additions & 6 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module(

# Lower-bounds for runtime dependencies.
# Do not bump these unless rules_js requires a newer version to function.
bazel_dep(name = "aspect_bazel_lib", version = "1.31.2")
bazel_dep(name = "aspect_bazel_lib", version = "1.38.1")
bazel_dep(name = "bazel_features", version = "0.1.0")
bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "rules_nodejs", version = "5.8.2")
Expand Down Expand Up @@ -37,14 +37,16 @@ bazel_dep(name = "gazelle", version = "0.33.0", dev_dependency = True, repo_name
bazel_dep(name = "buildifier_prebuilt", version = "6.3.3", dev_dependency = True)
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.4.1", dev_dependency = True)

ext = use_extension(
host = use_extension(
"@aspect_bazel_lib//lib:extensions.bzl",
"ext",
"host",
dev_dependency = True,
)
ext.host()
use_repo(ext, "aspect_bazel_lib_host")
use_repo(ext, "coreutils_toolchains")
host.host()
use_repo(host, "aspect_bazel_lib_host")

bazel_lib_toolchains = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "toolchains")
use_repo(bazel_lib_toolchains, "coreutils_toolchains")

node_dev = use_extension(
"@rules_nodejs//nodejs:extensions.bzl",
Expand Down
2 changes: 1 addition & 1 deletion e2e/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module(
)

bazel_dep(name = "aspect_rules_js", version = "0.0.0")
bazel_dep(name = "aspect_bazel_lib", version = "2.0.0-rc0")
bazel_dep(name = "aspect_bazel_lib", version = "2.0.1")
bazel_dep(name = "bazel_skylib", version = "1.4.1")

local_path_override(
Expand Down
2 changes: 1 addition & 1 deletion e2e/js_run_devserver/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module(
)

bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "aspect_bazel_lib", version = "1.32.1")
bazel_dep(name = "aspect_bazel_lib", version = "1.38.1")
bazel_dep(name = "rules_go", version = "0.41.0")
bazel_dep(name = "aspect_rules_js", version = "0.0.0")
local_path_override(
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_lock/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module(
)

bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "aspect_bazel_lib", version = "1.32.1")
bazel_dep(name = "aspect_bazel_lib", version = "1.38.1")
bazel_dep(name = "aspect_rules_js", version = "0.0.0")
local_path_override(
module_name = "aspect_rules_js",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_lock_empty/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module(
)

bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "aspect_bazel_lib", version = "1.32.1")
bazel_dep(name = "aspect_bazel_lib", version = "1.38.1")
bazel_dep(name = "aspect_rules_js", version = "0.0.0")
local_path_override(
module_name = "aspect_rules_js",
Expand Down
2 changes: 1 addition & 1 deletion e2e/npm_translate_lock_partial_clone/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module(
)

bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "aspect_bazel_lib", version = "1.32.1")
bazel_dep(name = "aspect_bazel_lib", version = "1.38.1")
bazel_dep(name = "aspect_rules_js", version = "0.0.0")
local_path_override(
module_name = "aspect_rules_js",
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_workspace/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module(

bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "rules_nodejs", version = "5.8.2")
bazel_dep(name = "aspect_bazel_lib", version = "1.32.1")
bazel_dep(name = "aspect_bazel_lib", version = "1.38.1")
bazel_dep(name = "aspect_rules_js", version = "0.0.0")
local_path_override(
module_name = "aspect_rules_js",
Expand Down
21 changes: 12 additions & 9 deletions examples/js_library/two/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load(":tsc.bzl", "tsc")
load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test", "update_docs")
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

Expand Down Expand Up @@ -32,11 +31,15 @@ bzl_library(
],
)

stardoc_with_diff_test(
name = "tsc-docs",
bzl_library_target = ":tsc",
)

update_docs(
name = "docs",
)
# TODO(derek): stardoc doesn't work under bzlmod with these
# targets when working against an overridden version of bazel-lib.
# Remove comments of the released version of bazel-lib succeeds.
#
# stardoc_with_diff_test(
# name = "tsc-docs",
# bzl_library_target = ":tsc",
# )
#
# update_docs(
# name = "docs",
# )
21 changes: 12 additions & 9 deletions examples/macro/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("//examples/macro:mocha.bzl", "mocha_test")
load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test", "update_docs")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@npm//:defs.bzl", "npm_link_all_packages")

Expand All @@ -22,11 +21,15 @@ bzl_library(
],
)

stardoc_with_diff_test(
name = "mocha-docs",
bzl_library_target = ":mocha",
)

update_docs(
name = "docs",
)
# TODO(derek): stardoc doesn't work under bzlmod with these
# targets when working against an overridden version of bazel-lib.
# Remove comments of the released version of bazel-lib succeeds.
#
# stardoc_with_diff_test(
# name = "mocha-docs",
# bzl_library_target = ":mocha",
# )
#
# update_docs(
# name = "docs",
# )
3 changes: 2 additions & 1 deletion js/private/js_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ load("@aspect_bazel_lib//lib:windows_utils.bzl", "create_windows_native_launcher
load("@aspect_bazel_lib//lib:expand_make_vars.bzl", "expand_locations", "expand_variables")
load("@aspect_bazel_lib//lib:directory_path.bzl", "DirectoryPathInfo")
load("@aspect_bazel_lib//lib:utils.bzl", "is_bazel_6_or_greater")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "COPY_FILE_TO_BIN_TOOLCHAINS")
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load(":js_helpers.bzl", "LOG_LEVELS", "envs_for_log_level", "gather_runfiles")
load(":bash.bzl", "BASH_INITIALIZE_RUNFILES")
Expand Down Expand Up @@ -604,7 +605,7 @@ js_binary_lib = struct(
# TODO: on Windows this toolchain is never referenced
"@bazel_tools//tools/sh:toolchain_type",
"@rules_nodejs//nodejs:toolchain_type",
],
] + COPY_FILE_TO_BIN_TOOLCHAINS,
)

js_binary = rule(
Expand Down
2 changes: 2 additions & 0 deletions js/private/js_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ js_library(

load(":js_info.bzl", "JsInfo", "js_info")
load(":js_helpers.bzl", "DOWNSTREAM_LINKED_NPM_DEPS_DOCSTRING", "JS_LIBRARY_DATA_ATTR", "copy_js_file_to_bin_action", "gather_npm_linked_packages", "gather_npm_package_store_deps", "gather_runfiles", "gather_transitive_declarations", "gather_transitive_sources")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "COPY_FILE_TO_BIN_TOOLCHAINS")

_DOC = """A library of JavaScript sources. Provides JsInfo, the primary provider used in rules_js
and derivative rule sets.
Expand Down Expand Up @@ -244,4 +245,5 @@ js_library = rule(
implementation = js_library_lib.implementation,
attrs = js_library_lib.attrs,
provides = js_library_lib.provides,
toolchains = COPY_FILE_TO_BIN_TOOLCHAINS,
)
7 changes: 4 additions & 3 deletions js/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ See https://docs.bazel.build/versions/main/skylark/deploying.html#dependencies

load("//js/private:maybe.bzl", http_archive = "maybe_http_archive")

# buildifier: disable=function-docstring
def rules_js_dependencies():
http_archive(
name = "bazel_skylib",
Expand All @@ -21,9 +22,9 @@ def rules_js_dependencies():

http_archive(
name = "aspect_bazel_lib",
sha256 = "44f4f6d1ea1fc5a79ed6ca83f875038fee0a0c47db4f9c9beed097e56f8fad03",
strip_prefix = "bazel-lib-1.34.0",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.34.0/bazel-lib-v1.34.0.tar.gz",
sha256 = "262e3d6693cdc16dd43880785cdae13c64e6a3f63f75b1993c716295093d117f",
strip_prefix = "bazel-lib-1.38.1",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.38.1/bazel-lib-v1.38.1.tar.gz",
)

http_archive(
Expand Down

0 comments on commit 7090261

Please sign in to comment.