2022-02-14 15:13:25 +03:00
|
|
|
#!/usr/bin/env bash
|
2022-02-24 09:06:03 +03:00
|
|
|
set -u
|
2022-02-14 15:13:25 +03:00
|
|
|
|
|
|
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
|
|
|
|
|
|
function prepend() { while read line; do echo "${1}${line}"; done; }
|
|
|
|
|
|
|
|
crates=$(\
|
|
|
|
cargo metadata --format-version 1 \
|
|
|
|
| jq -r '.workspace_members[]' \
|
|
|
|
| cut -f1 -d" " \
|
|
|
|
| sort \
|
|
|
|
)
|
|
|
|
|
2022-02-24 09:06:03 +03:00
|
|
|
# yq query syntax is weird, so we have to use jq
|
2022-04-15 16:47:44 +03:00
|
|
|
json_str="$(yq -o=json $SCRIPT_DIR/tests.yml)"
|
2022-02-24 09:06:03 +03:00
|
|
|
|
2022-02-14 15:13:25 +03:00
|
|
|
for crate in $crates
|
|
|
|
do
|
|
|
|
echo "- crate: $crate"
|
|
|
|
echo " os: ubuntu-latest"
|
|
|
|
|
2022-09-06 19:47:06 +03:00
|
|
|
if echo $json_str | jq -e "select(.host.\"$crate\")" > /dev/null; then
|
|
|
|
echo " runner: " `echo $json_str | jq -e -r ".host.\"$crate\""`
|
|
|
|
|
|
|
|
else
|
|
|
|
echo " runner: ubuntu-latest"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if echo $json_str | jq -e ".check.\"$crate\"" > /dev/null; then
|
2022-02-24 09:06:03 +03:00
|
|
|
echo " check: |"
|
|
|
|
|
2022-07-09 13:15:12 +03:00
|
|
|
check_commands=$(echo $json_str | jq -e -r ".check.\"$crate\" | .[]")
|
2022-02-24 09:06:03 +03:00
|
|
|
|
|
|
|
while IFS= read -r line; do
|
2022-09-06 19:47:06 +03:00
|
|
|
echo " $line"
|
2022-02-24 09:06:03 +03:00
|
|
|
done <<< "$check_commands"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2022-09-06 19:47:06 +03:00
|
|
|
if echo $json_str | jq -e "select(.os.macos | index(\"$crate\"))" > /dev/null; then
|
2022-02-14 15:13:25 +03:00
|
|
|
echo "- crate: $crate"
|
|
|
|
echo " os: macos-latest"
|
2022-09-06 19:47:06 +03:00
|
|
|
echo " runner: macos-latest"
|
2022-02-14 15:13:25 +03:00
|
|
|
fi
|
|
|
|
|
2022-09-06 19:47:06 +03:00
|
|
|
if echo $json_str | jq -e "select(.os.windows | index(\"$crate\"))" > /dev/null; then
|
2022-02-14 15:13:25 +03:00
|
|
|
echo "- crate: $crate"
|
|
|
|
echo " os: windows-latest"
|
2022-09-06 19:47:06 +03:00
|
|
|
echo " runner: windows-latest"
|
2022-02-14 15:13:25 +03:00
|
|
|
fi
|
|
|
|
done
|