diff --git a/.bazeliskrc b/.bazeliskrc deleted file mode 100644 index a28c88750..000000000 --- a/.bazeliskrc +++ /dev/null @@ -1,2 +0,0 @@ -BAZELISK_BASE_URL=https://github.com/aspect-build/aspect-cli/releases/download -USE_BAZEL_VERSION=aspect/5.7.2 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7123d89a1..3bb13b267 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -114,16 +114,6 @@ jobs: # Don't test Windows with Bazel 7 to minimize Windows minutes (billed at 2X) - bazelversion: 7.0.0 os: windows-latest - # TODO: fix or disable the following build & test on Windows - # //lib/tests/coreutils:test_sha256sum FAILED in 2 out of 2 in 0.2s - # //lib/tests/coreutils:test_sha512sum FAILED in 2 out of 2 in 0.2s - # //docs:update_0_test FAILED TO BUILD - # //docs:update_10_test FAILED TO BUILD - # //docs:update_11_test FAILED TO BUILD - # //docs:update_12_test FAILED TO BUILD - # //docs:update_13_test FAILED TO BUILD - - folder: . - os: windows-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: diff --git a/lib/BUILD.bazel b/lib/BUILD.bazel index 614ae2fda..405be4cc5 100644 --- a/lib/BUILD.bazel +++ b/lib/BUILD.bazel @@ -248,11 +248,11 @@ bzl_library( name = "testing", srcs = ["testing.bzl"], deps = [ + ":diff_test", ":jq", ":params_file", ":utils", "@bazel_skylib//lib:types", - "@bazel_skylib//rules:diff_test", "@bazel_skylib//rules:write_file", ], ) diff --git a/lib/private/tar_toolchain.bzl b/lib/private/tar_toolchain.bzl index fa4edb2fd..61a1cce87 100644 --- a/lib/private/tar_toolchain.bzl +++ b/lib/private/tar_toolchain.bzl @@ -15,7 +15,6 @@ BSDTAR_PLATFORMS = { "@platforms//cpu:aarch64", ], ), - # TODO(alexeagle): download from libarchive github releases. "windows_amd64": struct( release_platform = "win64", compatible_with = [ @@ -30,6 +29,11 @@ BSDTAR_PLATFORMS = { ), } +WINDOWS_DEPS = ( + "e06f10043b1b148eb38ad06cff678af05beade0bdd2edd8735a198c521fa3993", + "https://github.com/libarchive/libarchive/releases/download/v3.7.2/libarchive-v3.7.2-amd64.zip", +) + # note, using Ubuntu Focal packages as they link with older glibc versions. # Ubuntu Jammy packages will fail on ubuntu 20.02 with # bsdtar: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found @@ -124,11 +128,18 @@ package(default_visibility = ["//visibility:public"]) rctx.file("BUILD.bazel", build_header + """tar_toolchain(name = "bsdtar_toolchain", binary = "tar")""") return + if repo_utils.is_windows(rctx): + rctx.download_and_extract( + url = WINDOWS_DEPS[1], + type = "zip", + sha256 = WINDOWS_DEPS[0], + ) + rctx.file("BUILD.bazel", build_header + """tar_toolchain(name = "bsdtar_toolchain", binary = "libarchive/bin/bsdtar.exe")""") + return + # Other platforms, we have more work to do. libs_dir = "usr/lib/x86_64-linux-gnu" if rctx.attr.platform.endswith("amd64") else "usr/lib/aarch64-linux-gnu" - # TODO: windows - for lib in LINUX_LIB_DEPS[rctx.attr.platform]: rctx.download_and_extract( url = lib[1], diff --git a/lib/tar.bzl b/lib/tar.bzl index 3c169f85c..172c07e1b 100644 --- a/lib/tar.bzl +++ b/lib/tar.bzl @@ -76,6 +76,7 @@ def tar(name, mtree = "auto", **kwargs): out = "{}.txt".format(mtree_target), # Ensure there's a trailing newline, as bsdtar will ignore a last line without one content = mtree + [""], + newline = "unix", ) else: mtree_target = mtree diff --git a/lib/testing.bzl b/lib/testing.bzl index 2f7d36cf1..f7317a0e2 100644 --- a/lib/testing.bzl +++ b/lib/testing.bzl @@ -1,8 +1,8 @@ "Helpers for making test assertions" load("@bazel_skylib//lib:types.bzl", "types") -load("@bazel_skylib//rules:diff_test.bzl", "diff_test") load("@bazel_skylib//rules:write_file.bzl", "write_file") +load("//lib:diff_test.bzl", "diff_test") load("//lib:jq.bzl", "jq") load("//lib:params_file.bzl", "params_file") load("//lib:utils.bzl", "default_timeout") diff --git a/lib/tests/copy_directory_bin_action/BUILD.bazel b/lib/tests/copy_directory_bin_action/BUILD.bazel index 1d8206456..f2ee76add 100644 --- a/lib/tests/copy_directory_bin_action/BUILD.bazel +++ b/lib/tests/copy_directory_bin_action/BUILD.bazel @@ -1,16 +1,25 @@ load("//lib:diff_test.bzl", "diff_test") load(":pkg.bzl", "pkg") +not_windows = select({ + # 2023/10/10 18:59:00 lstat lib\tests\copy_directory_bin_action\d\d\s1 failed: + # CreateFile .\1: The system cannot find the file specified. + "@platforms//os:windows": ["@platforms//:incompatible"], + "//conditions:default": [], +}) + pkg( name = "pkg", src = "d", out = "d2", + target_compatible_with = not_windows, ) pkg( name = "pkg2", src = "pkg", out = "d3", + target_compatible_with = not_windows, ) diff_test( diff --git a/lib/tests/copy_to_directory_bin_action/BUILD.bazel b/lib/tests/copy_to_directory_bin_action/BUILD.bazel index 29e2f0f4a..9fbc04594 100644 --- a/lib/tests/copy_to_directory_bin_action/BUILD.bazel +++ b/lib/tests/copy_to_directory_bin_action/BUILD.bazel @@ -45,8 +45,6 @@ pkg( ":tree_artifact", ], out = "pkg", - # RBE not happy with the symlinks in this test case - tags = ["no-remote"], target_compatible_with = select({ # D:/a/bazel-lib/bazel-lib/lib/tests/copy_to_directory_bin_action/BUILD.bazel:36:4: # declared output 'lib/tests/copy_to_directory_bin_action/pkg_symlink_0' is not a symlink diff --git a/lib/tests/coreutils/BUILD.bazel b/lib/tests/coreutils/BUILD.bazel index fdfa50127..6b81d0f0b 100644 --- a/lib/tests/coreutils/BUILD.bazel +++ b/lib/tests/coreutils/BUILD.bazel @@ -26,6 +26,10 @@ assert_contains( name = "test_sha256sum", actual = "sha256sum.txt", expected = """9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 lib/tests/coreutils/test.bin""", + target_compatible_with = select({ + "@platforms//os:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), ) genrule( @@ -40,6 +44,10 @@ assert_contains( name = "test_sha512sum", actual = "sha512sum.txt", expected = """ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff lib/tests/coreutils/test.bin""", + target_compatible_with = select({ + "@platforms//os:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), ) genrule( diff --git a/lib/tests/tar/BUILD.bazel b/lib/tests/tar/BUILD.bazel index 7435c1c14..84a281ccc 100644 --- a/lib/tests/tar/BUILD.bazel +++ b/lib/tests/tar/BUILD.bazel @@ -1,6 +1,6 @@ +load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test") load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar") load("@aspect_bazel_lib//lib:testing.bzl", "assert_archive_contains") -load("@bazel_skylib//rules:diff_test.bzl", "diff_test") load("@bazel_skylib//rules:write_file.bzl", "write_file") load(":asserts.bzl", "assert_tar_listing") @@ -19,6 +19,11 @@ genrule( ], outs = ["1.tar"], cmd = "$(BSDTAR_BIN) --create --dereference --file $@ -s '#$(BINDIR)##' $(execpath :fixture1) $(execpath src_file)", + target_compatible_with = select({ + # bsdtar.exe: -s is not supported by this version of bsdtar + "@platforms//os:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), toolchains = ["@bsd_tar_toolchains//:resolved_toolchain"], ) @@ -168,6 +173,12 @@ genrule( ./lib/tests/tar/cat_src_file ) > $@ """, + target_compatible_with = select({ + # requires runfiles tree, otherwise get + # ERROR: cannot find bazel_tools/tools/bash/runfiles/runfiles.bash + "@platforms//os:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), toolchains = ["@bsd_tar_toolchains//:resolved_toolchain"], ) diff --git a/lib/tests/tar/asserts.bzl b/lib/tests/tar/asserts.bzl index a3ce57e9f..ce416789c 100644 --- a/lib/tests/tar/asserts.bzl +++ b/lib/tests/tar/asserts.bzl @@ -1,7 +1,7 @@ "Make shorter assertions" -load("@bazel_skylib//rules:diff_test.bzl", "diff_test") load("@bazel_skylib//rules:write_file.bzl", "write_file") +load("//lib:diff_test.bzl", "diff_test") # buildifier: disable=function-docstring def assert_tar_listing(name, actual, expected): @@ -20,6 +20,7 @@ def assert_tar_listing(name, actual, expected): name = expected_listing, out = "_{}.expected".format(name), content = expected + [""], + newline = "unix", ) diff_test(