Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cargo-binstall batching mode #54

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Try cargo-binstall batching mode
  • Loading branch information
taiki-e committed Jan 16, 2023
commit 0ee7430e066efcac7c6fc7f9ed4f5b200e950a04
1 change: 1 addition & 0 deletions .github/.cspell/project-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ shellcheck
shfmt
udeps
wasmtime
watchexec
xscale
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ jobs:
- ubuntu-20.04
- ubuntu-22.04
tool:
# cargo-watch is supported by cargo-binstall (through quickinstall)
# cargo-watch/watchexec-cli is supported by cargo-binstall (through quickinstall)
# TODO: valgrind installation sometime hangs.
- cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov
- cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov,watchexec-cli
include:
# Note: Specifying the version of valgrind and cargo-binstall is not supported.
- os: ubuntu-20.04
tool: cargo-hack@0.5.24,cargo-llvm-cov@0.5.3,cargo-minimal-versions@0.1.8,cargo-no-dev-deps@0.1.0,parse-changelog@0.5.2,cargo-udeps@0.1.35,cargo-valgrind@2.1.0,cargo-deny@0.13.5,cross@0.2.4,dprint@0.34.1,just@1.9.0,nextest@0.9.11,protoc@3.21.12,shellcheck@0.9.0,shfmt@3.6.0,wasm-pack@0.10.3,wasmtime@4.0.0,mdbook@0.4.25,mdbook-linkcheck@0.7.7,cargo-watch@8.1.1,grcov@0.8.13
tool: cargo-hack@0.5.24,cargo-llvm-cov@0.5.3,cargo-minimal-versions@0.1.8,cargo-no-dev-deps@0.1.0,parse-changelog@0.5.2,cargo-udeps@0.1.35,cargo-valgrind@2.1.0,cargo-deny@0.13.5,cross@0.2.4,dprint@0.34.1,just@1.9.0,nextest@0.9.11,protoc@3.21.12,shellcheck@0.9.0,shfmt@3.6.0,wasm-pack@0.10.3,wasmtime@4.0.0,mdbook@0.4.25,mdbook-linkcheck@0.7.7,cargo-watch@8.1.1,grcov@0.8.13,watchexec-cli@1.20.5
- os: ubuntu-20.04
tool: cargo-hack@0.5,cargo-llvm-cov@0.5,cargo-minimal-versions@0.1,cargo-no-dev-deps@0.1,parse-changelog@0.5,cargo-udeps@0.1,cargo-valgrind@2.1,cargo-deny@0.13,cross@0.2,dprint@0.34,just@1.9,nextest@0.9,protoc@3.21,shellcheck@0.9,shfmt@3.5,wasm-pack@0.10,wasmtime@4.0,mdbook@0.4,mdbook-linkcheck@0.7,cargo-watch@8.1,grcov@0.8
tool: cargo-hack@0.5,cargo-llvm-cov@0.5,cargo-minimal-versions@0.1,cargo-no-dev-deps@0.1,parse-changelog@0.5,cargo-udeps@0.1,cargo-valgrind@2.1,cargo-deny@0.13,cross@0.2,dprint@0.34,just@1.9,nextest@0.9,protoc@3.21,shellcheck@0.9,shfmt@3.5,wasm-pack@0.10,wasmtime@4.0,mdbook@0.4,mdbook-linkcheck@0.7,cargo-watch@8.1,grcov@0.8,watchexec-cli@1.20
- os: ubuntu-20.04
tool: cargo-valgrind@2,just@1,protoc@3,shfmt@3,wasmtime@4,cargo-watch@8
tool: cargo-valgrind@2,just@1,protoc@3,shfmt@3,wasmtime@4,cargo-watch@8,watchexec-cli@1
- os: macos-11
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov,watchexec-cli
- os: windows-2019
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov,watchexec-cli
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
Expand Down Expand Up @@ -77,20 +77,20 @@ jobs:
- rockylinux:8-minimal # glibc 2.28
tool:
# valgrind: installing snap to container is difficult...
- cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov
- cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov,watchexec-cli
include:
- container: ubuntu:22.04 # glibc 2.35
# cargo-udeps depends on openssl 1.1
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov,watchexec-cli
- container: fedora:latest # glibc 2.36 (as of fedora 37)
# cargo-udeps depends on openssl 1.1
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch,grcov,watchexec-cli
- container: centos:7 # glibc 2.17
# cargo-udeps,protoc,valgrind,wasmtime,mdbook-linkcheck,cargo-watch don't provide prebuilt binaries for musl host.
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,shellcheck,shfmt,wasm-pack,mdbook,cargo-binstall,grcov
# cargo-udeps,protoc,valgrind,wasmtime,mdbook-linkcheck,cargo-watch don't provide prebuilt binaries for musl or old glibc host.
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,shellcheck,shfmt,wasm-pack,mdbook,cargo-binstall,grcov,watchexec-cli
- container: alpine:latest # musl 1.2.3 (as of alpine 3.17)
# cargo-udeps,protoc,valgrind,wasmtime,mdbook-linkcheck,cargo-watch don't provide prebuilt binaries for musl host.
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,shellcheck,shfmt,wasm-pack,mdbook,cargo-binstall,grcov
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,cargo-no-dev-deps,parse-changelog,cargo-valgrind,cargo-deny,cross,dprint,just,nextest,shellcheck,shfmt,wasm-pack,mdbook,cargo-binstall,grcov,watchexec-cli
runs-on: ubuntu-latest
timeout-minutes: 60
container: ${{ matrix.container }}
Expand Down
40 changes: 21 additions & 19 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -241,22 +241,6 @@ install_cargo_binstall() {
x cargo binstall -V
fi
}
cargo_binstall() {
local tool="$1"
local version="$2"

info "install-action does not support ${tool}, fallback to cargo-binstall"

install_cargo_binstall

# By default, cargo-binstall enforce downloads over secure transports only.
# As a result, http will be disabled, and it will also set
# min tls version to be 1.2
case "${version}" in
latest) cargo binstall --force --no-confirm "${tool}" ;;
*) cargo binstall --force --no-confirm --version "${version}" "${tool}" ;;
esac
}
apt_update() {
if type -P sudo &>/dev/null; then
retry sudo apt-get -o Acquire::Retries=10 -qq update
Expand Down Expand Up @@ -425,6 +409,7 @@ if ! type -P jq &>/dev/null || ! type -P curl &>/dev/null || ! type -P tar &>/de
esac
fi

unsupported_tools=()
for tool in "${tools[@]}"; do
if [[ "${tool}" == *"@"* ]]; then
version="${tool#*@}"
Expand All @@ -438,9 +423,9 @@ for tool in "${tools[@]}"; do
else
version="latest"
fi
info "installing ${tool}@${version}"
case "${tool}" in
protoc)
info "installing ${tool}@${version}"
read_manifest "protoc" "${version}"
# Copying files to /usr/local/include requires sudo, so do not use it.
bin_dir="${HOME}/.install-action/bin"
Expand Down Expand Up @@ -475,6 +460,7 @@ for tool in "${tools[@]}"; do
rm -rf "${tmp_dir}"
;;
valgrind)
info "installing ${tool}@${version}"
case "${version}" in
latest) ;;
*) warn "specifying the version of ${tool} is not supported yet by this action" ;;
Expand All @@ -491,6 +477,7 @@ for tool in "${tools[@]}"; do
snap_install valgrind --classic
;;
cargo-binstall)
info "installing ${tool}@${version}"
case "${version}" in
latest) ;;
*) warn "specifying the version of ${tool} is not supported by this action" ;;
Expand All @@ -507,11 +494,15 @@ for tool in "${tools[@]}"; do

# Use cargo-binstall fallback if tool is not available.
if [[ ! -f "${manifest_dir}/${tool}.json" ]]; then
cargo_binstall "${tool}" "${version}"
echo
case "${version}" in
latest) unsupported_tools+=("${tool}") ;;
*) unsupported_tools+=("${tool}@${version}") ;;
esac
continue
fi

info "installing ${tool}@${version}"

# Pre-install
case "${tool}" in
shellcheck)
Expand All @@ -538,3 +529,14 @@ for tool in "${tools[@]}"; do
esac
echo
done

if [[ ${#unsupported_tools[@]} -gt 0 ]]; then
IFS=$','
info "install-action does not support ${unsupported_tools[*]}; fallback to cargo-binstall"
IFS=$'\n\t'
install_cargo_binstall
# By default, cargo-binstall enforce downloads over secure transports only.
# As a result, http will be disabled, and it will also set
# min tls version to be 1.2
cargo binstall --force --no-confirm "${unsupported_tools[@]}"
fi