mirror of
https://github.com/boostorg/boost-ci.git
synced 2026-01-19 04:02:12 +00:00
170 lines
6.5 KiB
Bash
Executable File
170 lines
6.5 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Generates markdown for README build status badges.
|
|
#
|
|
# Copyright 2025 James E. King III <jking@apache.org>
|
|
#
|
|
|
|
set -eu
|
|
|
|
#!/bin/bash
|
|
|
|
usage() {
|
|
cat << EOF
|
|
Usage: $0 [OPTIONS]
|
|
|
|
Generate a markdown table with badges suitable for a README.md file in a Boost library repository.
|
|
|
|
Options:
|
|
-r, --repo REPO The name of the Boost library repository (e.g., "uuid").
|
|
-b, --appveyorbadge ID The appveyor badge id (e.g., "xmeanhs47ke0dpo9" for uuid).
|
|
-o, --appveyororg ORG The appveyor organization (default: "cppalliance").
|
|
-c, --codecovbadge ID The codecov.io badge id (e.g., "6falIr5npV" for uuid).
|
|
-y, --coverity PROJ The coverity project name (e.g., "boostorg-uuid").
|
|
-p, --azure Include an Azure Pipelines column.
|
|
-d, --drone Include a Drone column.
|
|
-n, --notcode Hide Deps, Docs, and Tests columns and skip the "develop" branch.
|
|
-h, --help Display this help message
|
|
|
|
Note:
|
|
- Project tokens are considered secrets. Do not use them in badge slugs. Find them in the
|
|
"Badges" settings of your AppVeyor or codecov.io project for that repository.
|
|
EOF
|
|
exit 1
|
|
}
|
|
|
|
ORIGARGS=$@
|
|
ARGS=$(getopt --longoptions "repo:,appveyor:,appveyororg:,codecovbadge:,coverity:,azure,drone,notcode,help" "r:a:o:c:v:y:pdnh" -- "$@")
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to parse options" >&2
|
|
usage
|
|
fi
|
|
|
|
eval set -- "$ARGS"
|
|
|
|
REPO=
|
|
APPVEYORBADGEID=
|
|
APPVEYORORG=cppalliance
|
|
CODECOVBADGE=
|
|
COVERITY=
|
|
INCLUDE_AZURE=0
|
|
INCLUDE_DRONE=0
|
|
NOTCODE=0
|
|
|
|
while true; do
|
|
case "${1:-*}" in
|
|
-r | --repo) REPO="$2"; shift 2 ;;
|
|
-b | --appveyorbadge) APPVEYORBADGEID="$2"; shift 2 ;;
|
|
-o | --appveyororg) APPVEYORORG="$2"; shift 2 ;;
|
|
-c | --codecovbadge) CODECOVBADGE="$2"; shift 2 ;;
|
|
-y | --coverity) COVERITY="$2"; shift 2 ;;
|
|
-h | --help) usage ;;
|
|
-p | --azure) INCLUDE_AZURE=1; shift ;;
|
|
-d | --drone) INCLUDE_DRONE=1; shift ;;
|
|
-n | --notcode) NOTCODE=1; shift ;;
|
|
--) shift ;;
|
|
*) break ;;
|
|
esac
|
|
done
|
|
|
|
# Compose header and separator rows
|
|
HEADER="| Branch | GHA CI "
|
|
SEPARATOR="| :-------------: | ------ "
|
|
if [ -n "$APPVEYORBADGEID" ]; then
|
|
HEADER="${HEADER}| Appveyor "
|
|
SEPARATOR="${SEPARATOR}| -------- "
|
|
fi
|
|
if [ "$INCLUDE_AZURE" -eq 1 ]; then
|
|
HEADER="${HEADER}| Azure Pipelines "
|
|
SEPARATOR="${SEPARATOR}| --------------- "
|
|
fi
|
|
if [ "$INCLUDE_DRONE" -eq 1 ]; then
|
|
HEADER="${HEADER}| Drone "
|
|
SEPARATOR="${SEPARATOR}| ----- "
|
|
fi
|
|
if [ -n "$COVERITY" ]; then
|
|
HEADER="${HEADER}| Coverity Scan "
|
|
SEPARATOR="${SEPARATOR}| ------------- "
|
|
fi
|
|
if [ -n "$CODECOVBADGE" ]; then
|
|
HEADER="${HEADER}| codecov.io "
|
|
SEPARATOR="${SEPARATOR}| ---------- "
|
|
fi
|
|
if [ "$NOTCODE" -eq 0 ]; then
|
|
HEADER="${HEADER}| Deps | Docs | Tests "
|
|
SEPARATOR="${SEPARATOR}| ---- | ---- | ----- "
|
|
fi
|
|
HEADER="${HEADER}|"
|
|
SEPARATOR="${SEPARATOR}|"
|
|
|
|
cat <<EOF
|
|
<!-- boost-ci/tools/makebadges.sh ${ORIGARGS} -->
|
|
$HEADER
|
|
$SEPARATOR
|
|
EOF
|
|
|
|
# Helper for Azure badge
|
|
azure_badge() {
|
|
local branch="$1"
|
|
echo "[](https://dev.azure.com/boostorg/${REPO}/_build/latest?definitionId=8&branchName=${branch})"
|
|
}
|
|
|
|
# Helper for Drone badge
|
|
drone_badge() {
|
|
local branch="$1"
|
|
echo "[](https://drone.cpp.al/boostorg/${REPO})"
|
|
}
|
|
|
|
# Compose master row
|
|
ROW="| [\`master\`](https://github.com/boostorg/${REPO}/tree/master) "
|
|
ROW="${ROW}| [](https://github.com/boostorg/${REPO}/actions?query=branch:master) "
|
|
if [ -n "$APPVEYORBADGEID" ]; then
|
|
ROW="${ROW}| [](https://ci.appveyor.com/project/${APPVEYORORG}/${REPO//_/-}/branch/master) "
|
|
fi
|
|
if [ "$INCLUDE_AZURE" -eq 1 ]; then
|
|
ROW="${ROW}| $(azure_badge master) "
|
|
fi
|
|
if [ "$INCLUDE_DRONE" -eq 1 ]; then
|
|
ROW="${ROW}| $(drone_badge master) "
|
|
fi
|
|
if [ -n "$COVERITY" ]; then
|
|
ROW="${ROW}| [](https://scan.coverity.com/projects/boostorg-${REPO}) "
|
|
fi
|
|
if [ -n "$CODECOVBADGE" ]; then
|
|
ROW="${ROW}| [](https://codecov.io/gh/boostorg/${REPO}/tree/master) "
|
|
fi
|
|
if [ "$NOTCODE" -eq 0 ]; then
|
|
ROW="${ROW}| [](https://pdimov.github.io/boostdep-report/master/${REPO}.html) "
|
|
ROW="${ROW}| [](https://www.boost.org/doc/libs/master/libs/${REPO}) "
|
|
ROW="${ROW}| [](https://www.boost.org/development/tests/master/developer/${REPO}.html) "
|
|
fi
|
|
ROW="${ROW}|"
|
|
echo "$ROW"
|
|
|
|
# Compose develop row
|
|
if [ "$NOTCODE" -eq 0 ]; then
|
|
ROW="| [\`develop\`](https://github.com/boostorg/${REPO}/tree/develop) "
|
|
ROW="${ROW}| [](https://github.com/boostorg/${REPO}/actions?query=branch:develop) "
|
|
if [ -n "$APPVEYORBADGEID" ]; then
|
|
ROW="${ROW}| [](https://ci.appveyor.com/project/${APPVEYORORG}/${REPO//_/-}/branch/develop) "
|
|
fi
|
|
if [ "$INCLUDE_AZURE" -eq 1 ]; then
|
|
ROW="${ROW}| $(azure_badge develop) "
|
|
fi
|
|
if [ "$INCLUDE_DRONE" -eq 1 ]; then
|
|
ROW="${ROW}| $(drone_badge develop) "
|
|
fi
|
|
if [ -n "$COVERITY" ]; then
|
|
ROW="${ROW}| [](https://scan.coverity.com/projects/boostorg-${REPO}) "
|
|
fi
|
|
if [ -n "$CODECOVBADGE" ]; then
|
|
ROW="${ROW}| [](https://codecov.io/gh/boostorg/${REPO}/tree/develop) "
|
|
fi
|
|
ROW="${ROW}| [](https://pdimov.github.io/boostdep-report/develop/${REPO}.html) "
|
|
ROW="${ROW}| [](https://www.boost.org/doc/libs/develop/libs/${REPO}) "
|
|
ROW="${ROW}| [](https://www.boost.org/development/tests/develop/developer/${REPO}.html) "
|
|
ROW="${ROW}|"
|
|
echo "$ROW"
|
|
fi
|