From 97831e7bd55154dc948f0f316c0da8985e753cb4 Mon Sep 17 00:00:00 2001 From: myrmidex Date: Sun, 8 Mar 2026 12:58:12 +0100 Subject: [PATCH] Revert "25 - Add code coverage PR comment to CI workflow" This reverts commit e0ca89e8e89e64950e2a5b62b3f085bc356a7802. --- .forgejo/workflows/ci.yml | 72 +-------------------------------------- 1 file changed, 1 insertion(+), 71 deletions(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 8b4c936..920cd91 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -19,7 +19,6 @@ jobs: with: php-version: '8.3' extensions: pdo_sqlite, mbstring, xml, dom - coverage: pcov - name: Cache Composer dependencies uses: https://data.forgejo.org/actions/cache@v4 @@ -41,73 +40,4 @@ jobs: run: vendor/bin/phpstan analyse - name: Tests - run: php artisan test --coverage-clover coverage.xml --coverage-text - - - name: Parse coverage - if: github.event_name == 'pull_request' - id: coverage - run: | - COVERAGE=$(php -r ' - $xml = simplexml_load_file("coverage.xml"); - if ($xml === false || !isset($xml->project->metrics)) { - echo "0"; - exit; - } - $metrics = $xml->project->metrics; - $statements = (int) $metrics["statements"]; - $covered = (int) $metrics["coveredstatements"]; - echo $statements > 0 ? round(($covered / $statements) * 100, 2) : 0; - ') - echo "percentage=$COVERAGE" >> "$GITHUB_OUTPUT" - - - name: Comment coverage on PR - if: github.event_name == 'pull_request' - env: - FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} - COVERAGE: ${{ steps.coverage.outputs.percentage }} - REPO: ${{ github.repository }} - SERVER_URL: ${{ github.server_url }} - COMMIT_SHA: ${{ github.sha }} - run: | - API_URL="${SERVER_URL}/api/v1/repos/${REPO}/issues/${PR_NUMBER}/comments" - MARKER="" - - BODY="${MARKER} - ## Code Coverage Report - - | Metric | Value | - |--------|-------| - | **Line Coverage** | ${COVERAGE}% | - - _Updated by CI — commit ${COMMIT_SHA}_" - - # Find existing coverage comment - EXISTING=$(curl -sf -H "Authorization: token ${FORGEJO_TOKEN}" \ - "${API_URL}?limit=50" | \ - php -r ' - $comments = json_decode(file_get_contents("php://stdin"), true); - if (!is_array($comments)) exit; - foreach ($comments as $c) { - if (str_contains($c["body"], "")) { - echo $c["id"]; - exit; - } - } - ' || true) - - if [ -n "$EXISTING" ]; then - # Update existing comment - curl -sf -X PATCH \ - -H "Authorization: token ${FORGEJO_TOKEN}" \ - -H "Content-Type: application/json" \ - -d "$(php -r 'echo json_encode(["body" => $argv[1]]);' "$BODY")" \ - "${SERVER_URL}/api/v1/repos/${REPO}/issues/comments/${EXISTING}" > /dev/null - else - # Create new comment - curl -sf -X POST \ - -H "Authorization: token ${FORGEJO_TOKEN}" \ - -H "Content-Type: application/json" \ - -d "$(php -r 'echo json_encode(["body" => $argv[1]]);' "$BODY")" \ - "${API_URL}" > /dev/null - fi + run: php artisan test