From 4ebf18c66246a108a6b025ff17e0a8c4bd4f2a28 Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Fri, 28 Jun 2024 20:27:29 -0400 Subject: [PATCH 01/10] update --- .gitattributes | 5 +++ bzlformat/private/BUILD.bazel | 1 + bzlformat/private/bzlformat_lint_test.bzl | 17 +++++++-- tests/bzlformat_tests/BUILD.bazel | 3 ++ .../release_artifact_tests/archive_test.sh | 37 +++++++++++++------ .../private/updatesrc_diff_and_update.bzl | 1 + 6 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..be75c150 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# The behavior of core.autocrlf=input is to force conversion to LF on addition +# into the repository and not to perform any conversion on checkout; that is, +# to always use LF endings regardless of the user's settings. This is set in +# .gitattributes as '* eol=lf' +* eol=lf diff --git a/bzlformat/private/BUILD.bazel b/bzlformat/private/BUILD.bazel index d650c520..db017cc3 100644 --- a/bzlformat/private/BUILD.bazel +++ b/bzlformat/private/BUILD.bazel @@ -20,6 +20,7 @@ bzl_library( ":bzlformat_format", "//bzllib:defs", "//updatesrc:defs", + "@aspect_bazel_lib//lib:windows_utils", "@bazel_skylib//rules:diff_test", ], ) diff --git a/bzlformat/private/bzlformat_lint_test.bzl b/bzlformat/private/bzlformat_lint_test.bzl index c836b3cd..fa361a37 100644 --- a/bzlformat/private/bzlformat_lint_test.bzl +++ b/bzlformat/private/bzlformat_lint_test.bzl @@ -1,5 +1,6 @@ """Definition for bzlformat_lint_test rule.""" +load("@aspect_bazel_lib//lib:windows_utils.bzl", "create_windows_native_launcher_script") load("@bazel_skylib//lib:shell.bzl", "shell") load("//shlib/rules:execute_binary.bzl", "execute_binary_utils") @@ -23,9 +24,9 @@ def _bzlformat_lint_test_impl(ctx): lint_test_names = [lt.short_path for lt in lint_tests] # Write a script that executes all of the lint tests - out = ctx.actions.declare_file(ctx.label.name + ".sh") + bash_launcher = ctx.actions.declare_file(ctx.label.name + ".sh") ctx.actions.write( - output = out, + output = bash_launcher, is_executable = True, content = """\ #!/usr/bin/env bash @@ -55,15 +56,19 @@ echo "All tests succeeded!" """, ) + is_windows = ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) + launcher = create_windows_native_launcher_script(ctx, bash_launcher) if is_windows else bash_launcher + extra_runfiles = [bash_launcher] if is_windows else [] + # Gather the runfiles - runfiles = ctx.runfiles(files = ctx.files.srcs + lint_tests) + runfiles = ctx.runfiles(files = ctx.files.srcs + lint_tests + extra_runfiles) runfiles = execute_binary_utils.collect_runfiles( runfiles, [ctx.attr._buildifier], ) # Return the DefaultInfo - return DefaultInfo(executable = out, runfiles = runfiles) + return DefaultInfo(executable = launcher, runfiles = runfiles) bzlformat_lint_test = rule( implementation = _bzlformat_lint_test_impl, @@ -85,6 +90,10 @@ bzlformat_lint_test = rule( allow_files = True, doc = "The `buildifier` script that executes the formatting.", ), + "_windows_constraint": attr.label(default = "@platforms//os:windows"), }, + toolchains = [ + "@bazel_tools//tools/sh:toolchain_type", + ], doc = "Lints the specified Starlark files using Buildifier.", ) diff --git a/tests/bzlformat_tests/BUILD.bazel b/tests/bzlformat_tests/BUILD.bazel index e7d4ed41..a547de19 100644 --- a/tests/bzlformat_tests/BUILD.bazel +++ b/tests/bzlformat_tests/BUILD.bazel @@ -53,6 +53,7 @@ _FORMAT_INFOS = [ name = fi[0] + "_bzl", out = fi[0] + ".bzl", content = fi[1], + newline = "unix", ) for fi in _FORMAT_INFOS ] @@ -64,11 +65,13 @@ bzlformat_format( ) # Write the expected content +# buildifier writes unix newlines; match that [ write_file( name = fi[0] + "_bzl_expected", out = fi[0] + ".bzl.expected", content = fi[2], + newline = "unix", ) for fi in _FORMAT_INFOS ] diff --git a/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh b/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh index 77d08b8b..569bd0c5 100755 --- a/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh +++ b/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh @@ -5,12 +5,12 @@ set -uo pipefail set +e f=bazel_tools/tools/bash/runfiles/runfiles.bash -source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || - source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || - source "$0.runfiles/$f" 2>/dev/null || - source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || - source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || - { +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null \ + || source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null \ + || source "$0.runfiles/$f" 2>/dev/null \ + || source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null \ + || source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null \ + || { echo >&2 "ERROR: ${BASH_SOURCE[0]} cannot find $f" exit 1 } @@ -18,21 +18,34 @@ f= set -e # --- end runfiles.bash initialization v3 --- +# return a unix-style path on all platforms +# workaround for https://github.com/bazelbuild/bazel/issues/22803 +function rlocation_as_unix() { + path=$(rlocation ${1}) + case "$(uname -s)" in + CYGWIN* | MINGW32* | MSYS* | MINGW*) + path=${path//\\//} # backslashes to forward + path=/${path//:/} # d:/ to /d/ + ;; + esac + echo $path +} + # MARK - Locate Deps assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh -assertions_sh="$(rlocation "${assertions_sh_location}")" || - (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +assertions_sh="$(rlocation_as_unix "${assertions_sh_location}")" \ + || (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) # shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" archive_tar_gz_location=cgrindel_bazel_starlib/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive.tar.gz -archive_tar_gz="$(rlocation "${archive_tar_gz_location}")" || - (echo >&2 "Failed to locate ${archive_tar_gz_location}" && exit 1) +archive_tar_gz="$(rlocation_as_unix "${archive_tar_gz_location}")" \ + || (echo >&2 "Failed to locate ${archive_tar_gz_location}" && exit 1) tar_exe_location=cgrindel_bazel_starlib/tools/tar/tar.exe -tar="$(rlocation "${tar_exe_location}")" || - (echo >&2 "Failed to locate ${tar_exe_location}" && exit 1) +tar="$(rlocation "${tar_exe_location}")" \ + || (echo >&2 "Failed to locate ${tar_exe_location}" && exit 1) # MARK - Test diff --git a/updatesrc/private/updatesrc_diff_and_update.bzl b/updatesrc/private/updatesrc_diff_and_update.bzl index a1df9b22..b55e292b 100644 --- a/updatesrc/private/updatesrc_diff_and_update.bzl +++ b/updatesrc/private/updatesrc_diff_and_update.bzl @@ -72,6 +72,7 @@ def updatesrc_diff_and_update( name = diff_test_prefix + src_name + diff_test_suffix, file1 = src, file2 = out, + file2_to_lf = True, visibility = diff_test_visibility, failure_message = msg, **kwargs From b1b683f1e3e22c7b7cf9e3328439beaa2d739217 Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Fri, 28 Jun 2024 20:27:37 -0400 Subject: [PATCH 02/10] update --- .bazelrc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.bazelrc b/.bazelrc index e15d307f..6d87bf04 100644 --- a/.bazelrc +++ b/.bazelrc @@ -21,6 +21,13 @@ build:ci --//build:execution_env=ci common --enable_bzlmod build --@cgrindel_bazel_starlib//bzlmod:enabled +# windows stuff +startup --windows_enable_symlinks +common --enable_runfiles +common --override_module=bazel_skylib=d:\\workdir\\github\\bazel-skylib +#common --override_module=aspect_bazel_lib=d:\\workdir\\bazel-lib2 +common --test_env=BAZEL_SH + # Try to import a local.rc file; typically, written by CI try-import %workspace%/local.bazelrc From 5b1da72cc3ff1ed3f48b67792b5e7c70d18f3dd7 Mon Sep 17 00:00:00 2001 From: Chris Brown <77508021+peakschris@users.noreply.github.com> Date: Sat, 29 Jun 2024 06:10:30 -0400 Subject: [PATCH 03/10] add comment --- updatesrc/private/updatesrc_diff_and_update.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/updatesrc/private/updatesrc_diff_and_update.bzl b/updatesrc/private/updatesrc_diff_and_update.bzl index b55e292b..b7929d94 100644 --- a/updatesrc/private/updatesrc_diff_and_update.bzl +++ b/updatesrc/private/updatesrc_diff_and_update.bzl @@ -63,16 +63,16 @@ def updatesrc_diff_and_update( src = srcs[idx] out = outs[idx] src_name = src.replace("/", "_") - if failure_message == None: # create a helpful message if none has been given msg = "Run 'bazel run {}' to update {}".format(name, src) + # this difftest fails as file2 has CRLf on windows + # fix: https://github.com/bazelbuild/bazel-skylib/pull/527 diff_test( name = diff_test_prefix + src_name + diff_test_suffix, file1 = src, file2 = out, - file2_to_lf = True, visibility = diff_test_visibility, failure_message = msg, **kwargs From 715661495dd5c83678b50ddc2a4ab776a143c2ec Mon Sep 17 00:00:00 2001 From: Chris Brown <77508021+peakschris@users.noreply.github.com> Date: Sat, 29 Jun 2024 06:14:29 -0400 Subject: [PATCH 04/10] update bazelrc --- .bazelrc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.bazelrc b/.bazelrc index 6d87bf04..f74c440e 100644 --- a/.bazelrc +++ b/.bazelrc @@ -7,7 +7,7 @@ build --deleted_packages=examples/bzlformat/simple,examples/bzlformat/simple/moc query --deleted_packages=examples/bzlformat/simple,examples/bzlformat/simple/mockascript,examples/bzlformat/simple/mockascript/internal,examples/bzlmod_e2e,examples/bzlmod_e2e/header,examples/bzlmod_e2e/mockascript,examples/bzlmod_e2e/mockascript/internal,examples/bzlmod_e2e/srcs/Bar,examples/bzlmod_e2e/srcs/Foo,examples/markdown/simple,examples/markdown/simple/bar,examples/tools/workspace,examples/updatesrc/simple,examples/updatesrc/simple/header,examples/updatesrc/simple/srcs/Bar,examples/updatesrc/simple/srcs/Foo,tests/bzlformat_tests/tools_tests/missing_pkgs_tests/workspace,tests/bzlformat_tests/tools_tests/missing_pkgs_tests/workspace/foo,tests/bzlformat_tests/tools_tests/missing_pkgs_tests/workspace/foo/bar,tests/bzltidy_tests/workspace,tests/bzltidy_tests/workspace/child_workspaces/bar,tests/bzltidy_tests/workspace/child_workspaces/foo,tests/updatesrc_tests/workspace/diff_and_update_test,tests/updatesrc_tests/workspace/diff_and_update_test/with_custom_values,tests/updatesrc_tests/workspace/diff_and_update_test/with_defaults,tests/updatesrc_tests/workspace/letters # Import Shared settings -import %workspace%/shared.bazelrc +import %workspace%/shared.bazelrc# # Import CI settings. import %workspace%/ci.bazelrc @@ -21,12 +21,8 @@ build:ci --//build:execution_env=ci common --enable_bzlmod build --@cgrindel_bazel_starlib//bzlmod:enabled -# windows stuff +# windows requires symlinks to work well startup --windows_enable_symlinks -common --enable_runfiles -common --override_module=bazel_skylib=d:\\workdir\\github\\bazel-skylib -#common --override_module=aspect_bazel_lib=d:\\workdir\\bazel-lib2 -common --test_env=BAZEL_SH # Try to import a local.rc file; typically, written by CI try-import %workspace%/local.bazelrc From 6b2da04fd47840062bcbd1f5621f69769bad36c1 Mon Sep 17 00:00:00 2001 From: Chris Brown <77508021+peakschris@users.noreply.github.com> Date: Sat, 29 Jun 2024 06:15:41 -0400 Subject: [PATCH 05/10] fix typo --- .bazelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index f74c440e..509fa178 100644 --- a/.bazelrc +++ b/.bazelrc @@ -7,7 +7,7 @@ build --deleted_packages=examples/bzlformat/simple,examples/bzlformat/simple/moc query --deleted_packages=examples/bzlformat/simple,examples/bzlformat/simple/mockascript,examples/bzlformat/simple/mockascript/internal,examples/bzlmod_e2e,examples/bzlmod_e2e/header,examples/bzlmod_e2e/mockascript,examples/bzlmod_e2e/mockascript/internal,examples/bzlmod_e2e/srcs/Bar,examples/bzlmod_e2e/srcs/Foo,examples/markdown/simple,examples/markdown/simple/bar,examples/tools/workspace,examples/updatesrc/simple,examples/updatesrc/simple/header,examples/updatesrc/simple/srcs/Bar,examples/updatesrc/simple/srcs/Foo,tests/bzlformat_tests/tools_tests/missing_pkgs_tests/workspace,tests/bzlformat_tests/tools_tests/missing_pkgs_tests/workspace/foo,tests/bzlformat_tests/tools_tests/missing_pkgs_tests/workspace/foo/bar,tests/bzltidy_tests/workspace,tests/bzltidy_tests/workspace/child_workspaces/bar,tests/bzltidy_tests/workspace/child_workspaces/foo,tests/updatesrc_tests/workspace/diff_and_update_test,tests/updatesrc_tests/workspace/diff_and_update_test/with_custom_values,tests/updatesrc_tests/workspace/diff_and_update_test/with_defaults,tests/updatesrc_tests/workspace/letters # Import Shared settings -import %workspace%/shared.bazelrc# +import %workspace%/shared.bazelrc # Import CI settings. import %workspace%/ci.bazelrc From a5d1388378e762548373f94c11b3934803adfcad Mon Sep 17 00:00:00 2001 From: Chris Brown <77508021+peakschris@users.noreply.github.com> Date: Sat, 29 Jun 2024 07:57:23 -0400 Subject: [PATCH 06/10] runfiles on by default on windows --- .bazelrc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.bazelrc b/.bazelrc index 509fa178..e730e9b0 100644 --- a/.bazelrc +++ b/.bazelrc @@ -24,6 +24,10 @@ build --@cgrindel_bazel_starlib//bzlmod:enabled # windows requires symlinks to work well startup --windows_enable_symlinks +# this library requires runfiles for the bzlformat_lint_test +# but this is off by default on windows. Switch it on. +common --enable_runfiles + # Try to import a local.rc file; typically, written by CI try-import %workspace%/local.bazelrc From ab5eac6d7e219211dc1273f93ed10a4ac6934455 Mon Sep 17 00:00:00 2001 From: Chris Brown <77508021+peakschris@users.noreply.github.com> Date: Sat, 29 Jun 2024 14:09:39 -0400 Subject: [PATCH 07/10] remove debug code --- .../rules_tests/release_artifact_tests/archive_test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh b/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh index 569bd0c5..d355c904 100755 --- a/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh +++ b/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh @@ -21,14 +21,14 @@ set -e # return a unix-style path on all platforms # workaround for https://github.com/bazelbuild/bazel/issues/22803 function rlocation_as_unix() { - path=$(rlocation ${1}) + path="$(rlocation ${1})" case "$(uname -s)" in CYGWIN* | MINGW32* | MSYS* | MINGW*) path=${path//\\//} # backslashes to forward path=/${path//:/} # d:/ to /d/ ;; esac - echo $path + echo "$path" } # MARK - Locate Deps From 4523048cf587d29ce2660ebdafac8a138a5118ed Mon Sep 17 00:00:00 2001 From: Chris Brown <77508021+peakschris@users.noreply.github.com> Date: Mon, 1 Jul 2024 11:54:47 -0400 Subject: [PATCH 08/10] add aspect_bazel_lib to workspace snippets --- README.md | 4 ++++ deps.bzl | 8 ++++++++ release/workspace_snippet.tmpl | 4 ++++ .../tools_tests/missing_pkgs_tests/workspace/WORKSPACE | 4 ++++ .../generate_release_notes_tests/workspace_snippet.tmpl | 4 ++++ .../workspace_snippet.tmpl | 4 ++++ .../update_readme_tests/workspace_snippet.tmpl | 4 ++++ tests/bzlrelease_tests/tools_tests/workspace_snippet.tmpl | 4 ++++ tests/updatesrc_tests/workspace/WORKSPACE | 4 ++++ 9 files changed, 40 insertions(+) diff --git a/README.md b/README.md index 91fe7838..bbdfd062 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,10 @@ bazel_starlib_dependencies() load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() + +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") + +aspect_bazel_lib_dependencies() ``` diff --git a/deps.bzl b/deps.bzl index 11dcdc04..0f56d72b 100644 --- a/deps.bzl +++ b/deps.bzl @@ -59,5 +59,13 @@ def bazel_starlib_dependencies(): ], ) + maybe( + http_archive, + name = "aspect_bazel_lib", + sha256 = "4b32cf6feab38b887941db022020eea5a49b848e11e3d6d4d18433594951717a", + strip_prefix = "bazel-lib-2.0.1", + url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.0.1/bazel-lib-v2.0.1.tar.gz", + ) + _bazeldoc_dependencies() _prebuilt_buildtools_dependencies() diff --git a/release/workspace_snippet.tmpl b/release/workspace_snippet.tmpl index 1c706977..0b82c89c 100644 --- a/release/workspace_snippet.tmpl +++ b/release/workspace_snippet.tmpl @@ -9,3 +9,7 @@ bazel_starlib_dependencies() load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() + +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") + +aspect_bazel_lib_dependencies() diff --git a/tests/bzlformat_tests/tools_tests/missing_pkgs_tests/workspace/WORKSPACE b/tests/bzlformat_tests/tools_tests/missing_pkgs_tests/workspace/WORKSPACE index 93aa2826..0f478a93 100644 --- a/tests/bzlformat_tests/tools_tests/missing_pkgs_tests/workspace/WORKSPACE +++ b/tests/bzlformat_tests/tools_tests/missing_pkgs_tests/workspace/WORKSPACE @@ -13,6 +13,10 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") + +aspect_bazel_lib_dependencies() + # Buildifier Dependencies load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps") diff --git a/tests/bzlrelease_tests/rules_tests/generate_release_notes_tests/workspace_snippet.tmpl b/tests/bzlrelease_tests/rules_tests/generate_release_notes_tests/workspace_snippet.tmpl index d71cbe48..3003868b 100644 --- a/tests/bzlrelease_tests/rules_tests/generate_release_notes_tests/workspace_snippet.tmpl +++ b/tests/bzlrelease_tests/rules_tests/generate_release_notes_tests/workspace_snippet.tmpl @@ -13,3 +13,7 @@ bazel_skylib_workspace() load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") stardoc_repositories() + +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") + +aspect_bazel_lib_dependencies() diff --git a/tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests/workspace_snippet.tmpl b/tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests/workspace_snippet.tmpl index d71cbe48..3003868b 100644 --- a/tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests/workspace_snippet.tmpl +++ b/tests/bzlrelease_tests/rules_tests/generate_workspace_snippet_tests/workspace_snippet.tmpl @@ -13,3 +13,7 @@ bazel_skylib_workspace() load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") stardoc_repositories() + +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") + +aspect_bazel_lib_dependencies() diff --git a/tests/bzlrelease_tests/rules_tests/update_readme_tests/workspace_snippet.tmpl b/tests/bzlrelease_tests/rules_tests/update_readme_tests/workspace_snippet.tmpl index d71cbe48..3003868b 100644 --- a/tests/bzlrelease_tests/rules_tests/update_readme_tests/workspace_snippet.tmpl +++ b/tests/bzlrelease_tests/rules_tests/update_readme_tests/workspace_snippet.tmpl @@ -13,3 +13,7 @@ bazel_skylib_workspace() load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") stardoc_repositories() + +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") + +aspect_bazel_lib_dependencies() diff --git a/tests/bzlrelease_tests/tools_tests/workspace_snippet.tmpl b/tests/bzlrelease_tests/tools_tests/workspace_snippet.tmpl index d71cbe48..3003868b 100644 --- a/tests/bzlrelease_tests/tools_tests/workspace_snippet.tmpl +++ b/tests/bzlrelease_tests/tools_tests/workspace_snippet.tmpl @@ -13,3 +13,7 @@ bazel_skylib_workspace() load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") stardoc_repositories() + +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") + +aspect_bazel_lib_dependencies() diff --git a/tests/updatesrc_tests/workspace/WORKSPACE b/tests/updatesrc_tests/workspace/WORKSPACE index 62c90b15..4b9b0047 100644 --- a/tests/updatesrc_tests/workspace/WORKSPACE +++ b/tests/updatesrc_tests/workspace/WORKSPACE @@ -12,3 +12,7 @@ bazel_starlib_dependencies() load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() + +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") + +aspect_bazel_lib_dependencies() From bc0e3a32fda737a74d2c0291ba859a8c510550ce Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sat, 10 Jan 2026 15:21:32 -0700 Subject: [PATCH 09/10] fix: formatting --- bzlformat/private/bzlformat_lint_test.bzl | 27 ++++++++++++++----- .../private/updatesrc_diff_and_update.bzl | 1 + 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/bzlformat/private/bzlformat_lint_test.bzl b/bzlformat/private/bzlformat_lint_test.bzl index fa361a37..84d01199 100644 --- a/bzlformat/private/bzlformat_lint_test.bzl +++ b/bzlformat/private/bzlformat_lint_test.bzl @@ -1,6 +1,9 @@ """Definition for bzlformat_lint_test rule.""" -load("@aspect_bazel_lib//lib:windows_utils.bzl", "create_windows_native_launcher_script") +load( + "@aspect_bazel_lib//lib:windows_utils.bzl", + "create_windows_native_launcher_script", +) load("@bazel_skylib//lib:shell.bzl", "shell") load("//shlib/rules:execute_binary.bzl", "execute_binary_utils") @@ -11,7 +14,9 @@ def _bzlformat_lint_test_impl(ctx): # Generate the lint tests lint_tests = [] for src in ctx.files.srcs: - exec_binary_out = ctx.actions.declare_file(ctx.label.name + "_" + src.basename + ".sh") + exec_binary_out = ctx.actions.declare_file( + ctx.label.name + "_" + src.basename + ".sh", + ) lint_tests.append(exec_binary_out) arguments = common_arguments + [src.short_path] execute_binary_utils.write_execute_binary_script( @@ -46,22 +51,30 @@ for lint_test in "${lint_tests[@]}"; do exit_code=0 "${lint_test}" || exit_code=$? if [[ ${exit_code} != 0 ]]; then - failure_count=$(( ${failure_count} + 1 )) + failure_count=$(( ${failure_count} + 1 )) echo >&2 "${lint_test} failed with ${exit_code}." fi done -[[ ${failure_count} > 0 ]] && echo >&2 "${failure_count} lint tests failed." && exit 1 +[[ ${failure_count} > 0 ]] && echo >&2 "${failure_count} lint tests failed." \ + && exit 1 echo "All tests succeeded!" """, ) - is_windows = ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) - launcher = create_windows_native_launcher_script(ctx, bash_launcher) if is_windows else bash_launcher + is_windows = ctx.target_platform_has_constraint( + ctx.attr._windows_constraint[platform_common.ConstraintValueInfo], + ) + if is_windows: + launcher = create_windows_native_launcher_script(ctx, bash_launcher) + else: + launcher = bash_launcher extra_runfiles = [bash_launcher] if is_windows else [] # Gather the runfiles - runfiles = ctx.runfiles(files = ctx.files.srcs + lint_tests + extra_runfiles) + runfiles = ctx.runfiles( + files = ctx.files.srcs + lint_tests + extra_runfiles, + ) runfiles = execute_binary_utils.collect_runfiles( runfiles, [ctx.attr._buildifier], diff --git a/updatesrc/private/updatesrc_diff_and_update.bzl b/updatesrc/private/updatesrc_diff_and_update.bzl index b7929d94..37db1a13 100644 --- a/updatesrc/private/updatesrc_diff_and_update.bzl +++ b/updatesrc/private/updatesrc_diff_and_update.bzl @@ -63,6 +63,7 @@ def updatesrc_diff_and_update( src = srcs[idx] out = outs[idx] src_name = src.replace("/", "_") + if failure_message == None: # create a helpful message if none has been given msg = "Run 'bazel run {}' to update {}".format(name, src) From 1e8b100f6394f9deb53d6958774ed8b6796200d1 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sat, 10 Jan 2026 15:40:58 -0700 Subject: [PATCH 10/10] chore: ran tidy --- .../release_artifact_tests/archive_test.sh | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh b/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh index d355c904..6be02770 100755 --- a/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh +++ b/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive_test.sh @@ -5,12 +5,12 @@ set -uo pipefail set +e f=bazel_tools/tools/bash/runfiles/runfiles.bash -source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null \ - || source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null \ - || source "$0.runfiles/$f" 2>/dev/null \ - || source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null \ - || source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null \ - || { +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || + source "$0.runfiles/$f" 2>/dev/null || + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || + { echo >&2 "ERROR: ${BASH_SOURCE[0]} cannot find $f" exit 1 } @@ -23,10 +23,10 @@ set -e function rlocation_as_unix() { path="$(rlocation ${1})" case "$(uname -s)" in - CYGWIN* | MINGW32* | MSYS* | MINGW*) - path=${path//\\//} # backslashes to forward - path=/${path//:/} # d:/ to /d/ - ;; + CYGWIN* | MINGW32* | MSYS* | MINGW*) + path=${path//\\//} # backslashes to forward + path=/${path//:/} # d:/ to /d/ + ;; esac echo "$path" } @@ -34,18 +34,18 @@ function rlocation_as_unix() { # MARK - Locate Deps assertions_sh_location=cgrindel_bazel_starlib/shlib/lib/assertions.sh -assertions_sh="$(rlocation_as_unix "${assertions_sh_location}")" \ - || (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) +assertions_sh="$(rlocation_as_unix "${assertions_sh_location}")" || + (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) # shellcheck source=SCRIPTDIR/../../../../shlib/lib/assertions.sh source "${assertions_sh}" archive_tar_gz_location=cgrindel_bazel_starlib/tests/bzlrelease_tests/rules_tests/release_artifact_tests/archive.tar.gz -archive_tar_gz="$(rlocation_as_unix "${archive_tar_gz_location}")" \ - || (echo >&2 "Failed to locate ${archive_tar_gz_location}" && exit 1) +archive_tar_gz="$(rlocation_as_unix "${archive_tar_gz_location}")" || + (echo >&2 "Failed to locate ${archive_tar_gz_location}" && exit 1) tar_exe_location=cgrindel_bazel_starlib/tools/tar/tar.exe -tar="$(rlocation "${tar_exe_location}")" \ - || (echo >&2 "Failed to locate ${tar_exe_location}" && exit 1) +tar="$(rlocation "${tar_exe_location}")" || + (echo >&2 "Failed to locate ${tar_exe_location}" && exit 1) # MARK - Test