Skip to content

Fix CI failure: remove conflicting <coverage> block from phpunit.xml#73

Closed
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-phpunit-coverage-issue
Closed

Fix CI failure: remove conflicting <coverage> block from phpunit.xml#73
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-phpunit-coverage-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 18, 2026

ci.yml sets coverage: none in setup-php, but phpunit.xml had a <coverage> block requesting HTML/Clover/Crap4J reports — causing PHPUnit to abort with No code coverage driver available before running any tests.

Change

  • phpunit.xml: Removed the <coverage> block entirely. All other blocks (<testsuites>, <logging>, <source>) are untouched.
-  <coverage includeUncoveredFiles="true">
-    <report>
-      <html outputDirectory="build/coverage"/>
-      <clover outputFile="build/logs/clover.xml"/>
-      <crap4j outputFile="build/logs/crap4j.xml"/>
-    </report>
-  </coverage>
Original prompt

Problem

The CI workflow is failing with:

No code coverage driver available
No tests executed!
Process completed with exit code 1.

Root cause: There is a conflict between two settings:

  1. .github/workflows/ci.yml sets coverage: none in the setup-php step — intentionally disabling any code coverage driver.
  2. phpunit.xml has a <coverage> block with report outputs (HTML, Clover, Crap4J) — which tells PHPUnit to collect and report code coverage.

When PHPUnit tries to execute coverage reporting but no coverage driver is available, it exits with code 1 and no tests run.

Fix

Remove the <coverage> block from phpunit.xml so it no longer requests coverage reporting. The <logging> and all other blocks should remain intact.

The fixed phpunit.xml should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         processIsolation="false"
         stopOnFailure="false"
         bootstrap="vendor/autoload.php">
  <testsuites>
    <testsuite name="unit">
      <directory>tests/Unit</directory>
    </testsuite>
    <testsuite name="functional">
      <directory>tests/Functional</directory>
      <directory>tests/SimpleJob</directory>
    </testsuite>
  </testsuites>
  <logging>
    <junit outputFile="build/logs/junit.xml"/>
  </logging>
  <source>
    <include>
      <directory suffix=".php">src/</directory>
    </include>
  </source>
</phpunit>

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Why https://github.com/onlineconvert/onlineconvert-api-sdk-php/actions/runs/24599302479 is failing? How to fix it?

Assistant: ## Root Cause

The workflow is failing because of a conflict between two settings:

  1. ci.yml sets coverage: none in the setup-php step — this intentionally disables any code coverage driver (Xdebug/PCOV).
  2. phpunit.xml has a <coverage> block with report outputs (HTML, Clover, Crap4J) — this tells PHPUnit to collect and report code coverage.

When PHPUnit tries to execute coverage reporting but no coverage driver is available, it fails with:

No code coverage driver available
No tests executed!
Process completed with exit code 1.

How to Fix

You have two options:

✅ Option 1 — Remove the <coverage> block from phpunit.xml (Recommended for CI)

Since the workflow explicitly disables coverage (coverage: none), remove the coverage reporting from phpunit.xml:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         processIsolation="false"
         stopOnFailure="false"
         bootstrap="vendor/autoload.php">
  <testsuites>
    <testsuite name="unit">
      <directory>tests/Unit</directory>
    </testsuite>
    <testsuite name="functional">
      <directory>tests/Functional</directory>
      <directory>tests/SimpleJob</directory>
    </testsuite>
  </testsuites>
  <logging>
    <junit outputFile="build/logs/junit.xml"/>
  </logging>
  <source>
    <include>
      <directory suffix=".php">src/</directory>
    </include>
  </source>
</phpunit>

Option 2 — Enable a coverage driver in ci.yml

If you actually want code coverage reports, change coverage: none to use xdebug or pcov:

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
      php-version: ${{ matrix.php-versions }}
      extensions: json, dom, curl, libxml, mbstring
      coverage: pcov   # or xdebug

Option 1 is recommended since code coverage collection slows down CI and the current intent (via coverage: none) is clearly to skip it.

Would you like me to open a PR with the fix?

User: yes, do it

Assistant: I'm waiting for your response on the confirmation dialog to proceed with creating the pull request.

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Fix PHPUnit coverage conflict in phpunit.xml Fix CI failure: remove conflicting <coverage> block from phpunit.xml Apr 18, 2026
Copilot AI requested a review from qaamgo-luca April 18, 2026 07:15
@qaamgo-luca qaamgo-luca marked this pull request as ready for review April 18, 2026 07:15
@qaamgo-luca
Copy link
Copy Markdown
Contributor

Fix for github CI failure

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.

2 participants