Merge pull request #19 from Avicted/feature/voice-daemon #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | | |
| set -o pipefail | |
| 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 | |
| state_top="#E05D44" | |
| state_bottom="#CB2431" | |
| if awk "BEGIN {exit !($total >= 80)}"; then | |
| state_top="#34D058" | |
| state_bottom="#28A745" | |
| elif awk "BEGIN {exit !($total >= 60)}"; then | |
| state_top="#DBAB09" | |
| state_bottom="#B08800" | |
| 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}%"> | |
| <defs> | |
| <linearGradient id="workflow-fill" x1="50%" y1="0%" x2="50%" y2="100%"> | |
| <stop stop-color="#444D56" offset="0%"/> | |
| <stop stop-color="#24292E" offset="100%"/> | |
| </linearGradient> | |
| <linearGradient id="state-fill" x1="50%" y1="0%" x2="50%" y2="100%"> | |
| <stop stop-color="${state_top}" offset="0%"/> | |
| <stop stop-color="${state_bottom}" offset="100%"/> | |
| </linearGradient> | |
| </defs> | |
| <rect rx="3" width="130" height="20" fill="url(#workflow-fill)"/> | |
| <rect rx="3" x="62" width="68" height="20" fill="url(#state-fill)"/> | |
| <path fill="url(#state-fill)" d="M62 0h4v20h-4z"/> | |
| <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 |