Skip to content

Skip reports coverage when no tests are available#345

Merged
coisa merged 4 commits into
mainfrom
chore/344-skip-reports-tests-when-unavailable
May 13, 2026
Merged

Skip reports coverage when no tests are available#345
coisa merged 4 commits into
mainfrom
chore/344-skip-reports-tests-when-unavailable

Conversation

@coisa
Copy link
Copy Markdown
Contributor

@coisa coisa commented May 13, 2026

Summary

  • Updates standards:reports to resolve project capabilities before running coverage.
  • Skips coverage generation when no tests or PHP source files are detected.
  • Keeps docs and metrics report generation unchanged.

Testing

  • Implemented and updated dedicated report command unit tests.
  • Added coverage metadata test annotations required by structured output runs.
  • Could not complete full dev-tools pre-commit in this environment because ./bin/dev-tools tests --coverage=.dev-tools/coverage returns process failure code while tests report assertions: 2148, errors: 0, failures: 0, risky: 0.

Changelog

  • Added unreleased entry for skipping reports coverage in repositories without detectable test surface.

Closes #344

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ff5b0068-0d9a-47d5-9096-6dd865b2c233

📥 Commits

Reviewing files that changed from the base of the PR and between 626b33b and 9b4f3a7.

📒 Files selected for processing (22)
  • .github/wiki
  • src/Config/ComposerDependencyAnalyserConfig.php
  • src/Console/Command/ReportsCommand.php
  • src/Console/Command/TestsCommand.php
  • src/Console/DevTools.php
  • src/Path/ManagedWorkspace.php
  • src/Path/WorkingProjectPathResolver.php
  • src/Project/ProjectCapabilities.php
  • src/Project/ProjectCapabilitiesResolver.php
  • tests/Composer/Capability/DevToolsCommandProviderTest.php
  • tests/Composer/PluginTest.php
  • tests/Config/ComposerDependencyAnalyserConfigTest.php
  • tests/Config/ECSConfigTest.php
  • tests/Config/RectorConfigTest.php
  • tests/Console/Command/ReportsCommandTest.php
  • tests/Console/Command/TestsCommandTest.php
  • tests/Console/DevToolsTest.php
  • tests/Console/Input/HasJsonOptionTest.php
  • tests/Environment/EnvironmentTest.php
  • tests/Path/ManagedWorkspaceTest.php
  • tests/Path/WorkingProjectPathResolverTest.php
  • tests/Project/ProjectCapabilitiesResolverTest.php

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • The reports command now intelligently skips coverage report generation when no testable PHP source files are detected, while still generating documentation and metrics reports.
  • Improvements

    • Enhanced detection of PHP source files in Composer-exposed directories for more accurate test capability assessment.
    • Improved environment variable handling for more reliable configuration management.

Walkthrough

The reports command now conditionally skips coverage report generation when no runnable tests are detected, while still generating documentation and metrics. ReportsCommand depends on ProjectCapabilitiesResolverInterface and queues the tests/coverage process only when canRunTests() is true; otherwise it logs a warning. Tests verify both the normal path and the new skip-coverage scenario.

Changes

Conditional Coverage Report Generation

Layer / File(s) Summary
Conditional Coverage Logic in ReportsCommand
src/Console/Command/ReportsCommand.php, tests/Console/Command/ReportsCommandTest.php
ReportsCommand accepts ProjectCapabilitiesResolverInterface and conditionally queues the tests/coverage process only when canRunTests() is true; otherwise logs a warning and skips. Tests added to assert skip behavior; changelog updated.
Project capabilities detection
src/Project/ProjectCapabilities.php, src/Project/ProjectCapabilitiesResolver.php, tests/Project/ProjectCapabilitiesResolverTest.php
canRunTests() now requires Composer-exposed PHP source files; resolver inspects autoload paths and recursively detects .php files; adds test for empty autoload dirs.
EnvironmentInterface plumbing
src/Path/ManagedWorkspace.php, src/Path/WorkingProjectPathResolver.php, src/Config/ComposerDependencyAnalyserConfig.php
Core path/config components accept an optional EnvironmentInterface and read environment values via $environment->get(...) instead of getenv().
TestsCommand & DevTools constants
src/Console/Command/TestsCommand.php, src/Console/DevTools.php
TestsCommand now depends on EnvironmentInterface, exposes agent/min-coverage constants publicly, and reads minimum coverage from environment; DevTools exposes ENV_AUTO_UPDATE.
Tests, metadata, and env-mocking migration
tests/*, .github/wiki
Many tests migrated from putenv/global mutation to injected EnvironmentInterface mocks (Prophecy), added PHPUnit #[UsesClass(...)] attributes, removed global teardown reliance, and added tests for min-coverage env and skip-coverage. .github/wiki submodule pointer advanced.

Sequence Diagram

sequenceDiagram
  participant ReportsCommand
  participant ProjectCapabilitiesResolver
  participant ProcessQueue
  participant Logger
  ReportsCommand->>ProjectCapabilitiesResolver: resolve()
  ProjectCapabilitiesResolver-->>ReportsCommand: ProjectCapabilities
  ReportsCommand->>ReportsCommand: evaluate canRunTests()
  alt Tests Available
    ReportsCommand->>ProcessQueue: build & queue tests ("Generating Coverage Report")
  else No Tests
    ReportsCommand->>Logger: warn "Skipping coverage — no runnable tests"
  end
  ReportsCommand->>ProcessQueue: queue docs (detached)
  ReportsCommand->>ProcessQueue: queue metrics
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

🐰 "When tests don't hop where rabbits play,
The reports command finds its way—
Skip coverage with a knowing sigh,
But docs and metrics still comply!"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: skipping coverage report generation when tests are unavailable.
Description check ✅ Passed The description covers the main changes, testing approach, and changelog updates, though it does not follow the provided template structure with explicit section headings.
Linked Issues check ✅ Passed The pull request implements all acceptance criteria from issue #344: conditional coverage skipping based on test availability, proper logging, unit tests, and changelog updates.
Out of Scope Changes check ✅ Passed Changes are focused on the stated objectives; test metadata annotations and submodule updates are minor supporting changes related to the PR scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/344-skip-reports-tests-when-unavailable

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added the enhancement New feature or request label May 13, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ed5eb7c24

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Console/Command/ReportsCommand.php
Comment thread tests/Console/Command/ReportsCommandTest.php
@github-actions
Copy link
Copy Markdown
Contributor

@coisa coisa merged commit 1f02309 into main May 13, 2026
12 checks passed
@coisa coisa deleted the chore/344-skip-reports-tests-when-unavailable branch May 13, 2026 18:34
@github-project-automation github-project-automation Bot moved this from Backlog to Released in PHP Fast Forward Project May 13, 2026
github-actions Bot added a commit that referenced this pull request May 13, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5862564175

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

public function canRunTests(): bool
{
return $this->hasTestsPath || $this->hasPhpSourceFiles;
return $this->hasPhpSourceFiles;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore tests-path fallback in canRunTests

canRunTests() now returns only hasPhpSourceFiles, but TestsCommand::execute() still uses this flag to decide whether to run PHPUnit at all. That means repositories with a valid tests directory but no Composer-autoloaded source (for example, tests that exercise generated assets, external integrations, or temporarily empty src/) are now reported as success without executing tests, which can hide real failures in CI. Keep hasTestsPath as a runtime gate for running PHPUnit and scope the new source-file check to coverage/report decisions instead.

Useful? React with 👍 / 👎.

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

Labels

enhancement New feature or request

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

Skip reports coverage when no PHP tests are available

1 participant