chore: bazel run //:format (#682)

This commit is contained in:
Greg Magolan 2023-12-08 00:30:39 -08:00 committed by GitHub
parent bb64a79dc3
commit b1c342a96f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 161 additions and 134 deletions

View File

@ -42,7 +42,7 @@ module "aspect_workflows" {
# Warming set definitions # Warming set definitions
warming_sets = { warming_sets = {
default = {} default = {}
} }
# Resource types for use by runner groups # Resource types for use by runner groups
@ -67,7 +67,7 @@ module "aspect_workflows" {
min_runners = 0 min_runners = 0
resource_type = "default" resource_type = "default"
scale_out_factor = 7 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 warming = true
} }
# The warming runner group is used for the periodic warming job that creates # The warming runner group is used for the periodic warming job that creates

3
.editorconfig Normal file
View File

@ -0,0 +1,3 @@
[*.sh]
indent_style = space
indent_size = 2

View File

@ -12,10 +12,10 @@ PREFIX="bazel-lib-${TAG:1}"
ARCHIVE="bazel-lib-$TAG.tar.gz" ARCHIVE="bazel-lib-$TAG.tar.gz"
# NB: configuration for 'git archive' is in /.gitattributes # 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}') SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
cat << EOF cat <<EOF
## Using Bzlmod with Bazel 6: ## Using Bzlmod with Bazel 6:

View File

@ -1,12 +1,19 @@
# --- begin runfiles.bash initialization v2 --- # --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2. # Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash set -uo pipefail
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ set +e
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "$0.runfiles/$f" 2>/dev/null || \ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null ||
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null ||
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ source "$0.runfiles/$f" 2>/dev/null ||
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e 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 --- # --- end runfiles.bash initialization v2 ---
# Read external directory and make sure it exists with a file. # Read external directory and make sure it exists with a file.

View File

@ -4,12 +4,11 @@ set -o errexit -o nounset -o pipefail
BZLMOD_FLAG="${BZLMOD_FLAG:-}" BZLMOD_FLAG="${BZLMOD_FLAG:-}"
case "$(uname -s)" in case "$(uname -s)" in
CYGWIN*|MINGW32*|MSYS*|MINGW*) CYGWIN* | MINGW32* | MSYS* | MINGW*)
bazel run $BZLMOD_FLAG @jq//:jq.exe -- --null-input .a=5 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 esac

View File

@ -4,11 +4,11 @@ set -o errexit -o nounset -o pipefail
BZLMOD_FLAG="${BZLMOD_FLAG:-}" BZLMOD_FLAG="${BZLMOD_FLAG:-}"
case "$(uname -s)" in case "$(uname -s)" in
CYGWIN*|MINGW32*|MSYS*|MINGW*) CYGWIN* | MINGW32* | MSYS* | MINGW*)
bazel run $BZLMOD_FLAG @yq//:yq.exe -- --null-input .a=5 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 esac

View File

