Skip to content

Post coverage report as a PR comment via couve - #285

Closed
pnzrfst wants to merge 2 commits into
masterfrom
report-coverage-on-pr
Closed

pnzrfst wants to merge 2 commits into
masterfrom
report-coverage-on-pr

Conversation

@pnzrfst

@pnzrfst pnzrfst commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Resumo

Segunda PR da série de migração qlty → couve (empilhada sobre #284). Adiciona um comentário automático de cobertura nas PRs, sem nenhum gate ainda (só informativo).

O que muda

  • spec/spec_helper.rb — volta a gerar coverage/coverage.json, mas com o simplecov_json_formatter oficial (já é dependência do próprio gem simplecov, não precisa de gem nova) — não o simplecov-json de terceiros que a Remove qlty integration from CI #284 removeu. É o schema (meta.simplecov_version + coverage.<arquivo>.lines) que o cc-test-reporter espera; o simplecov-json antigo tinha outro schema, incompatível.
  • .github/workflows/config.yml:
    • trigger ganha pull_request: (mantendo push só em master, pra não rodar duas vezes com a PR aberta);
    • permissions: pull-requests: write, necessário pra comentar na PR;
    • fetch-depth: 0 no checkout do job rspec, necessário pra git diff contra a branch base da PR;
    • dois steps novos, só em pull_request: converter coverage.json pro formato CodeClimate via cc-test-reporter (binário baixado do mirror github.com/asseinfo/test-reporter, já que a URL original da Code Climate está fora do ar) e rodar couve escopado aos arquivos alterados; e postar/atualizar (via sentinela <!-- couve-coverage -->) um único comentário na PR, em vez de acumular um novo a cada push.

O que NÃO muda

  • Sem --fail-on-low-coverage — isso fica pra uma terceira PR, depois que decidirmos o que fazer com os arquivos que hoje estão abaixo de 100% (incluindo código de suporte de teste, que precisa ser excluído do gate antes de travar merge nele).

Plano de teste

  • bundle exec rspec local: 291 examples, 0 failures, coverage/coverage.json no schema correto
  • bundle exec rubocop --display-cop-names --parallel local: sem ofensas
  • Pipeline cc-test-reporter → couve rodado localmente contra o diff real desta branch vs. master: relatório vazio (esperado — essa PR não toca nenhum arquivo Ruby coberto)
  • Comentário de cobertura aparece na PR (só testável rodando de verdade no Actions)

🤖 Generated with Claude Code

@pnzrfst pnzrfst self-assigned this Aug 18, 2026
@github-actions

github-actions Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Nenhum arquivo coberto por testes foi alterado nesta PR.

@pnzrfst pnzrfst linked an issue Aug 18, 2026 that may be closed by this pull request
Base automatically changed from remove-qlty-ci to master August 20, 2026 12:10
pnzrfst and others added 2 commits August 20, 2026 09:10
Reintroduces a SimpleCov JSON formatter, but the official
`simplecov_json_formatter` (already a simplecov dependency) instead of
the third-party `simplecov-json` removed in the qlty cleanup: it's the
schema cc-test-reporter's simplecov parser actually expects
(`meta.simplecov_version` + `coverage.<file>.lines`).

On pull_request events, converts coverage.json to CodeClimate format,
scopes it to the PR's changed files with couve, and upserts a single
PR comment (matched by an HTML sentinel) instead of piling up a new
one per push. Informational only — no --fail-on-low-coverage yet.

Refs #283

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Instead of posting a coverage table with just the header row (no data),
show a clear "nothing to report" message when the PR's diff doesn't
touch any Ruby file SimpleCov tracks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gabrieldeespindula

Copy link
Copy Markdown
Member

Closing in favor of #289.

What we want from the PR comment is the project total and the delta vs master — couve computes neither (there's no baseline anywhere in this flow). And with a single RSpec suite, the cc-test-reporter step exists only to convert SimpleCov's JSON into the CodeClimate schema couve reads. That conversion pays off in facil123, where it normalizes and sums 5 coverage sources; here it's pure overhead.

#289 gets there with fewer moving parts: octocov reads coverage/.resultset.json natively, stores the master baseline as an Actions artifact, and posts total + delta using only the built-in GITHUB_TOKEN. Uncovered lines stay visible in the coverage-html artifact. A gate, when we want one, is a single line (coverage.acceptable) — so the same reasoning applies to #286.

Good ideas from this stack live on: #289 reuses the trigger change you made here, and #288's coverage backfill is still worth merging after a rebase onto master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remover integração com qlty do CI (projeto pausado no Qlty Cloud)

2 participants