diff --git a/.aspect/workflows/terraform/workflows.tf b/.aspect/workflows/terraform/workflows.tf index 53616bd..4af3803 100644 --- a/.aspect/workflows/terraform/workflows.tf +++ b/.aspect/workflows/terraform/workflows.tf @@ -42,7 +42,7 @@ module "aspect_workflows" { # Warming set definitions warming_sets = { - default = {} + default = {} } # Resource types for use by runner groups @@ -67,7 +67,7 @@ module "aspect_workflows" { min_runners = 0 resource_type = "default" scale_out_factor = 7 - scaling_polling_frequency = 3 # check for queued jobs every 20s + scaling_polling_frequency = 3 # check for queued jobs every 20s warming = true } # The warming runner group is used for the periodic warming job that creates diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b9a948f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,3 @@ +[*.sh] +indent_style = space +indent_size = 2 diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh index 4215028..01c2c45 100755 --- a/.github/workflows/release_prep.sh +++ b/.github/workflows/release_prep.sh @@ -12,10 +12,10 @@ PREFIX="bazel-lib-${TAG:1}" ARCHIVE="bazel-lib-$TAG.tar.gz" # NB: configuration for 'git archive' is in /.gitattributes -git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE +git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip >$ARCHIVE SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') -cat << EOF +cat </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: cannot find $f"; exit 1; }; f=; set -e +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 || + { + echo >&2 "ERROR: cannot find $f" + exit 1 + } +f= +set -e # --- end runfiles.bash initialization v2 --- # Read external directory and make sure it exists with a file. diff --git a/e2e/run_jq_symlinked_bin.sh b/e2e/run_jq_symlinked_bin.sh index f9613cf..1f7e086 100755 --- a/e2e/run_jq_symlinked_bin.sh +++ b/e2e/run_jq_symlinked_bin.sh @@ -4,12 +4,11 @@ set -o errexit -o nounset -o pipefail BZLMOD_FLAG="${BZLMOD_FLAG:-}" case "$(uname -s)" in - CYGWIN*|MINGW32*|MSYS*|MINGW*) - bazel run $BZLMOD_FLAG @jq//:jq.exe -- --null-input .a=5 - ;; +CYGWIN* | MINGW32* | MSYS* | MINGW*) + bazel run $BZLMOD_FLAG @jq//:jq.exe -- --null-input .a=5 + ;; - *) - bazel run $BZLMOD_FLAG @jq//:jq -- --null-input .a=5 - ;; +*) + bazel run $BZLMOD_FLAG @jq//:jq -- --null-input .a=5 + ;; esac - diff --git a/e2e/run_yq_symlinked_bin.sh b/e2e/run_yq_symlinked_bin.sh index a3fb7b9..ad006af 100755 --- a/e2e/run_yq_symlinked_bin.sh +++ b/e2e/run_yq_symlinked_bin.sh @@ -4,11 +4,11 @@ set -o errexit -o nounset -o pipefail BZLMOD_FLAG="${BZLMOD_FLAG:-}" case "$(uname -s)" in - CYGWIN*|MINGW32*|MSYS*|MINGW*) - bazel run $BZLMOD_FLAG @yq//:yq.exe -- --null-input .a=5 - ;; +CYGWIN* | MINGW32* | MSYS* | MINGW*) + bazel run $BZLMOD_FLAG @yq//:yq.exe -- --null-input .a=5 + ;; - *) - bazel run $BZLMOD_FLAG @yq//:yq -- --null-input .a=5 - ;; +*) + bazel run $BZLMOD_FLAG @yq//:yq -- --null-input .a=5 + ;; esac diff --git a/e2e/write_source_files_symlinks.sh b/e2e/write_source_files_symlinks.sh index cc35d44..9953a84 100755 --- a/e2e/write_source_files_symlinks.sh +++ b/e2e/write_source_files_symlinks.sh @@ -4,35 +4,35 @@ set -o errexit -o nounset -o pipefail BZLMOD_FLAG="${BZLMOD_FLAG:-}" function run_test { - bazel run $BZLMOD_FLAG //lib/tests/write_source_files:write_symlinks + bazel run $BZLMOD_FLAG //lib/tests/write_source_files:write_symlinks - local expected_out="lib/tests/write_source_files/symlink_test/a/test.txt" - if [ ! -e "$expected_out" ]; then - echo "ERROR: expected $expected_out to exist" - exit 1 - fi - if [ -x "$expected_out" ]; then - echo "ERROR: expected $expected_out to not be executable" - exit 1 - fi - if [ -L "$expected_out" ]; then - echo "ERROR: expected $expected_out to not be a symlink" - exit 1 - fi + local expected_out="lib/tests/write_source_files/symlink_test/a/test.txt" + if [ ! -e "$expected_out" ]; then + echo "ERROR: expected $expected_out to exist" + exit 1 + fi + if [ -x "$expected_out" ]; then + echo "ERROR: expected $expected_out to not be executable" + exit 1 + fi + if [ -L "$expected_out" ]; then + echo "ERROR: expected $expected_out to not be a symlink" + exit 1 + fi - local expected_out="lib/tests/write_source_files/symlink_test/b/test.txt" - if [ ! -e "$expected_out" ]; then - echo "ERROR: expected $expected_out to exist" - exit 1 - fi - if [ -x "$expected_out" ]; then - echo "ERROR: expected $expected_out to not be executable" - exit 1 - fi - if [ -L "$expected_out" ]; then - echo "ERROR: expected $expected_out to not be a symlink" - exit 1 - fi + local expected_out="lib/tests/write_source_files/symlink_test/b/test.txt" + if [ ! -e "$expected_out" ]; then + echo "ERROR: expected $expected_out to exist" + exit 1 + fi + if [ -x "$expected_out" ]; then + echo "ERROR: expected $expected_out to not be executable" + exit 1 + fi + if [ -L "$expected_out" ]; then + echo "ERROR: expected $expected_out to not be a symlink" + exit 1 + fi } # Run twice to make sure we can have permission to overwrite the outputs of a previous run diff --git a/lib/private/diff_test_tmpl.sh b/lib/private/diff_test_tmpl.sh index 60f6f5b..22da038 100644 --- a/lib/private/diff_test_tmpl.sh +++ b/lib/private/diff_test_tmpl.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash set -o errexit -o nounset -o pipefail escape() { - echo "$1" \ - | sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g' \ - | awk 1 ORS=' ' # preserve newlines + echo "$1" | + sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g' | + awk 1 ORS=' ' # preserve newlines } fail() { - cat << EOF >"${XML_OUTPUT_FILE:-/dev/null}" + cat <"${XML_OUTPUT_FILE:-/dev/null}" diff --git a/lib/tests/copy_to_directory/case6.sh b/lib/tests/copy_to_directory/case6.sh index 281f6f0..3288b4a 100755 --- a/lib/tests/copy_to_directory/case6.sh +++ b/lib/tests/copy_to_directory/case6.sh @@ -10,6 +10,6 @@ cd case_6 # A path that should be in the directory we have in data[] path="f/f2/f2" if [ ! -f "$path" ]; then - echo >&2 "Expected $path to exist in runfiles" - exit 1 + echo >&2 "Expected $path to exist in runfiles" + exit 1 fi diff --git a/lib/tests/run_binary_expansions/expansions.sh b/lib/tests/run_binary_expansions/expansions.sh index 6816588..683387f 100755 --- a/lib/tests/run_binary_expansions/expansions.sh +++ b/lib/tests/run_binary_expansions/expansions.sh @@ -4,9 +4,8 @@ set -o errexit -o nounset -o pipefail mkdir -p $(dirname $1) outfile=$1 rm -f $outfile -for each in $@ -do +for each in $@; do sanitized=${each/darwin/PLATFORM} sanitized=${sanitized/k8/PLATFORM} - echo $sanitized >> $outfile + echo $sanitized >>$outfile done diff --git a/lib/tests/stamping/stamper.sh b/lib/tests/stamping/stamper.sh index 3225c96..35e1349 100755 --- a/lib/tests/stamping/stamper.sh +++ b/lib/tests/stamping/stamper.sh @@ -5,9 +5,9 @@ set -o nounset # https://github.com/bazelbuild/bazel/issues/11164#issuecomment-996186921 # is another option, which requires Bash 4 for associative arrays. while IFS= read -r line; do - read key value <<< "$line" + read key value <<<"$line" declare $key="$value" done < <(cat "${BAZEL_STABLE_STATUS_FILE:-/dev/null}" "${BAZEL_VOLATILE_STATUS_FILE:-/dev/null}") # A real program would do something useful with the stamp info, like pass it to a linker. -echo "${BUILD_USER:-unstamped}" > $1 +echo "${BUILD_USER:-unstamped}" >$1 diff --git a/lib/tests/tar/cat_src_file.sh b/lib/tests/tar/cat_src_file.sh index ce6c373..7a0c4d7 100755 --- a/lib/tests/tar/cat_src_file.sh +++ b/lib/tests/tar/cat_src_file.sh @@ -3,13 +3,20 @@ # --- begin runfiles.bash initialization v3 --- # Copy-pasted from the Bazel Bash runfiles library v3. -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 || \ - { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e +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 || + { + echo >&2 "ERROR: cannot find $f" + exit 1 + } +f= +set -e # --- end runfiles.bash initialization v3 --- cat $(rlocation aspect_bazel_lib/lib/tests/tar/src_file) diff --git a/lib/tests/transitions/main.go b/lib/tests/transitions/main.go index a2e13c5..b1b14d0 100644 --- a/lib/tests/transitions/main.go +++ b/lib/tests/transitions/main.go @@ -3,5 +3,5 @@ package main import "fmt" func main() { - fmt.Println("Hello World!") + fmt.Println("Hello World!") } diff --git a/shlib/lib/assertions.sh b/shlib/lib/assertions.sh index 110ff52..b728b9e 100644 --- a/shlib/lib/assertions.sh +++ b/shlib/lib/assertions.sh @@ -20,13 +20,12 @@ fail() { make_err_msg() { local err_msg="${1}" local prefix="${2:-}" - if [[ -n "${prefix:-}" ]]; then + if [[ -n "${prefix:-}" ]]; then err_msg="${prefix} ${err_msg}" fi echo "${err_msg}" } - # Asserts that the actual value equals the expected value. # # Args: @@ -41,9 +40,9 @@ assert_equal() { local expected="${1}" local actual="${2}" local err_msg - err_msg="$(\ + err_msg="$( make_err_msg \ - "Expected to be equal. expected: ${expected}, actual: ${actual}" "${3:-}" \ + "Expected to be equal. expected: ${expected}, actual: ${actual}" "${3:-}" )" if [[ "${expected}" != "${actual}" ]]; then fail "${err_msg}" @@ -64,9 +63,9 @@ assert_match() { local pattern=${1} local actual="${2}" local err_msg - err_msg="$(\ + err_msg="$( make_err_msg \ - "Expected to match. pattern: ${pattern}, actual: ${actual}" "${3:-}" \ + "Expected to match. pattern: ${pattern}, actual: ${actual}" "${3:-}" )" if [[ ! "${actual}" =~ ${pattern} ]]; then fail "${err_msg}" @@ -87,9 +86,9 @@ assert_no_match() { local pattern=${1} local actual="${2}" local err_msg - err_msg="$(\ + err_msg="$( make_err_msg \ - "Expected not to match. pattern: ${pattern}, actual: ${actual}" "${3:-}" \ + "Expected not to match. pattern: ${pattern}, actual: ${actual}" "${3:-}" )" if [[ "${actual}" =~ ${pattern} ]]; then fail "${err_msg}" diff --git a/shlib/tests/lib_tests/assertions_tests/assert_equal_test.sh b/shlib/tests/lib_tests/assertions_tests/assert_equal_test.sh index d543426..6b22f54 100755 --- a/shlib/tests/lib_tests/assertions_tests/assert_equal_test.sh +++ b/shlib/tests/lib_tests/assertions_tests/assert_equal_test.sh @@ -2,29 +2,34 @@ # --- begin runfiles.bash initialization v2 --- # Copy-pasted from the Bazel Bash runfiles library v2. -set -o nounset -o pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash +set -o nounset -o pipefail +f=bazel_tools/tools/bash/runfiles/runfiles.bash # shellcheck disable=SC1090 -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: cannot find $f"; exit 1; }; f=; set -e +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: cannot find $f" + exit 1 + } +f= +set -e # --- end runfiles.bash initialization v2 --- assertions_sh_location=aspect_bazel_lib/shlib/lib/assertions.sh -assertions_sh="$(rlocation "${assertions_sh_location}")" || \ +assertions_sh="$(rlocation "${assertions_sh_location}")" || (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) # shellcheck source=SCRIPTDIR/../../../lib/assertions.sh source "${assertions_sh}" assert_fail_sh_location=aspect_bazel_lib/shlib/tests/lib_tests/assertions_tests/assert_fail.sh -assert_fail_sh="$(rlocation "${assert_fail_sh_location}")" || \ +assert_fail_sh="$(rlocation "${assert_fail_sh_location}")" || (echo >&2 "Failed to locate ${assert_fail_sh_location}" && exit 1) # shellcheck source=SCRIPTDIR/assert_fail.sh source "${assert_fail_sh}" - # MARK - Test assert_equal reset_fail_err_msgs diff --git a/shlib/tests/lib_tests/assertions_tests/assert_fail.sh b/shlib/tests/lib_tests/assertions_tests/assert_fail.sh index 35deb24..3dfc76c 100644 --- a/shlib/tests/lib_tests/assertions_tests/assert_fail.sh +++ b/shlib/tests/lib_tests/assertions_tests/assert_fail.sh @@ -4,14 +4,14 @@ FAIL_ERR_MSGS=() fail() { local err_msg="${1:-"Unspecified error occurred."}" - FAIL_ERR_MSGS+=( "${err_msg}" ) + FAIL_ERR_MSGS+=("${err_msg}") } reset_fail_err_msgs() { FAIL_ERR_MSGS=() } -new_fail(){ +new_fail() { local err_msg="${1:-}" [[ -n "${err_msg}" ]] || err_msg="Unspecified error occurred." echo >&2 "${err_msg}" @@ -20,17 +20,17 @@ new_fail(){ assert_fail() { local pattern=${1} - [[ ${#FAIL_ERR_MSGS[@]} == 0 ]] && \ + [[ ${#FAIL_ERR_MSGS[@]} == 0 ]] && new_fail "Expected a failure. None found. pattern: ${pattern}" - [[ ${#FAIL_ERR_MSGS[@]} -gt 1 ]] && \ + [[ ${#FAIL_ERR_MSGS[@]} -gt 1 ]] && new_fail "Expected a single failure. Found ${#FAIL_ERR_MSGS[@]}. pattern: ${pattern}" - [[ "${FAIL_ERR_MSGS[0]}" =~ ${pattern} ]] || \ + [[ "${FAIL_ERR_MSGS[0]}" =~ ${pattern} ]] || new_fail "Unexpected failure. Found '${FAIL_ERR_MSGS[0]}'. pattern: ${pattern}" } -assert_no_fail(){ - [[ ${#FAIL_ERR_MSGS[@]} == 0 ]] || ( \ - err_msg=$("${FAIL_ERR_MSGS[@]}") && \ - new_fail "Expected no failures. Found ${#FAIL_ERR_MSGS[@]}. '${err_msg}'" \ +assert_no_fail() { + [[ ${#FAIL_ERR_MSGS[@]} == 0 ]] || ( + err_msg=$("${FAIL_ERR_MSGS[@]}") && + new_fail "Expected no failures. Found ${#FAIL_ERR_MSGS[@]}. '${err_msg}'" ) } diff --git a/shlib/tests/lib_tests/assertions_tests/assert_match_test.sh b/shlib/tests/lib_tests/assertions_tests/assert_match_test.sh index 4afdd5a..f724aeb 100755 --- a/shlib/tests/lib_tests/assertions_tests/assert_match_test.sh +++ b/shlib/tests/lib_tests/assertions_tests/assert_match_test.sh @@ -2,24 +2,30 @@ # --- begin runfiles.bash initialization v2 --- # Copy-pasted from the Bazel Bash runfiles library v2. -set -o nounset -o pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash +set -o nounset -o pipefail +f=bazel_tools/tools/bash/runfiles/runfiles.bash # shellcheck disable=SC1090 -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: cannot find $f"; exit 1; }; f=; set -e +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: cannot find $f" + exit 1 + } +f= +set -e # --- end runfiles.bash initialization v2 --- assertions_sh_location=aspect_bazel_lib/shlib/lib/assertions.sh -assertions_sh="$(rlocation "${assertions_sh_location}")" || \ +assertions_sh="$(rlocation "${assertions_sh_location}")" || (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) # shellcheck source=SCRIPTDIR/../../../lib/assertions.sh source "${assertions_sh}" assert_fail_sh_location=aspect_bazel_lib/shlib/tests/lib_tests/assertions_tests/assert_fail.sh -assert_fail_sh="$(rlocation "${assert_fail_sh_location}")" || \ +assert_fail_sh="$(rlocation "${assert_fail_sh_location}")" || (echo >&2 "Failed to locate ${assert_fail_sh_location}" && exit 1) # shellcheck source=SCRIPTDIR/assert_fail.sh source "${assert_fail_sh}" diff --git a/shlib/tests/lib_tests/assertions_tests/assert_no_match_test.sh b/shlib/tests/lib_tests/assertions_tests/assert_no_match_test.sh index 784a5c9..609e9fb 100755 --- a/shlib/tests/lib_tests/assertions_tests/assert_no_match_test.sh +++ b/shlib/tests/lib_tests/assertions_tests/assert_no_match_test.sh @@ -2,24 +2,30 @@ # --- begin runfiles.bash initialization v2 --- # Copy-pasted from the Bazel Bash runfiles library v2. -set -o nounset -o pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash +set -o nounset -o pipefail +f=bazel_tools/tools/bash/runfiles/runfiles.bash # shellcheck disable=SC1090 -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: cannot find $f"; exit 1; }; f=; set -e +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: cannot find $f" + exit 1 + } +f= +set -e # --- end runfiles.bash initialization v2 --- assertions_sh_location=aspect_bazel_lib/shlib/lib/assertions.sh -assertions_sh="$(rlocation "${assertions_sh_location}")" || \ +assertions_sh="$(rlocation "${assertions_sh_location}")" || (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1) # shellcheck source=SCRIPTDIR/../../../lib/assertions.sh source "${assertions_sh}" assert_fail_sh_location=aspect_bazel_lib/shlib/tests/lib_tests/assertions_tests/assert_fail.sh -assert_fail_sh="$(rlocation "${assert_fail_sh_location}")" || \ +assert_fail_sh="$(rlocation "${assert_fail_sh_location}")" || (echo >&2 "Failed to locate ${assert_fail_sh_location}" && exit 1) # shellcheck source=SCRIPTDIR/assert_fail.sh source "${assert_fail_sh}" diff --git a/tools/coreutils_mirror_release.sh b/tools/coreutils_mirror_release.sh index 580f792..4efb506 100755 --- a/tools/coreutils_mirror_release.sh +++ b/tools/coreutils_mirror_release.sh @@ -2,8 +2,7 @@ set -o errexit -o nounset -o pipefail -JQ_FILTER=\ -'map({ +JQ_FILTER='map({ "key": .tag_name, "value": .assets | map(select( @@ -41,16 +40,14 @@ JQ_FILTER=\ }) | from_entries ' - INFO="$(curl --silent -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/uutils/coreutils/releases?per_page=1 | jq "$JQ_FILTER")" - -for VERSION in $(jq -r 'keys | join("\n")' <<< $INFO); do - for PLATFORM in $(jq -r ".[\"$VERSION\"] | keys | join(\"\n\")" <<< $INFO); do - FILENAME=$(jq -r ".[\"$VERSION\"][\"$PLATFORM\"].filename" <<< $INFO) - SHA256=$(curl -fLs "https://github.com/uutils/coreutils/releases/download/$VERSION/$FILENAME" | sha256sum | xxd -r -p | base64) - INFO=$(jq ".[\"$VERSION\"][\"$PLATFORM\"].sha256 = \"sha256-$SHA256\"" <<< $INFO) - done +for VERSION in $(jq -r 'keys | join("\n")' <<<$INFO); do + for PLATFORM in $(jq -r ".[\"$VERSION\"] | keys | join(\"\n\")" <<<$INFO); do + FILENAME=$(jq -r ".[\"$VERSION\"][\"$PLATFORM\"].filename" <<<$INFO) + SHA256=$(curl -fLs "https://github.com/uutils/coreutils/releases/download/$VERSION/$FILENAME" | sha256sum | xxd -r -p | base64) + INFO=$(jq ".[\"$VERSION\"][\"$PLATFORM\"].sha256 = \"sha256-$SHA256\"" <<<$INFO) + done done echo -n "COREUTILS_VERSIONS = " diff --git a/tools/release/create_versions.sh b/tools/release/create_versions.sh index 22f6031..0ae9337 100755 --- a/tools/release/create_versions.sh +++ b/tools/release/create_versions.sh @@ -10,7 +10,7 @@ cat < 0 )); do +while (($# > 0)); do if [[ "$1" =~ .*.sha256 ]]; then base=$(basename $1) @@ -24,6 +24,5 @@ EOF shift done - echo -n "}" echo "" diff --git a/tools/yq_mirror_release.sh b/tools/yq_mirror_release.sh index 951298e..2b81f2f 100755 --- a/tools/yq_mirror_release.sh +++ b/tools/yq_mirror_release.sh @@ -6,9 +6,9 @@ set -o errexit -o nounset -o pipefail # Find the latest version if [ "${1:-}" ]; then - version=$1 + version=$1 else - version=$(curl --silent "https://api.github.com/repos/mikefarah/yq/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') + version=$(curl --silent "https://api.github.com/repos/mikefarah/yq/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') fi # yq publishes its checksums and a script to extract them @@ -23,11 +23,11 @@ chmod u+x extract-checksum.sh echo "\"$version\": {" platforms=(darwin_{amd64,arm64} linux_{amd64,arm64,s390x,ppc64le} windows_amd64) for release in ${platforms[@]}; do - artifact=$release - if [[ $release == windows* ]]; then - artifact="$release.exe" - fi - echo " \"$release\": \"$(./extract-checksum.sh SHA-384 $artifact | awk '{ print $2 }' | xxd -r -p | base64 | awk '{ print "sha384-" $1 }' )\"," + artifact=$release + if [[ $release == windows* ]]; then + artifact="$release.exe" + fi + echo " \"$release\": \"$(./extract-checksum.sh SHA-384 $artifact | awk '{ print $2 }' | xxd -r -p | base64 | awk '{ print "sha384-" $1 }')\"," done echo "},"