chore: add windows binaries (#610)

* chore: add windows binaries

* chore: fix/exclude windows brokenness

* chore: try to see why diff tests fail on windows

* fix: rm bazelisk rc again for windows

* fix: try our own diff_test

* chore: use only our own diff_test
This commit is contained in:
Alex Eagle 2023-10-10 14:13:17 -07:00 committed by GitHub
parent 177b883991
commit eda4929c72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 61 additions and 20 deletions

View File

@ -1,2 +0,0 @@
BAZELISK_BASE_URL=https://github.com/aspect-build/aspect-cli/releases/download
USE_BAZEL_VERSION=aspect/5.7.2

View File

@ -103,16 +103,6 @@ jobs:
# Don't test Windows with Bazel 7 to minimize Windows minutes (billed at 2X) # Don't test Windows with Bazel 7 to minimize Windows minutes (billed at 2X)
- bazelversion: 7.0.0-pre.20230530.3 - bazelversion: 7.0.0-pre.20230530.3
os: windows-latest 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 represent a sequence of tasks that will be executed as part of the job
steps: steps:

View File

@ -238,11 +238,11 @@ bzl_library(
name = "testing", name = "testing",
srcs = ["testing.bzl"], srcs = ["testing.bzl"],
deps = [ deps = [
":diff_test",
":jq", ":jq",
":params_file", ":params_file",
":utils", ":utils",
"@bazel_skylib//lib:types", "@bazel_skylib//lib:types",
"@bazel_skylib//rules:diff_test",
"@bazel_skylib//rules:write_file", "@bazel_skylib//rules:write_file",
], ],
) )

View File

@ -292,6 +292,12 @@ bzl_library(
visibility = ["//lib:__subpackages__"], visibility = ["//lib:__subpackages__"],
) )
bzl_library(
name = "extension_utils",
srcs = ["extension_utils.bzl"],
visibility = ["//lib:__subpackages__"],
)
bzl_library( bzl_library(
name = "glob_match", name = "glob_match",
srcs = ["glob_match.bzl"], srcs = ["glob_match.bzl"],

View File

@ -15,7 +15,6 @@ BSDTAR_PLATFORMS = {
"@platforms//cpu:aarch64", "@platforms//cpu:aarch64",
], ],
), ),
# TODO(alexeagle): download from libarchive github releases.
"windows_amd64": struct( "windows_amd64": struct(
release_platform = "win64", release_platform = "win64",
compatible_with = [ 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. # note, using Ubuntu Focal packages as they link with older glibc versions.
# Ubuntu Jammy packages will fail on ubuntu 20.02 with # 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 # 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")""") rctx.file("BUILD.bazel", build_header + """tar_toolchain(name = "bsdtar_toolchain", binary = "tar")""")
return 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. # 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" 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]: for lib in LINUX_LIB_DEPS[rctx.attr.platform]:
rctx.download_and_extract( rctx.download_and_extract(
url = lib[1], url = lib[1],

View File

@ -76,6 +76,7 @@ def tar(name, mtree = "auto", **kwargs):
out = "{}.txt".format(mtree_target), out = "{}.txt".format(mtree_target),
# Ensure there's a trailing newline, as bsdtar will ignore a last line without one # Ensure there's a trailing newline, as bsdtar will ignore a last line without one
content = mtree + [""], content = mtree + [""],
newline = "unix",
) )
else: else:
mtree_target = mtree mtree_target = mtree

View File

@ -1,8 +1,8 @@
"Helpers for making test assertions" "Helpers for making test assertions"
load("@bazel_skylib//lib:types.bzl", "types") 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("@bazel_skylib//rules:write_file.bzl", "write_file")
load("//lib:diff_test.bzl", "diff_test")
load("//lib:jq.bzl", "jq") load("//lib:jq.bzl", "jq")
load("//lib:params_file.bzl", "params_file") load("//lib:params_file.bzl", "params_file")
load("//lib:utils.bzl", "default_timeout") load("//lib:utils.bzl", "default_timeout")

View File

@ -1,16 +1,25 @@
load("//lib:diff_test.bzl", "diff_test") load("//lib:diff_test.bzl", "diff_test")
load(":pkg.bzl", "pkg") 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( pkg(
name = "pkg", name = "pkg",
src = "d", src = "d",
out = "d2", out = "d2",
target_compatible_with = not_windows,
) )
pkg( pkg(
name = "pkg2", name = "pkg2",
src = "pkg", src = "pkg",
out = "d3", out = "d3",
target_compatible_with = not_windows,
) )
diff_test( diff_test(

View File

@ -43,6 +43,12 @@ pkg(
":tree_artifact", ":tree_artifact",
], ],
out = "pkg", out = "pkg",
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
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
use_declare_symlink = select({ use_declare_symlink = select({
"//lib/tests:experimental_allow_unresolved_symlinks": True, "//lib/tests:experimental_allow_unresolved_symlinks": True,
"//conditions:default": False, "//conditions:default": False,

View File

@ -26,6 +26,10 @@ assert_contains(
name = "test_sha256sum", name = "test_sha256sum",
actual = "sha256sum.txt", actual = "sha256sum.txt",
expected = """9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 lib/tests/coreutils/test.bin""", expected = """9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 lib/tests/coreutils/test.bin""",
target_compatible_with = select({
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
) )
genrule( genrule(
@ -40,6 +44,10 @@ assert_contains(
name = "test_sha512sum", name = "test_sha512sum",
actual = "sha512sum.txt", actual = "sha512sum.txt",
expected = """ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff lib/tests/coreutils/test.bin""", expected = """ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff lib/tests/coreutils/test.bin""",
target_compatible_with = select({
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
) )
genrule( genrule(

View File

@ -1,7 +1,7 @@
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:tar.bzl", "mtree_spec", "tar")
load("@aspect_bazel_lib//lib:testing.bzl", "assert_archive_contains") load("@aspect_bazel_lib//lib:testing.bzl", "assert_archive_contains")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file") load("@bazel_skylib//rules:write_file.bzl", "write_file")
load(":asserts.bzl", "assert_tar_listing") load(":asserts.bzl", "assert_tar_listing")
@ -20,6 +20,11 @@ genrule(
], ],
outs = ["1.tar"], outs = ["1.tar"],
cmd = "$(BSDTAR_BIN) --create --dereference --file $@ -s '#$(BINDIR)##' $(execpath :fixture1) $(execpath src_file)", 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"], toolchains = ["@bsd_tar_toolchains//:resolved_toolchain"],
) )
@ -149,7 +154,7 @@ bzl_library(
srcs = ["asserts.bzl"], srcs = ["asserts.bzl"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"@bazel_skylib//rules:diff_test", "//lib:diff_test",
"@bazel_skylib//rules:write_file", "@bazel_skylib//rules:write_file",
], ],
) )
@ -179,6 +184,12 @@ genrule(
./lib/tests/tar/cat_src_file ./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"], toolchains = ["@bsd_tar_toolchains//:resolved_toolchain"],
) )

View File

@ -1,7 +1,7 @@
"Make shorter assertions" "Make shorter assertions"
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file") load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("//lib:diff_test.bzl", "diff_test")
# buildifier: disable=function-docstring # buildifier: disable=function-docstring
def assert_tar_listing(name, actual, expected): def assert_tar_listing(name, actual, expected):
@ -20,6 +20,7 @@ def assert_tar_listing(name, actual, expected):
name = expected_listing, name = expected_listing,
out = "_{}.expected".format(name), out = "_{}.expected".format(name),
content = expected + [""], content = expected + [""],
newline = "unix",
) )
diff_test( diff_test(