Refactor core interfaces and CLI commands to remove direct db depende… #202
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: Coverage | |
| on: | |
| workflow_dispatch: {} | |
| push: | |
| branches: [ main ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| coverage: | |
| name: Run coverage and generate badge | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '1.25.7' | |
| - name: Run tests and collect coverage | |
| run: | | |
| set -eux | |
| # Produce a unified coverage profile across packages | |
| go test -coverpkg=./... ./... -coverprofile=coverage.out || true | |
| # Some shells / platforms may produce a file named 'coverage' without extension. | |
| if [ -f coverage ] && [ ! -f coverage.out ]; then | |
| mv coverage coverage.out || true | |
| fi | |
| if [ -f coverage.out ]; then | |
| # Exclude test utility packages and legacy TUI from coverage metrics (not part of product surface). | |
| # Keep the first 'mode:' line, filter out entries for internal/testutil and internal/tui, then regenerate coverage report. | |
| head -n1 coverage.out > coverage.filtered.out || true | |
| # Remove coverage entries for test helpers, legacy TUI, and testdata directories | |
| tail -n +2 coverage.out | grep -v -E '(^github.com/toeirei/keymaster/internal/testutil|^github.com/toeirei/keymaster/internal/tui|testdata)' >> coverage.filtered.out || true | |
| mv coverage.filtered.out coverage.out || true | |
| go tool cover -func=coverage.out > coverage.txt || true | |
| else | |
| echo "no coverage file produced" > coverage.txt | |
| fi | |
| - name: Generate SVG badge | |
| run: | | |
| set -eux | |
| percent=$(awk '/total:/ {print $3}' coverage.txt | sed 's/%//') || true | |
| if [ -z "$percent" ]; then percent=0; fi | |
| width=$(awk -v p="$percent" 'BEGIN{printf("%d", 200*p/100)}') | |
| cat > coverage.svg <<'EOF' | |
| <svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"> | |
| <rect width="200" height="20" fill="#555"/> | |
| <rect width="WIDTH" height="20" x="0" y="0" fill="#4c1"/> | |
| <text x="100" y="14" font-family="Verdana" font-size="11" fill="#fff" text-anchor="middle">coverage PERCENT%</text> | |
| </svg> | |
| EOF | |
| sed -i "s/WIDTH/${width}/g" coverage.svg | |
| sed -i "s/PERCENT/${percent}/g" coverage.svg | |
| - name: Upload coverage artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: coverage | |
| path: | | |
| coverage.svg | |
| coverage.txt | |
| coverage.out |