Skip to content

Migrate coverage reporting from Coveralls to Codecov#109

Merged
BenMorel merged 3 commits intomasterfrom
copilot/migrate-to-codecov-coverage
Feb 26, 2026
Merged

Migrate coverage reporting from Coveralls to Codecov#109
BenMorel merged 3 commits intomasterfrom
copilot/migrate-to-codecov-coverage

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

  • Update .github/workflows/ci.yml: simplified "Run PHPUnit with coverage" step (removed mkdir -p build/logs, changed clover path to clover.xml); replaced "Upload coverage report to Coveralls" step with "Upload coverage to Codecov" using codecov/codecov-action@v5
  • Update README.md: replaced Coveralls badge with Codecov badge
  • Update composer.json: removed php-coveralls/php-coveralls from require-dev
Original prompt

Migrate from Coveralls to Codecov for coverage reporting, mirroring the changes made in brick/money#115.

Changes required

1. .github/workflows/ci.yml

In the phpunit job, make the following changes:

  • In the "Run PHPUnit with coverage" step, change the clover output path from build/logs/clover.xml to clover.xml (and remove the mkdir -p build/logs line, since the file is now written to the root):

    - name: Run PHPUnit with coverage
      run: vendor/bin/phpunit --fail-on-skipped --coverage-clover clover.xml
      env:
        CALCULATOR: ${{ matrix.calculator }}
      if: ${{ matrix.php-version == env.COVERAGE_PHP_VERSION }}

    Note: The current step uses a multi-line run block with mkdir -p build/logs followed by vendor/bin/phpunit --coverage-clover build/logs/clover.xml. Keep the --fail-on-skipped flag if it's present; if not, just change the clover path.

  • Replace the "Upload coverage report to Coveralls" step with:

    - name: Upload coverage to Codecov
      uses: codecov/codecov-action@v5
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
      if: ${{ matrix.php-version == env.COVERAGE_PHP_VERSION }}

    (Remove the old step that runs vendor/bin/php-coveralls with COVERALLS_REPO_TOKEN.)

Here is the current full content of .github/workflows/ci.yml for reference:

name: CI

on:
  push:
  pull_request:

env:
  PHPSTAN_PHP_VERSION: "8.4"
  COVERAGE_PHP_VERSION: "8.4"

jobs:
  phpstan:
    name: PHPStan
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ env.PHPSTAN_PHP_VERSION }}

      - name: Install composer dependencies
        uses: ramsey/composer-install@v3

      - name: Run PHPStan
        run: vendor/bin/phpstan --no-progress

  coding-standard:
    name: Coding Standard
    uses: brick/coding-standard/.github/workflows/coding-standard.yml@v4
    with:
      php-version: "8.2"
      working-directory: "tools/ecs"

  phpunit:
    name: PHPUnit
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        php-version:
          - "8.2"
          - "8.3"
          - "8.4"
          - "8.5"
        calculator:
          - GMP
          - BCMath
          - Native
        deps:
          - "highest"
        include:
          - php-version: "8.2"
            calculator: GMP
            deps: "lowest"
          - php-version: "8.2"
            calculator: BCMath
            deps: "lowest"
          - php-version: "8.2"
            calculator: Native
            deps: "lowest"

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-version }}
          coverage: pcov

      - name: Install composer dependencies
        uses: ramsey/composer-install@v3
        with:
          dependency-versions: ${{ matrix.deps }}

      - name: Run PHPUnit
        run: vendor/bin/phpunit
        env:
          CALCULATOR: ${{ matrix.calculator }}
        if: ${{ matrix.php-version != env.COVERAGE_PHP_VERSION }}

      - name: Run PHPUnit with coverage
        run: |
          mkdir -p build/logs
          vendor/bin/phpunit --coverage-clover build/logs/clover.xml
        env:
          CALCULATOR: ${{ matrix.calculator }}
        if: ${{ matrix.php-version == env.COVERAGE_PHP_VERSION }}

      - name: Run PHPUnit with bcscale()
        run: vendor/bin/phpunit
        env:
          CALCULATOR: BCMath
          BCMATH_DEFAULT_SCALE: 8
        if: ${{ matrix.calculator == 'BCMath' }}

      - name: Upload coverage report to Coveralls
        run: vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        if: ${{ matrix.php-version == env.COVERAGE_PHP_VERSION }}

The updated file should replace the last two steps (Run PHPUnit with coverage and Upload coverage report to Coveralls) with:

      - name: Run PHPUnit with coverage
        run: vendor/bin/phpunit --fail-on-skipped --coverage-clover clover.xml
        env:
          CALCULATOR: ${{ matrix.calculator }}
        if: ${{ matrix.php-version == env.COVERAGE_PHP_VERSION }}

      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v5
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
        if: ${{ matrix.php-version == env.COVERAGE_PHP_VERSION }}

2. README.md

Replace the Coveralls badge with a Codecov badge:

  • Remove:
    [![Coverage Status](https://coveralls.io/repos/github/brick/math/badge.svg?branch=master)](https://coveralls.io/github/brick/math?branch=master)
    
  • Add:
    [![Coverage](https://codecov.io/github/brick/math/graph/badge.svg)](https://codecov.io/github...
    
    

This pull request was created from Copilot chat.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: BenMorel <1952838+BenMorel@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate from Coveralls to Codecov for coverage reporting Migrate coverage reporting from Coveralls to Codecov Feb 26, 2026
@codecov
Copy link

codecov bot commented Feb 26, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@BenMorel BenMorel marked this pull request as ready for review February 26, 2026 18:17
@BenMorel
Copy link
Member

@copilot Do not add fail-on-skipped if it was not already there.

Co-authored-by: BenMorel <1952838+BenMorel@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 26, 2026

@copilot Do not add fail-on-skipped if it was not already there.

Removed in 7ce4383.

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