From 014b3309310cb03c43876f72260b617bb3192a0e Mon Sep 17 00:00:00 2001 From: Micheal Wilkinson Date: Sat, 21 Mar 2026 20:13:40 +0000 Subject: [PATCH] ci(pr-validation): replace manual badge/gate logic with vociferate actions - Remove manual changelog validation shell script - Remove AWS CLI install and jq tooling steps - Remove hand-rolled SVG badge generation, S3 upload, and PR comment steps - Replace with coverage-badge@v1.1.0 for coverage artefact upload - Replace with decorate-pr@v1.1.0 for PR comment and changelog gate (enable-changelog-gate: true, changelog-gate-mode: strict) - Retain per-package coverage gate awk logic (Aether threshold enforcement) --- .gitea/workflows/pr-validation.yml | 130 ++++------------------------- 1 file changed, 18 insertions(+), 112 deletions(-) diff --git a/.gitea/workflows/pr-validation.yml b/.gitea/workflows/pr-validation.yml index a6248eb..e8396be 100644 --- a/.gitea/workflows/pr-validation.yml +++ b/.gitea/workflows/pr-validation.yml @@ -26,6 +26,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Go uses: actions/setup-go@v5 @@ -53,20 +55,6 @@ jobs: git diff --exit-code go.mod go.sum go mod verify - - name: Install AWS CLI v2 - uses: ankurk91/install-aws-cli-action@v1 - - - name: Ensure tooling is available - run: | - set -euo pipefail - - aws --version - - if ! command -v jq >/dev/null 2>&1; then - apt-get update - apt-get install -y jq - fi - - name: Prepare test runtime run: | set -euo pipefail @@ -81,11 +69,6 @@ jobs: set -euo pipefail go test -covermode=atomic -coverprofile=coverage.out ./... | tee go-test-coverage.log - go tool cover -html=coverage.out -o coverage.html - - total="$(go tool cover -func=coverage.out | awk '/^total:/ {sub(/%/, "", $3); print $3}')" - printf '{\n "total": "%s"\n}\n' "$total" > coverage-summary.json - printf 'total=%s\n' "$total" >> "$GITHUB_OUTPUT" set +e awk ' @@ -164,106 +147,29 @@ jobs: env: GOTOOLCHAIN: auto - - name: Generate coverage badge - env: - COVERAGE_TOTAL: ${{ steps.coverage.outputs.total }} - run: | - set -euo pipefail + - name: Upload coverage badge + id: badge + uses: https://git.hrafn.xyz/aether/vociferate/coverage-badge@v1.1.0 + with: + artefact-bucket-name: ${{ vars.ARTEFACT_BUCKET_NAME }} + artefact-bucket-endpoint: ${{ vars.ARTEFACT_BUCKET_ENDPONT }} - color="$(awk -v total="$COVERAGE_TOTAL" 'BEGIN { - if (total >= 80) print "brightgreen"; - else if (total >= 70) print "green"; - else if (total >= 60) print "yellowgreen"; - else if (total >= 50) print "yellow"; - else print "red"; - }')" - - cat > coverage-badge.svg < - - - - - - - - - - - - - - coverage - coverage - ${COVERAGE_TOTAL}% - ${COVERAGE_TOTAL}% - - - EOF - - - name: Upload PR coverage artefacts - id: upload - run: | - set -euo pipefail - - aws configure set default.s3.addressing_style path - - repo_name="${GITHUB_REPOSITORY##*/}" - prefix="${repo_name}/pull-requests/${{ github.event.pull_request.number }}" - report_url="${ARTEFACT_BUCKET_ENDPONT%/}/${ARTEFACT_BUCKET_NAME}/${prefix}/coverage.html" - badge_url="${ARTEFACT_BUCKET_ENDPONT%/}/${ARTEFACT_BUCKET_NAME}/${prefix}/coverage-badge.svg" - - aws --endpoint-url "${ARTEFACT_BUCKET_ENDPONT}" s3 cp coverage.html "s3://${ARTEFACT_BUCKET_NAME}/${prefix}/coverage.html" --content-type text/html - aws --endpoint-url "${ARTEFACT_BUCKET_ENDPONT}" s3 cp coverage-badge.svg "s3://${ARTEFACT_BUCKET_NAME}/${prefix}/coverage-badge.svg" --content-type image/svg+xml - aws --endpoint-url "${ARTEFACT_BUCKET_ENDPONT}" s3 cp coverage-summary.json "s3://${ARTEFACT_BUCKET_NAME}/${prefix}/coverage-summary.json" --content-type application/json - - printf 'report_url=%s\n' "$report_url" >> "$GITHUB_OUTPUT" - printf 'badge_url=%s\n' "$badge_url" >> "$GITHUB_OUTPUT" - - - name: Comment coverage report on pull request - env: - COVERAGE_BADGE_URL: ${{ steps.upload.outputs.badge_url }} - COVERAGE_REPORT_URL: ${{ steps.upload.outputs.report_url }} - COVERAGE_TOTAL: ${{ steps.coverage.outputs.total }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - set -euo pipefail - - marker='' - api_base="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" - - payload="$(jq -n \ - --arg marker "$marker" \ - --arg total "$COVERAGE_TOTAL" \ - --arg report "$COVERAGE_REPORT_URL" \ - --arg badge "$COVERAGE_BADGE_URL" \ - '{body: ($marker + "\n## Coverage Report\n\nCoverage total: **" + $total + "%**\n\n[HTML report](" + $report + ")\n\n![Coverage badge](" + $badge + ")")}')" - - comments="$(curl -sS -H "Authorization: token ${GITHUB_TOKEN}" "${api_base}/issues/${{ github.event.pull_request.number }}/comments")" - comment_id="$(printf '%s' "$comments" | jq -r '.[] | select(.body | contains("")) | .id' | tail -n 1)" - - if [[ -n "$comment_id" ]]; then - curl -sS -X PATCH \ - -H "Authorization: token ${GITHUB_TOKEN}" \ - -H 'Content-Type: application/json' \ - -d "$payload" \ - "${api_base}/issues/comments/${comment_id}" >/dev/null - else - curl -sS -X POST \ - -H "Authorization: token ${GITHUB_TOKEN}" \ - -H 'Content-Type: application/json' \ - -d "$payload" \ - "${api_base}/issues/${{ github.event.pull_request.number }}/comments" >/dev/null - fi + - name: Decorate PR + uses: https://git.hrafn.xyz/aether/vociferate/decorate-pr@v1.1.0 + with: + coverage-percentage: ${{ steps.badge.outputs.total }} + badge-url: ${{ steps.badge.outputs.badge-url }} + enable-changelog-gate: 'true' + changelog-gate-mode: strict - name: Add coverage summary run: | { echo '## Coverage' echo - echo '- Total: `${{ steps.coverage.outputs.total }}%`' - echo '- Report: ${{ steps.upload.outputs.report_url }}' - echo '- Badge: ${{ steps.upload.outputs.badge_url }}' + echo '- Total: `${{ steps.badge.outputs.total }}%`' + echo '- Report: ${{ steps.badge.outputs.report-url }}' + echo '- Badge: ${{ steps.badge.outputs.badge-url }}' echo echo '### Package Coverage' cat coverage-packages.md