Skip to content

Commit 4c48449

Browse files
redsun82Paolo Tranquilli
andauthored
feat: add node_urls parameter to bzlmod toolchain in the node extension (#3763)
--------- Co-authored-by: Paolo Tranquilli <[email protected]>
1 parent 20d9b25 commit 4c48449

File tree

19 files changed

+197
-33
lines changed

19 files changed

+197
-33
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ jobs:
1919
test:
2020
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v6
2121
with:
22-
folders: '[".", "e2e/headers", "e2e/smoke", "e2e/nodejs_host"]'
22+
folders: '[".", "e2e/headers", "e2e/smoke", "e2e/nodejs_host", "e2e/conflicting_toolchains"]'
2323
# stardoc generated docs fail on diff_test with Bazel 6.4.0 so don't test against it in root repository
2424
exclude: |
2525
[
2626
{"bazelversion": "6.4.0", "os": "macos-latest"},
2727
{"bazelversion": "6.4.0", "os": "windows-latest"},
2828
{"bazelversion": "6.4.0", folder: "."},
2929
{"bazelversion": "6.4.0", bzlmodEnabled: true}
30+
# this test is for bzlmod only
31+
{folder: "e2e/conflicting_toolchains", bzlmodEnabled: false},
3032
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.bazelversion

e2e/conflicting_toolchains/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
error.txt
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# this is set up to make bazel test //... pass
2+
load("@bazel_skylib//rules:write_file.bzl", "write_file")
3+
4+
write_file(
5+
name = "empty",
6+
out = "empty.sh",
7+
content = [],
8+
)
9+
10+
sh_test(
11+
name = "dummy",
12+
srcs = [":empty"],
13+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# this is set up to make bazel test //... pass
2+
bazel_dep(name = "bazel_skylib", version = "1.7.1", dev_dependency = True)

e2e/conflicting_toolchains/test.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# this is the integration test checking various combinations of conflicting nodejs toolchain definitions
3+
4+
set -eu
5+
6+
for test_attr in test_*; do
7+
pushd $test_attr > /dev/null
8+
attr=${test_attr#test_}
9+
echo -n "testing conflict on $attr... "
10+
if bazel mod tidy &> error.txt; then
11+
echo "ERROR: bazel mod tidy should have failed with following MODULE.bazel:"
12+
cat MODULE.bazel
13+
exit 1
14+
elif ! grep "conflicting toolchains" error.txt > /dev/null; then
15+
echo "ERROR: expected bazel mod tidy to mention conflicting toolchains, found:"
16+
cat error.txt
17+
exit 1
18+
else
19+
echo "PASS"
20+
fi
21+
popd > /dev/null
22+
done
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.bazelversion
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
bazel_dep(name = "rules_nodejs", version = "0.0.0", dev_dependency = True)
2+
local_path_override(
3+
module_name = "rules_nodejs",
4+
path = "../../..",
5+
)
6+
7+
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
8+
node.toolchain(
9+
name = "mynode",
10+
)
11+
node.toolchain(
12+
name = "mynode",
13+
node_urls = ["file://whatever"],
14+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.bazelversion
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
bazel_dep(name = "rules_nodejs", version = "0.0.0", dev_dependency = True)
2+
local_path_override(
3+
module_name = "rules_nodejs",
4+
path = "../../..",
5+
)
6+
7+
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
8+
node.toolchain(
9+
name = "mynode",
10+
)
11+
node.toolchain(
12+
name = "mynode",
13+
include_headers = True,
14+
)

0 commit comments

Comments
 (0)