Skip to content

Merge pull request #15 from Avicted/feature/voice-daemon #10

Merge pull request #15 from Avicted/feature/voice-daemon

Merge pull request #15 from Avicted/feature/voice-daemon #10

Workflow file for this run

name: badge
on:
push:
branches:
- "main"
workflow_dispatch:
permissions:
contents: write
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: true
- name: Install native dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
pkg-config \
libopus-dev \
libopusfile-dev \
libx11-dev \
libxtst-dev \
xvfb \
xauth
- name: Generate coverage
run: xvfb-run -a ./scripts/coverage.sh | tee coverage-report.txt
- name: Generate coverage badge
run: |
total=$(go tool cover -func=coverage.out | awk '/^total:/ { sub(/%/,"",$3); print $3 }')
if [[ -z "$total" ]]; then
echo "coverage total not found" >&2
exit 1
fi
color="red"
if awk "BEGIN {exit !($total >= 80)}"; then
color="brightgreen"
elif awk "BEGIN {exit !($total >= 60)}"; then
color="yellow"
fi
mkdir -p public/badges
cat > public/badges/coverage.svg <<EOF
<svg xmlns="http://www.w3.org/2000/svg" width="130" height="20" role="img" aria-label="coverage: ${total}%">
<linearGradient id="s" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<rect rx="3" width="130" height="20" fill="#555"/>
<rect rx="3" x="62" width="68" height="20" fill="${color}"/>
<path fill="${color}" d="M62 0h4v20h-4z"/>
<rect rx="3" width="130" height="20" fill="url(#s)"/>
<g fill="#fff" text-anchor="middle" font-family="Verdana,DejaVu Sans,sans-serif" font-size="11">
<text x="31" y="14">coverage</text>
<text x="96" y="14">${total}%</text>
</g>
</svg>
EOF
- name: Prepare Pages artifacts
run: |
touch public/.nojekyll
cat > public/index.html <<'EOF'
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Dialtone Badges</title>
</head>
<body>
<h1>Dialtone Badges</h1>
<p><a href="badges/coverage.svg">coverage.svg</a></p>
</body>
</html>
EOF
- name: Publish coverage badge
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: public
keep_files: true