Skip to content

Expand backend unit coverage and enforce PR reports - #78

Merged
abhi1693 merged 7 commits into
masterfrom
test/backend-unit-coverage
Oct 4, 2026
Merged

abhi1693 merged 7 commits into
masterfrom
test/backend-unit-coverage

Conversation

@abhi1693

@abhi1693 abhi1693 commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

What changes and why?

Backend unit coverage was not required, and PRs did not expose it. This adds 327 unit cases across authentication, cache consistency, publication policy, reading history, retry selection, relationship coverage, scheduler orchestration, search projections, and decision-worker budgets and leases.

Whole backend unit coverage Original baseline Updated branch
Lines 67.71% 71.48%
Branches 47.80% 53.64%
Combined 63.43% 67.63%

The minimum is 67.60% combined line and branch coverage, enforced in CI and backend pre-commit checks. All 271 Python source files in all 13 backend workspaces are measured, including unimported modules. No coverage exclusions were added. The reports retain module-level line and branch counts, including uncovered paths.

CI uploads HTML, JSON, and Cobertura XML reports and updates one PR comment with test counts, workspace coverage, the minimum, and report links. It rejects missing files, omitted workspaces, inconsistent counters, empty suites, failures, and skips. The comment job has no checkout, validates numeric data, ignores superseded PR heads, and preserves human comments. Report-only reruns reuse the newest applicable unit artifact; failed unit attempts cannot borrow older passing artifacts. Unit attempt metadata supports both flat single-artifact downloads and folders for multiple artifacts. Fork and Dependabot PRs retain job summaries and artifacts because their tokens cannot comment.

Checked abhi1693/actions: its pinned Python workflow accepts custom test commands, Node setup, and artifact paths, but has no coverage PR commenter. This reuses that workflow, provisions Node 24 for comment-script regression tests, and adds reporting inside the existing ci.yml. Release dependencies and the shared Actions pin remain unchanged.

A new cache regression test also caught an incorrect metric: a matching-revision entry without a payload was counted as both a hit and a miss. It is now counted only as a miss.

Validation

Updated against master after #77 and reader touch-fixture PR #87. Final hosted CI passes on ec5779f20cc611d4bfa0d7e2e51716dd629f6570: CI required, the coverage-comment job, all CodeQL analyses and both Sonar checks. Auto-merge remains disabled.

  • 2,971 backend unit tests passed, with no failures/skips; all 271 source files across 13 workspaces measured. 67.63% combined, 71.48% line and 53.64% branch coverage, with the 67.60% minimum enforced locally, by commit hooks and on ARM64 CI.
  • The live bot comment identifies the final commit, correct counts, per-workspace metrics and 67.60% floor. It updates the existing comment rather than adding duplicates. HTML/JSON/XML and raw coverage data are retained as artifacts.
  • 1,136 PostgreSQL/Redis integration tests, populated upgrades and recovery checks passed. 818 web and 648 admin tests, frontend builds/lint/types, actual web/Chrome/Edge parity, admin/API journeys, security, ARM64 images and the performance gate passed. No production speed improvement is claimed.
  • Sonar passes with 83.6% new-code coverage, zero new duplication and zero open issues. Its first updated-head run flagged three Bash conditions; those now use [[ ... ]]. No gate, rule or source-exclusion changes were made.
  • Unit inventory reports remain backend-only, while Sonar combines all four raw Python databases and retains measured CI utilities. Repository-relative XML preserves distinct filenames across service roots. The new real Coverage.py regression fails before the path fix and passes afterward.
  • Local 119 focused gate/report/catalog tests, 28 real PostgreSQL 18 / Redis 8 cache/catalog/scheduler tests, and 88 focused checks after the shell fix passed. Python checks, commit hooks, Bash syntax, ShellCheck, actionlint and whitespace checks passed.
  • Fork/Dependabot and report-only artifact behavior remain covered by the actual comment JavaScript regressions. Unit failures cannot reuse older passing data.
  • GitHub's separate managed AI findings scan remains unavailable because its monthly quota is exhausted (HTTP 402); repository CodeQL checks passed.
  • No visible UI changes; screenshots are not applicable.

Rollout notes

pytest-cov and coverage are development-only dependencies. No schema or API contracts change. Integration tests remain independent requirements and do not inflate unit coverage. The only runtime change corrects catalog-cache read metrics.

Whole-backend 100% was not reached. The reports retain the uncovered paths; larger follow-up targets include discovery, recommendations, topic proposals, user profiles, and research-verification workers. PostgreSQL/Redis transaction behavior still requires real integration verification alongside unit tests.

Ready for review

  • The description explains the change and validation results, including gaps.
  • Relevant documentation and regression tests are updated.

Before merge, keep the current commit passing CI required and standard CodeQL, and resolve review conversations.

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

PR reader API performance

Result: INCONCLUSIVE

