mirror of
https://github.com/taiki-e/install-action.git
synced 2026-04-17 19:52:38 +08:00
Auto-generate tool list for CI
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
set -euxo pipefail
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
cd "$(dirname "$0")"/../..
|
||||
|
||||
@@ -16,6 +16,8 @@ fi
|
||||
git config user.name "Taiki Endo"
|
||||
git config user.email "te316e89@gmail.com"
|
||||
|
||||
set -x
|
||||
|
||||
for manifest in manifests/*.json; do
|
||||
git add -N "${manifest}"
|
||||
if ! git diff --exit-code -- "${manifest}"; then
|
||||
|
||||
132
tools/ci/tool-list.sh
Executable file
132
tools/ci/tool-list.sh
Executable file
@@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
cd "$(dirname "$0")"/../..
|
||||
|
||||
# They don't provide prebuilt binaries for musl or old glibc host.
|
||||
glibc_pre_2_31_incompat=(
|
||||
zola
|
||||
)
|
||||
glibc_pre_2_27_incompat=(
|
||||
"${glibc_pre_2_31_incompat[@]}"
|
||||
cargo-watch
|
||||
mdbook-linkcheck
|
||||
protoc
|
||||
valgrind
|
||||
wasmtime
|
||||
)
|
||||
musl_incompat=(
|
||||
"${glibc_pre_2_27_incompat[@]}"
|
||||
)
|
||||
|
||||
incompat_tools=()
|
||||
case "${1:-}" in
|
||||
'') version=latest ;;
|
||||
major.minor.patch | major.minor | major)
|
||||
version="$1"
|
||||
# Specifying the version of valgrind and cargo-binstall is not supported.
|
||||
incompat_tools+=(valgrind cargo-binstall)
|
||||
;;
|
||||
*)
|
||||
echo "tool=$1"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
case "$(uname -s)" in
|
||||
Linux)
|
||||
host_os=linux
|
||||
ldd_version=$(ldd --version 2>&1 || true)
|
||||
if grep <<<"${ldd_version}" -q 'musl'; then
|
||||
incompat_tools+=("${musl_incompat[@]}")
|
||||
else
|
||||
host_glibc_version=$(grep <<<"${ldd_version}" -E "GLIBC|GNU libc" | sed "s/.* //g")
|
||||
higher_glibc_version=$(sort <<<"2.31"$'\n'"${host_glibc_version}" -Vu | tail -1)
|
||||
if [[ "${higher_glibc_version}" != "${host_glibc_version}" ]]; then
|
||||
higher_glibc_version=$(sort <<<"2.27"$'\n'"${host_glibc_version}" -Vu | tail -1)
|
||||
if [[ "${higher_glibc_version}" == "${host_glibc_version}" ]]; then
|
||||
incompat_tools+=("${glibc_pre_2_31_incompat[@]}")
|
||||
else
|
||||
incompat_tools+=("${glibc_pre_2_27_incompat[@]}")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if ! type -P snap &>/dev/null; then
|
||||
incompat_tools+=(valgrind)
|
||||
fi
|
||||
;;
|
||||
Darwin) host_os=macos ;;
|
||||
MINGW* | MSYS* | CYGWIN* | Windows_NT) host_os=windows ;;
|
||||
*) bail "unrecognized OS type '$(uname -s)'" ;;
|
||||
esac
|
||||
|
||||
tools=()
|
||||
for manifest in tools/codegen/base/*.json; do
|
||||
tool_name=$(basename "${manifest%.*}")
|
||||
case "${host_os}" in
|
||||
linux*)
|
||||
for incompat in ${incompat_tools[@]+"${incompat_tools[@]}"}; do
|
||||
if [[ "${incompat}" == "${tool_name}" ]]; then
|
||||
tool_name=''
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
*)
|
||||
if [[ "$(jq -r ".platform.x86_64_${host_os}" "${manifest}")" == "null" ]]; then
|
||||
continue
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [[ -n "${tool_name}" ]]; then
|
||||
if [[ "${version}" != "latest" ]]; then
|
||||
latest_version="$(jq -r ".latest.version" "manifests/${tool_name}.json")"
|
||||
case "${version}" in
|
||||
major.minor.patch) tool_name+="@${latest_version}" ;;
|
||||
major.minor) tool_name+="@${latest_version%.*}" ;;
|
||||
major) tool_name+="@${latest_version%%.*}" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
fi
|
||||
if [[ "${tool_name}" != *"@0" ]] && [[ "${tool_name}" != *"@0.0" ]]; then
|
||||
tools+=("${tool_name}")
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ "${version}" != "latest" ]]; then
|
||||
tools_tmp=()
|
||||
for tool in "${tools[@]}"; do
|
||||
tools_tmp+=("${tool}")
|
||||
done
|
||||
tools=("${tools_tmp[@]}")
|
||||
fi
|
||||
|
||||
# Not manifest-based
|
||||
case "${host_os}" in
|
||||
linux*)
|
||||
# Installing snap to container is difficult...
|
||||
# Specifying the version of valgrind is not supported.
|
||||
if type -P snap &>/dev/null && [[ "${version}" == "latest" ]]; then
|
||||
tools+=(valgrind)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
# cargo-watch/watchexec-cli is supported by cargo-binstall (through quickinstall)
|
||||
case "${version}" in
|
||||
latest) tools+=(cargo-watch watchexec-cli) ;;
|
||||
major.minor.patch) tools+=(cargo-watch@8.1.1 watchexec-cli@1.20.5) ;;
|
||||
major.minor) tools+=(cargo-watch@8.1 watchexec-cli@1.20) ;;
|
||||
major) tools+=(cargo-watch@8 watchexec-cli@1) ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
|
||||
# sort and dedup
|
||||
IFS=$'\n'
|
||||
# shellcheck disable=SC2207
|
||||
tools=($(LC_ALL=C sort -u <<<"${tools[*]}"))
|
||||
IFS=$'\n\t'
|
||||
|
||||
# TODO: inject random space before/after of tool name for testing https://github.com/taiki-e/install-action/issues/115.
|
||||
IFS=','
|
||||
echo "tool=${tools[*]}"
|
||||
IFS=$'\n\t'
|
||||
Reference in New Issue
Block a user