CI: Check for required commands
Add a function to check for commands used by the `run_task` script. Move the version printing to after the check. Also print the bash version in use.
This commit is contained in:
parent
5c15ed5441
commit
01a66a7fa7
|
@ -5,13 +5,18 @@ set -ex
|
||||||
# Make all cargo invocations verbose.
|
# Make all cargo invocations verbose.
|
||||||
export CARGO_TERM_VERBOSE=true
|
export CARGO_TERM_VERBOSE=true
|
||||||
|
|
||||||
cargo --version
|
|
||||||
rustc --version
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
crate="$1"
|
crate="$1"
|
||||||
task="$2"
|
task="$2"
|
||||||
|
|
||||||
|
check_required_commands
|
||||||
|
|
||||||
|
cargo --version
|
||||||
|
rustc --version
|
||||||
|
/usr/bin/env bash --version
|
||||||
|
locale
|
||||||
|
env
|
||||||
|
|
||||||
cd "$crate"
|
cd "$crate"
|
||||||
|
|
||||||
# Building the fuzz crate is more-or-less just a sanity check.
|
# Building the fuzz crate is more-or-less just a sanity check.
|
||||||
|
@ -65,8 +70,7 @@ main() {
|
||||||
do_schemars
|
do_schemars
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Error: unknown task $task" >&2
|
err "Error: unknown task $task"
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -222,6 +226,27 @@ do_schemars() {
|
||||||
cargo test
|
cargo test
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check all the commands we use are present in the current environment.
|
||||||
|
check_required_commands() {
|
||||||
|
need_cmd cargo
|
||||||
|
need_cmd rustc
|
||||||
|
need_cmd jq
|
||||||
|
need_cmd cut
|
||||||
|
need_cmd grep
|
||||||
|
need_cmd wc
|
||||||
|
}
|
||||||
|
|
||||||
|
need_cmd() {
|
||||||
|
if ! command -v "$1" > /dev/null 2>&1
|
||||||
|
then err "need '$1' (command not found)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
err() {
|
||||||
|
echo "$1" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Main script
|
# Main script
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue