Skip to content

Commit

Permalink
build: only run bazel 6 unit tests with bzlmod
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Oct 18, 2024
1 parent 7d20158 commit 56bc5b0
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 11 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ jobs:
major: 6
bzlmod: 1
folder: e2e/npm_translate_lock_replace_packages
# Don't run bzlmod tests with Bazel 6 to reduce the size of the test matrix
# Don't run workspace tests with Bazel 6 to reduce the size of the test matrix
# and remove the need for bazel 6 workspace support for local development.
- bazel-version:
major: 6
bzlmod: 1
bzlmod: 0
# Don't run workspace smoke test under bzlmod
- bzlmod: 1
folder: e2e/workspace
Expand All @@ -150,27 +151,32 @@ jobs:
folder: e2e/npm_link_package
- bzlmod: 1
folder: e2e/rules_foo
# gyp_no_install_script is broken in an usual way on 6.5.0
# gyp_no_install_script+patch_from_repo+js_run_devserver are broken in an usual way on 6.5.0
# that is not worth investigating as we're dropping Bazel 6 support soon
- bazel-version:
major: 6
bzlmod: 0
folder: e2e/gyp_no_install_script
- bazel-version:
major: 6
folder: e2e/patch_from_repo
- bazel-version:
major: 6
folder: e2e/js_run_devserver
# @bazel/runfiles seems broken with non-bzlmod + bazel7
# https://github.com/bazel-contrib/rules_nodejs/issues/3797
- bzlmod: 0
folder: e2e/runfiles
include:
- bazel-version:
major: 7
version: 7.1.1
version: 7.3.2
bzlmod: 1
os: windows
config: local
folder: e2e/bzlmod
- bazel-version:
major: 7
version: 7.1.1
version: 7.3.2
bzlmod: 1
os: macos
config: local
Expand Down Expand Up @@ -253,8 +259,8 @@ jobs:
--bazelrc=${GITHUB_WORKSPACE//\\/\/}/.github/workflows/ci.bazelrc \
test \
--config=local \
--test_tag_filters=-skip-on-bazel${{ matrix.bazel-version.major }} \
--build_tag_filters=-skip-on-bazel${{ matrix.bazel-version.major }} \
--test_tag_filters=-skip-on-bazel${{ matrix.bazel-version.major }},-skip-on-bzlmod-${{ matrix.bzlmod }} \
--build_tag_filters=-skip-on-bazel${{ matrix.bazel-version.major }},-skip-on-bzlmod-${{ matrix.bzlmod }} \
--enable_bzlmod=${{ matrix.bzlmod }} \
//...
env:
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.7.1", dev_dependenc
bazel_dep(name = "buildifier_prebuilt", version = "7.3.1", dev_dependency = True)
bazel_dep(name = "gazelle", version = "0.39.1", dev_dependency = True, repo_name = "bazel_gazelle")
bazel_dep(name = "rules_go", version = "0.50.1", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.7.1", dev_dependency = True, repo_name = "io_bazel_stardoc")
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc")

host = use_extension(
"@aspect_bazel_lib//lib:extensions.bzl",
Expand Down
77 changes: 75 additions & 2 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,49 +1,97 @@
load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test", "update_docs")
load(":docs.bzl", "stardoc_with_diff_test", "update_docs")

# NOTE: run docs on non-bzlmod bazel7 where 'stardoc' is updated
# to latest while bzlmod 'stardoc' is blocked on upgrade due to bazel6+bzlmod compatibility.

stardoc_with_diff_test(
name = "js_binary",
bzl_library_target = "//js/private:js_binary",
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

stardoc_with_diff_test(
name = "js_library",
bzl_library_target = "//js/private:js_library",
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

stardoc_with_diff_test(
name = "js_run_binary",
bzl_library_target = "//js/private:js_run_binary",
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

stardoc_with_diff_test(
name = "js_run_devserver",
bzl_library_target = "//js/private:js_run_devserver",
symbol_names = ["js_run_devserver"],
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

stardoc_with_diff_test(
name = "js_info_files",
bzl_library_target = "//js/private:js_info_files",
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

stardoc_with_diff_test(
name = "js_image_layer",
bzl_library_target = "//js/private:js_image_layer",
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

stardoc_with_diff_test(
name = "npm_package",
bzl_library_target = "//npm/private:npm_package",
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

stardoc_with_diff_test(
name = "npm_link_package",
bzl_library_target = "//npm/private:npm_link_package",
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

stardoc_with_diff_test(
name = "npm_link_all_packages",
bzl_library_target = "//npm/private:npm_translate_lock_generate.docs",
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

stardoc_with_diff_test(
Expand All @@ -52,6 +100,11 @@ stardoc_with_diff_test(
symbol_names = [
"npm_import",
],
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

stardoc_with_diff_test(
Expand All @@ -61,10 +114,20 @@ stardoc_with_diff_test(
"list_patches",
"npm_translate_lock",
],
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

update_docs(
name = "update",
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

# Demonstration delivery target for Aspect Workflows.
Expand All @@ -73,7 +136,12 @@ sh_binary(
name = "docs_delivery_only_on_change",
srcs = ["delivery.sh"],
data = glob(["*.md"]),
tags = ["deliverable"],
tags = [
"deliverable",
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)

# Demonstration delivery target for Aspect Workflows.
Expand All @@ -82,4 +150,9 @@ sh_binary(
name = "docs_delivery",
srcs = ["delivery.sh"],
data = glob(["*.md"]),
tags = [
"skip-on-bazel6",
"skip-on-bzlmod-1",
"skip-on-rbe",
],
)
18 changes: 18 additions & 0 deletions docs/docs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Wrapper around stardoc_with_diff_test that only runs the test if Bazel 7 or greater is being used.
"""

load("@aspect_bazel_lib//lib:docs.bzl", _stardoc_with_diff_test = "stardoc_with_diff_test", _update_docs = "update_docs")
load("@aspect_bazel_lib//lib:utils.bzl", "is_bazel_7_or_greater")

def stardoc_with_diff_test(name, **kwargs):
"""
Wrapper around stardoc_with_diff_test that only runs the test if Bazel 7 or greater is being used.
"""
if is_bazel_7_or_greater():
_stardoc_with_diff_test(name, **kwargs)
else:
# buildifier: disable=print
print("WARNING: Skipping stardoc_with_diff_test for %s because it requires Bazel 7 or greater" % name)

update_docs = _update_docs
3 changes: 3 additions & 0 deletions e2e/pnpm_lockfiles/lockfile-test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ def lockfile_test(name = None):
for f in BZL_FILES.keys()
],
),
# Target names may be different on workspace vs bzlmod
target_compatible_with = select({
"@aspect_bazel_lib//lib:bzlmod": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
# Target names may be different on bazel versions
tags = ["skip-on-bazel6"],
)
2 changes: 2 additions & 0 deletions js/private/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ write_source_files(
files = {
"snapshots/wksp/launcher.sh": ":shell_launcher_sed",
},
tags = ["skip-on-bazel6"],
target_compatible_with = select({
"@aspect_bazel_lib//lib:bzlmod": ["@platforms//:incompatible"],
"//conditions:default": [],
Expand All @@ -45,6 +46,7 @@ write_source_files(
files = {
"snapshots/bzlmod/launcher.sh": ":shell_launcher_sed",
},
tags = ["skip-on-bazel6"],
target_compatible_with = select({
"@aspect_bazel_lib//lib:bzlmod": [],
"//conditions:default": ["@platforms//:incompatible"],
Expand Down
2 changes: 2 additions & 0 deletions js/private/test/image/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ write_source_file(
testonly = True,
in_file = ":checksum_gen",
out_file = "checksum.expected",
# Under bazel6 bzlmod name differs
tags = ["skip-on-bazel6"],
# Under bzlmod workspace name is a fixed string `_main` which differs from WORKSPACE
target_compatible_with = select({
"@aspect_bazel_lib//lib:bzlmod": [],
Expand Down

0 comments on commit 56bc5b0

Please sign in to comment.