1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#! /bin/sh
die() {
printf "\e[31:1mError: %s\e[0m\n" "$1" >&2
exit 1
}
if [ -z "$RUST_CHAIN" ]
then
die "RUST_CHAIN environment variable is not set! RUST_CHAIN={stable,nightly}"
fi
(
cd "$(git rev-parse --show-toplevel)" || die "cannot find project root"
# Badges!
mkdir -p ./target/shields
if cargo "+${RUST_CHAIN}" --color=always build --all-targets; then
cat <<EOF > "./target/shields/$RUST_CHAIN-build.json"
{
"color": "brightgreen",
"isError": true,
"label": "$RUST_CHAIN build",
"message": "passing",
"schemaVersion": 1
}
EOF
else
PRV_EXIT=$?
cat <<EOF > "./target/shields/$RUST_CHAIN-build.json"
{
"color": "red",
"isError": true,
"label": "$RUST_CHAIN build",
"message": "failed",
"schemaVersion": 1
}
EOF
exit $PRV_EXIT
fi
cargo "+${RUST_CHAIN}" --color=always test --no-fail-fast
exitcode=$?
# create badge for `cargo test`
cargo "+${RUST_CHAIN}" test --no-fail-fast -- -Z unstable-options --format json | \
jq -s -f ./scripts/shields-from-tests.jq > ./target/shields/cargo-test.json
exit $exitcode
)
|