@ -4,35 +4,35 @@ set -o errexit -o nounset -o pipefail
BZLMOD_FLAG="${BZLMOD_FLAG:-}" BZLMOD_FLAG="${BZLMOD_FLAG:-}"
function run_test { 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" local expected_out="lib/tests/write_source_files/symlink_test/a/test.txt"
if [ ! -e "$expected_out" ]; then if [ ! -e "$expected_out" ]; then
echo "ERROR: expected $expected_out to exist" echo "ERROR: expected $expected_out to exist"
exit 1 exit 1
fi fi
if [ -x "$expected_out" ]; then if [ -x "$expected_out" ]; then
echo "ERROR: expected $expected_out to not be executable" echo "ERROR: expected $expected_out to not be executable"
exit 1 exit 1
fi fi
if [ -L "$expected_out" ]; then if [ -L "$expected_out" ]; then
echo "ERROR: expected $expected_out to not be a symlink" echo "ERROR: expected $expected_out to not be a symlink"
exit 1 exit 1
fi fi
local expected_out="lib/tests/write_source_files/symlink_test/b/test.txt" local expected_out="lib/tests/write_source_files/symlink_test/b/test.txt"
if [ ! -e "$expected_out" ]; then if [ ! -e "$expected_out" ]; then
echo "ERROR: expected $expected_out to exist" echo "ERROR: expected $expected_out to exist"
exit 1 exit 1
fi fi
if [ -x "$expected_out" ]; then if [ -x "$expected_out" ]; then
echo "ERROR: expected $expected_out to not be executable" echo "ERROR: expected $expected_out to not be executable"
exit 1 exit 1
fi fi
if [ -L "$expected_out" ]; then if [ -L "$expected_out" ]; then
echo "ERROR: expected $expected_out to not be a symlink" echo "ERROR: expected $expected_out to not be a symlink"
exit 1 exit 1
fi fi
} }
# Run twice to make sure we can have permission to overwrite the outputs of a previous run # Run twice to make sure we can have permission to overwrite the outputs of a previous run

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o errexit -o nounset -o pipefail set -o errexit -o nounset -o pipefail
escape() { escape() {
echo "$1" \ echo "$1" |
| sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g' \ sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g' |
| awk 1 ORS='&#10;' # preserve newlines awk 1 ORS='&#10;' # preserve newlines
} }
fail() { fail() {
cat << EOF >"${XML_OUTPUT_FILE:-/dev/null}" cat <<EOF >"${XML_OUTPUT_FILE:-/dev/null}"
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<testsuites name="$(escape "{name}")" tests="1" failures="1"> <testsuites name="$(escape "{name}")" tests="1" failures="1">
<testsuite name="$(escape "{name}")" tests="1" failures="1" id="0"> <testsuite name="$(escape "{name}")" tests="1" failures="1" id="0">

View File

@ -10,6 +10,6 @@ cd case_6
# A path that should be in the directory we have in data[] # A path that should be in the directory we have in data[]
path="f/f2/f2" path="f/f2/f2"
if [ ! -f "$path" ]; then if [ ! -f "$path" ]; then
echo >&2 "Expected $path to exist in runfiles" echo >&2 "Expected $path to exist in runfiles"
exit 1 exit 1
fi fi

View File

@ -4,9 +4,8 @@ set -o errexit -o nounset -o pipefail
mkdir -p $(dirname $1) mkdir -p $(dirname $1)
outfile=$1 outfile=$1
rm -f $outfile rm -f $outfile
for each in $@ for each in $@; do
do
sanitized=${each/darwin/PLATFORM} sanitized=${each/darwin/PLATFORM}
sanitized=${sanitized/k8/PLATFORM} sanitized=${sanitized/k8/PLATFORM}
echo $sanitized >> $outfile echo $sanitized >>$outfile
done done

View File

@ -5,9 +5,9 @@ set -o nounset
# https://github.com/bazelbuild/bazel/issues/11164#issuecomment-996186921 # https://github.com/bazelbuild/bazel/issues/11164#issuecomment-996186921
# is another option, which requires Bash 4 for associative arrays. # is another option, which requires Bash 4 for associative arrays.
while IFS= read -r line; do while IFS= read -r line; do
read key value <<< "$line" read key value <<<"$line"
declare $key="$value" declare $key="$value"
done < <(cat "${BAZEL_STABLE_STATUS_FILE:-/dev/null}" "${BAZEL_VOLATILE_STATUS_FILE:-/dev/null}") 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. # 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

View File

@ -3,13 +3,20 @@
# --- begin runfiles.bash initialization v3 --- # --- begin runfiles.bash initialization v3 ---
# Copy-pasted from the Bazel Bash runfiles library v3. # Copy-pasted from the Bazel Bash runfiles library v3.
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash set -uo pipefail
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ set +e
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "$0.runfiles/$f" 2>/dev/null || \ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null ||
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null ||
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ source "$0.runfiles/$f" 2>/dev/null ||
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e 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 --- # --- end runfiles.bash initialization v3 ---
cat $(rlocation aspect_bazel_lib/lib/tests/tar/src_file) cat $(rlocation aspect_bazel_lib/lib/tests/tar/src_file)

View File

@ -3,5 +3,5 @@ package main
import "fmt" import "fmt"
func main() { func main() {
fmt.Println("Hello World!") fmt.Println("Hello World!")
} }

View File

@ -20,13 +20,12 @@ fail() {
make_err_msg() { make_err_msg() {
local err_msg="${1}" local err_msg="${1}"
local prefix="${2:-}" local prefix="${2:-}"
if [[ -n "${prefix:-}" ]]; then if [[ -n "${prefix:-}" ]]; then
err_msg="${prefix} ${err_msg}" err_msg="${prefix} ${err_msg}"
fi fi
echo "${err_msg}" echo "${err_msg}"
} }
# Asserts that the actual value equals the expected value. # Asserts that the actual value equals the expected value.
# #
# Args: # Args:
@ -41,9 +40,9 @@ assert_equal() {
local expected="${1}" local expected="${1}"
local actual="${2}" local actual="${2}"
local err_msg local err_msg
err_msg="$(\ err_msg="$(
make_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 if [[ "${expected}" != "${actual}" ]]; then
fail "${err_msg}" fail "${err_msg}"
@ -64,9 +63,9 @@ assert_match() {
local pattern=${1} local pattern=${1}
local actual="${2}" local actual="${2}"
local err_msg local err_msg
err_msg="$(\ err_msg="$(
make_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 if [[ ! "${actual}" =~ ${pattern} ]]; then
fail "${err_msg}" fail "${err_msg}"
@ -87,9 +86,9 @@ assert_no_match() {
local pattern=${1} local pattern=${1}
local actual="${2}" local actual="${2}"
local err_msg local err_msg
err_msg="$(\ err_msg="$(
make_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 if [[ "${actual}" =~ ${pattern} ]]; then
fail "${err_msg}" fail "${err_msg}"

View File

@ -2,29 +2,34 @@
# --- begin runfiles.bash initialization v2 --- # --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library 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 # shellcheck disable=SC1090
source "${RUNFILES_DIR:-/dev/null}/$f" 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 "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null ||
source "$0.runfiles/$f" 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.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null ||
source "$(grep -sm1 "^$f " "$0.exe.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 {
echo >&2 "ERROR: cannot find $f"
exit 1
}
f=
set -e
# --- end runfiles.bash initialization v2 --- # --- end runfiles.bash initialization v2 ---
assertions_sh_location=aspect_bazel_lib/shlib/lib/assertions.sh 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) (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1)
# shellcheck source=SCRIPTDIR/../../../lib/assertions.sh # shellcheck source=SCRIPTDIR/../../../lib/assertions.sh
source "${assertions_sh}" source "${assertions_sh}"
assert_fail_sh_location=aspect_bazel_lib/shlib/tests/lib_tests/assertions_tests/assert_fail.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) (echo >&2 "Failed to locate ${assert_fail_sh_location}" && exit 1)
# shellcheck source=SCRIPTDIR/assert_fail.sh # shellcheck source=SCRIPTDIR/assert_fail.sh
source "${assert_fail_sh}" source "${assert_fail_sh}"
# MARK - Test assert_equal # MARK - Test assert_equal
reset_fail_err_msgs reset_fail_err_msgs

View File

@ -4,14 +4,14 @@ FAIL_ERR_MSGS=()
fail() { fail() {
local err_msg="${1:-"Unspecified error occurred."}" local err_msg="${1:-"Unspecified error occurred."}"
FAIL_ERR_MSGS+=( "${err_msg}" ) FAIL_ERR_MSGS+=("${err_msg}")
} }
reset_fail_err_msgs() { reset_fail_err_msgs() {
FAIL_ERR_MSGS=() FAIL_ERR_MSGS=()
} }
new_fail(){ new_fail() {
local err_msg="${1:-}" local err_msg="${1:-}"
[[ -n "${err_msg}" ]] || err_msg="Unspecified error occurred." [[ -n "${err_msg}" ]] || err_msg="Unspecified error occurred."
echo >&2 "${err_msg}" echo >&2 "${err_msg}"
@ -20,17 +20,17 @@ new_fail(){
assert_fail() { assert_fail() {
local pattern=${1} local pattern=${1}
[[ ${#FAIL_ERR_MSGS[@]} == 0 ]] && \ [[ ${#FAIL_ERR_MSGS[@]} == 0 ]] &&
new_fail "Expected a failure. None found. pattern: ${pattern}" 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}" 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}" new_fail "Unexpected failure. Found '${FAIL_ERR_MSGS[0]}'. pattern: ${pattern}"
} }
assert_no_fail(){ assert_no_fail() {
[[ ${#FAIL_ERR_MSGS[@]} == 0 ]] || ( \ [[ ${#FAIL_ERR_MSGS[@]} == 0 ]] || (
err_msg=$("${FAIL_ERR_MSGS[@]}") && \ err_msg=$("${FAIL_ERR_MSGS[@]}") &&
new_fail "Expected no failures. Found ${#FAIL_ERR_MSGS[@]}. '${err_msg}'" \ new_fail "Expected no failures. Found ${#FAIL_ERR_MSGS[@]}. '${err_msg}'"
) )
} }

View File

@ -2,24 +2,30 @@
# --- begin runfiles.bash initialization v2 --- # --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library 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 # shellcheck disable=SC1090
source "${RUNFILES_DIR:-/dev/null}/$f" 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 "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null ||
source "$0.runfiles/$f" 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.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null ||
source "$(grep -sm1 "^$f " "$0.exe.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 {
echo >&2 "ERROR: cannot find $f"
exit 1
}
f=
set -e
# --- end runfiles.bash initialization v2 --- # --- end runfiles.bash initialization v2 ---
assertions_sh_location=aspect_bazel_lib/shlib/lib/assertions.sh 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) (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1)
# shellcheck source=SCRIPTDIR/../../../lib/assertions.sh # shellcheck source=SCRIPTDIR/../../../lib/assertions.sh
source "${assertions_sh}" source "${assertions_sh}"
assert_fail_sh_location=aspect_bazel_lib/shlib/tests/lib_tests/assertions_tests/assert_fail.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) (echo >&2 "Failed to locate ${assert_fail_sh_location}" && exit 1)
# shellcheck source=SCRIPTDIR/assert_fail.sh # shellcheck source=SCRIPTDIR/assert_fail.sh
source "${assert_fail_sh}" source "${assert_fail_sh}"

View File

@ -2,24 +2,30 @@
# --- begin runfiles.bash initialization v2 --- # --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library 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 # shellcheck disable=SC1090
source "${RUNFILES_DIR:-/dev/null}/$f" 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 "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null ||
source "$0.runfiles/$f" 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.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null ||
source "$(grep -sm1 "^$f " "$0.exe.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 {
echo >&2 "ERROR: cannot find $f"
exit 1
}
f=
set -e
# --- end runfiles.bash initialization v2 --- # --- end runfiles.bash initialization v2 ---
assertions_sh_location=aspect_bazel_lib/shlib/lib/assertions.sh 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) (echo >&2 "Failed to locate ${assertions_sh_location}" && exit 1)
# shellcheck source=SCRIPTDIR/../../../lib/assertions.sh # shellcheck source=SCRIPTDIR/../../../lib/assertions.sh
source "${assertions_sh}" source "${assertions_sh}"
assert_fail_sh_location=aspect_bazel_lib/shlib/tests/lib_tests/assertions_tests/assert_fail.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) (echo >&2 "Failed to locate ${assert_fail_sh_location}" && exit 1)
# shellcheck source=SCRIPTDIR/assert_fail.sh # shellcheck source=SCRIPTDIR/assert_fail.sh
source "${assert_fail_sh}" source "${assert_fail_sh}"

View File

@ -2,8 +2,7 @@
set -o errexit -o nounset -o pipefail set -o errexit -o nounset -o pipefail
JQ_FILTER=\ JQ_FILTER='map({
'map({
"key": .tag_name, "key": .tag_name,
"value": .assets "value": .assets
| map(select( | map(select(
@ -41,16 +40,14 @@ JQ_FILTER=\
}) | from_entries }) | 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")" 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 VERSION in $(jq -r 'keys | join("\n")' <<< $INFO); do for PLATFORM in $(jq -r ".[\"$VERSION\"] | keys | join(\"\n\")" <<<$INFO); do
for PLATFORM in $(jq -r ".[\"$VERSION\"] | keys | join(\"\n\")" <<< $INFO); do FILENAME=$(jq -r ".[\"$VERSION\"][\"$PLATFORM\"].filename" <<<$INFO)
FILENAME=$(jq -r ".[\"$VERSION\"][\"$PLATFORM\"].filename" <<< $INFO) SHA256=$(curl -fLs "https://github.com/uutils/coreutils/releases/download/$VERSION/$FILENAME" | sha256sum | xxd -r -p | base64)
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)
INFO=$(jq ".[\"$VERSION\"][\"$PLATFORM\"].sha256 = \"sha256-$SHA256\"" <<< $INFO) done
done
done done
echo -n "COREUTILS_VERSIONS = " echo -n "COREUTILS_VERSIONS = "

View File

@ -10,7 +10,7 @@ cat <<EOF
${NAME_UPPER}_INTEGRITY = { ${NAME_UPPER}_INTEGRITY = {
EOF EOF
while (( $# > 0 )); do while (($# > 0)); do
if [[ "$1" =~ .*.sha256 ]]; then if [[ "$1" =~ .*.sha256 ]]; then
base=$(basename $1) base=$(basename $1)
@ -24,6 +24,5 @@ EOF
shift shift
done done
echo -n "}" echo -n "}"
echo "" echo ""

View File

@ -6,9 +6,9 @@ set -o errexit -o nounset -o pipefail
# Find the latest version # Find the latest version
if [ "${1:-}" ]; then if [ "${1:-}" ]; then
version=$1 version=$1
else 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 fi
# yq publishes its checksums and a script to extract them # yq publishes its checksums and a script to extract them
@ -23,11 +23,11 @@ chmod u+x extract-checksum.sh
echo "\"$version\": {" echo "\"$version\": {"
platforms=(darwin_{amd64,arm64} linux_{amd64,arm64,s390x,ppc64le} windows_amd64) platforms=(darwin_{amd64,arm64} linux_{amd64,arm64,s390x,ppc64le} windows_amd64)
for release in ${platforms[@]}; do for release in ${platforms[@]}; do
artifact=$release artifact=$release
if [[ $release == windows* ]]; then if [[ $release == windows* ]]; then
artifact="$release.exe" artifact="$release.exe"
fi fi
echo " \"$release\": \"$(./extract-checksum.sh SHA-384 $artifact | awk '{ print $2 }' | xxd -r -p | base64 | awk '{ print "sha384-" $1 }' )\"," echo " \"$release\": \"$(./extract-checksum.sh SHA-384 $artifact | awk '{ print $2 }' | xxd -r -p | base64 | awk '{ print "sha384-" $1 }')\","
done done
echo "}," echo "},"