8 inconclusive. Zero request failures across all six runs.

Base 7b3c9255a8fb2b0d3ff5950566831cb63b59db09 → PR ec5779f20cc611d4bfa0d7e2e51716dd629f6570

Three independent runs per revision, each on a fresh GitHub-hosted ARM64 runner. 16 users, 60 seconds/run, 1,000 synthetic articles, cache off, five PgBouncer slots.

Latency comparison

All latency values are in milliseconds; lower is better. Values are medians of three runs.

Route Base p95 PR p95 Change Result
All requests 120 110 -10 (-8.3%) Inconclusive
Latest feed 160 150 -10 (-6.2%) Inconclusive
Feed pagination 110 90 -20 (-18.2%) Inconclusive
Article detail 97 90 -7 (-7.2%) Inconclusive
Source feed 76 110 +34 (+44.7%) Inconclusive
Topic feed 110 100 -10 (-9.1%) Inconclusive
Feed filters 96 75 -21 (-21.9%) Inconclusive
Sources 43 48 +5 (+11.6%) Inconclusive
Topics 61 44 -17 (-27.9%) Inconclusive
Additional latency and throughput metrics

Each cell shows base → PR. Latencies are in milliseconds.

Endpoint p50 p99 Requests/s
Aggregated 34 → 32 170 → 160 30.19 → 30.39
/v1/feed [latest] 50 → 49 180 → 180 9.07 → 8.69
/v1/feed [page] 30 → 30 150 → 180 3.50 → 3.76
/v1/articles/[id] 21 → 21 140 → 140 6.13 → 6.32
/v1/feed [source] 32 → 28 130 → 110 1.91 → 1.87
/v1/feed [topic] 31 → 30 180 → 170 1.98 → 1.73
/v1/feed/options 23 → 22 140 → 120 2.53 → 2.61
/v1/sources 12 → 12 73 → 71 2.53 → 2.65
/v1/topics 15 → 14 120 → 85 2.53 → 2.65
Individual runs
Run Requests Failures Exit code
Base 1 1681 0 0
Base 2 1705 0 0
Base 3 1697 0 0
PR 1 1697 0 0
PR 2 1713 0 0
PR 3 1711 0 0
How to interpret this report

Regressed / Improved: a p95 regression needs >20% and >20 ms increase in the medians and at least two head samples versus the base median. Improvements use the inverse threshold. Within threshold means the change did not meet both thresholds.

Inconclusive: a within-revision p95 range >35% of its median and >20 ms is too noisy for a confident latency verdict.

Inconclusive latency comparisons are non-blocking: the check passes without claiming an improvement. Confirmed regressions and test/report errors fail the PR gate. Throughput is descriptive: paced users do not measure maximum capacity. This uncached public API test does not establish production health, browser performance or worker capacity. Separate runners can differ in hardware or host load; repetitions and noise checks reduce but cannot eliminate that uncertainty.

Full HTML/CSV reports and logs · attempt 1

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Backend unit coverage

PASS · minimum combined coverage 67.60%.

Tests: 2971 passed, 0 failed, 0 skipped. Source files: 271.

Workspace Lines Branches Combined
All backend code 71.48% 53.64% 67.63%
apps/admin-api 64.92% 35.76% 60.09%
apps/aggregator 73.15% 57.09% 69.46%
apps/api 69.97% 55.88% 67.39%
apps/article-enrichment-worker 80.00% 50.00% 71.43%
apps/cli 68.76% 42.93% 64.81%
apps/images-worker 80.00% 50.00% 71.43%
apps/mcp 79.90% 73.88% 78.77%
apps/notifications 80.73% 73.53% 79.02%
apps/search-indexer 85.48% 85.71% 85.53%
apps/source-discovery-worker 80.00% 50.00% 71.43%
apps/user-api 59.67% 32.90% 54.71%
packages/core 73.62% 56.50% 69.53%
packages/http 93.93% 86.75% 92.21%

Unit coverage includes every backend workspace. PostgreSQL/Redis integration tests run separately.

Commit: ec5779f · HTML, JSON, XML reports and job logs · attempt 1

@gitar-bot

gitar-bot Bot commented Oct 4, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · CI enforces backend coverage and reports results; cache-read metrics are corrected.

Expands backend unit coverage from 63.43% to 67.63% combined with 327 new unit cases across nine subsystems, enforces a 67.60% minimum in CI and pre-commit checks, and adds PR reporting with coverage metrics, workspace breakdowns, and HTML/JSON/Cobertura artifacts. No issues found.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

sonarqubecloud Bot commented Oct 4, 2026

Copy link
Copy Markdown

@abhi1693
abhi1693 merged commit 9ba10ce into master Oct 4, 2026
58 checks passed
@abhi1693
abhi1693 deleted the test/backend-unit-coverage branch October 4, 2026 14:57
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.

1 participant