Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4b361a0
[BUGFIX] Fix StyleCI configuration
IchHabRecht Aug 2, 2024
a715056
[FEATURE] Introduce GitHub Actions PHP linting
IchHabRecht Aug 2, 2024
1522a51
[FEATURE] Compute matrix values
IchHabRecht Aug 2, 2024
f096c24
[FEATURE] Run PHPUnit tests and create artifacts
IchHabRecht Aug 3, 2024
d193bd5
[BUGFIX] Re-add compatibility to phpunit/php-code-coverage ^9.0
IchHabRecht Aug 3, 2024
6ee2a5e
[BUGFIX] Streamline PHPUnit configuration
IchHabRecht Aug 4, 2024
261efdf
[FEATURE] Add major version processing
IchHabRecht Aug 4, 2024
722e1eb
[FEATURE] Add merge testing job
IchHabRecht Aug 4, 2024
9d32123
[TASK] Increase log files
IchHabRecht Aug 5, 2024
15ca05c
[TASK] Remove Travis CI configuration
IchHabRecht Aug 5, 2024
e9db2b4
Merge pull request #31 from Nimut/github-actions
IchHabRecht Aug 5, 2024
790ea36
Allow Symfony ^7.0 as dependency
Jan 26, 2024
01a92d4
Merge pull request #29 from kennaar/main
IchHabRecht Aug 5, 2024
ae4e968
[RELEASE] Release of phpunit-merger 2.0.1
IchHabRecht Aug 5, 2024
d0ba7c6
[TASK] Update status badges
IchHabRecht Aug 5, 2024
cfe84c9
Merge remote-tracking branch 'upstream/main' into summer-bump-2
jgrimaud Jul 11, 2025
81ea07d
Retours PR
jgrimaud Jul 11, 2025
7d1fd2d
Fix composer
jgrimaud Jul 11, 2025
2e79168
Fix TU
jgrimaud Jul 11, 2025
8031951
Fix TU
jgrimaud Jul 11, 2025
f7424ea
Fix TU
jgrimaud Jul 11, 2025
8cf5198
Fix TU
jgrimaud Jul 15, 2025
a4a08ad
Fix TU
jgrimaud Jul 15, 2025
8509500
Remove tests from matrix for PHPUnit < 11, PHP < 8.3
steven-actual Jul 15, 2025
f68d565
Remove obsolete dependencies PHPUnit < 11, PHP Code Coverage < 11
steven-actual Jul 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: ✏️ matrix

on:
workflow_call:
outputs:
os:
value: ${{ jobs.compute.outputs.os }}
coverage:
value: ${{ jobs.compute.outputs.coverage }}
major:
value: ${{ jobs.compute.outputs.major }}
php:
value: ${{ jobs.compute.outputs.php }}
exclude:
value: ${{ jobs.compute.outputs.exclude }}

env:
OS: '[ "ubuntu-latest" ]'
COVERAGE: '[ "~11.5.27", "~12.2.7" ]'
PHP: '[ "8.3", "8.4" ]'
EXCLUDE: '[ { "coverage": "~11.5.27", "php": "8.3" }, { "coverage": "~11.5.27", "php": "8.4" }, { "coverage": "~12.2.7", "php": "8.3" }, { "coverage": "~12.2.7", "php": "8.4" } ]'

jobs:
compute:
name: Compute outputs

runs-on: ubuntu-latest

outputs:
os: ${{ env.OS }}
coverage: ${{ env.COVERAGE }}
major: ${{ steps.major-version.outputs.major }}
php: ${{ env.PHP }}
exclude: ${{ env.EXCLUDE }}

steps:
- name: Compute major versions
id: major-version
run: |
echo -e "COVERAGE\n"
echo $COVERAGE
echo -e "\n\nSplit by comma\n"
echo $COVERAGE | tr "," "\n"
echo -e "\n\nParse numbers\n"
echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9"
echo -e "\n\nCut last 2 characters\n"
echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//"
echo -e "\n\nSort by version\n"
echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | sort -V
echo -e "\n\nUnique values only\n"
echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | sort -V | uniq
echo -e "\n\nCovert to JSON\n"
echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | sort -V | uniq | jq --compact-output --raw-input --slurp 'split("\n") | map(select(. != ""))'
echo "major=$(echo $COVERAGE | tr "," "\n" | tr -cd "\n0-9" | sed "s/.\{2\}$//" | sort -V | uniq | jq --compact-output --raw-input --slurp 'split("\n") | map(select(. != ""))')" >> $GITHUB_OUTPUT
163 changes: 163 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: 🏃 tests

on: [ push, pull_request, workflow_call ]

jobs:
compute:
uses: ./.github/workflows/compute.yml

build:
name: 'Build COVERAGE: ${{ matrix.coverage }} - PHP: ${{ matrix.php }}'

needs: [ compute ]

strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.compute.outputs.os) }}
coverage: ${{ fromJson(needs.compute.outputs.coverage) }}
php: ${{ fromJson(needs.compute.outputs.php) }}
exclude: ${{ fromJson(needs.compute.outputs.exclude) }}

runs-on: ${{ matrix.os }}

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

- name: Store Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Store PHP code coverage version
id: version-cache
env:
COVERAGE: ${{ matrix.coverage }}
run: |
echo "version=$(echo $COVERAGE | tr -d -c 0-9)" >> $GITHUB_OUTPUT
echo "major=$(echo $COVERAGE | tr -d -c 0-9 | sed 's/.\{2\}$//')" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4
id: restore-composer-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-${{ steps.version-cache.outputs.major }}-${{ matrix.coverage }}
restore-keys: |
${{ runner.os }}-${{ matrix.php }}-${{ steps.version-cache.outputs.major }}-
${{ runner.os }}-${{ matrix.php }}-
${{ runner.os }}-

- name: Set up PHP Version ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: composer:v2

- name: Environment Check
run: |
php --version
composer --version
mkdir -p .Log/coverage/ .Log/log/

- name: Validate composer.json
run: composer validate

- name: Composer install
run: composer update --with "phpunit/php-code-coverage:${{ matrix.coverage }}" --no-interaction

- name: Save composer cache
uses: actions/cache/save@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }}

- name: Lint PHP
run: php .Build/bin/parallel-lint --exclude .Build .

- name: Run PHPUnit
if: ${{ success() || failure() }}
run: find 'tests' -wholename '*Test.php' | parallel --gnu 'echo -e "\n\nRunning test {}"; HASH=${{ steps.version-cache.outputs.version }}_$( echo {} | md5sum | cut -d " " -f 1); .Build/bin/phpunit --log-junit .Log/log/junit_$HASH.xml --coverage-php .Log/coverage/coverage_$HASH.cov --coverage-filter src/ {}'

- name: Archive PHPUnit logs
uses: actions/upload-artifact@v4
with:
name: phpunit-logs-${{ runner.os }}-${{ matrix.php }}-${{ steps.version-cache.outputs.major }}-${{ matrix.coverage }}
path: .Log/*
retention-days: 1

merge:
name: 'Merge COVERAGE: ${{ matrix.coverage }} - PHP: ${{ matrix.php }}'

needs: [ compute, build ]

strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.compute.outputs.os) }}
coverage: ${{ fromJson(needs.compute.outputs.major) }}
php: ${{ fromJson(needs.compute.outputs.php) }}
exclude: ${{ fromJson(needs.compute.outputs.exclude) }}

runs-on: ${{ matrix.os }}

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

- name: Download PHPUnit logs
uses: actions/download-artifact@v4
with:
path: .Log
pattern: phpunit-logs-${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }}-*
merge-multiple: true

- name: Store Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4
id: restore-composer-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }}
restore-keys: |
${{ runner.os }}-${{ matrix.php }}-
${{ runner.os }}-

- name: Set up PHP Version ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: composer:v2

- name: Environment Check
run: |
php --version
composer --version

- name: Validate composer.json
run: composer validate

- name: Composer install
run: composer update --with "phpunit/php-code-coverage:^${{ matrix.coverage }}.0" --no-interaction

- name: Save composer cache
uses: actions/cache/save@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }}

- name: Merge log files
run: bin/phpunit-merger log .Log/log/ .Log/junit.xml

- name: Merge coverage files
run: bin/phpunit-merger coverage .Log/coverage/ .Log/coverage.xml

- name: Archive PHPUnit logs
uses: actions/upload-artifact@v4
with:
name: phpunit-logs-merged-${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }}
path: .Log/*
retention-days: 1
5 changes: 4 additions & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ risky: true

preset: psr12

disabled:
- binary_operator_at_least_one_space

enabled:
- alpha_ordered_imports
- binary_operator_spaces
- binary_operator_exactly_one_space
- blank_line_before_return
- hash_to_slash_comment
- linebreak_after_opening_tag
Expand Down
98 changes: 0 additions & 98 deletions .travis.yml

This file was deleted.

13 changes: 13 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2024-08-05 [RELEASE] Release of phpunit-merger 2.0.1 (Nicole Cordes)
2024-01-26 790ea36 Allow Symfony ^7.0 as dependency (Kennard Vermeiren)
2024-08-05 15ca05c [TASK] Remove Travis CI configuration (Nicole Cordes)
2024-08-05 9d32123 [TASK] Increase log files (Nicole Cordes)
2024-08-05 722e1eb [FEATURE] Add merge testing job (Nicole Cordes)
2024-08-04 261efdf [FEATURE] Add major version processing (Nicole Cordes)
2024-08-04 6ee2a5e [BUGFIX] Streamline PHPUnit configuration (Nicole Cordes)
2024-08-03 d193bd5 [BUGFIX] Re-add compatibility to phpunit/php-code-coverage ^9.0 (Nicole Cordes)
2024-08-03 f096c24 [FEATURE] Run PHPUnit tests and create artifacts (Nicole Cordes)
2024-08-02 1522a51 [FEATURE] Compute matrix values (Nicole Cordes)
2024-08-02 a715056 [FEATURE] Introduce GitHub Actions PHP linting (Nicole Cordes)
2024-08-02 4b361a0 [BUGFIX] Fix StyleCI configuration (Nicole Cordes)

2023-10-02 [RELEASE] Release of phpunit-merger 2.0.0 (Nicole Cordes)
2023-10-02 ff24d85 [FEATURE] Add support for phpunit/php-code-coverage ^10.0 (Nicole Cordes)

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Merge multiple PHPUnit reports into one file

[![Latest Stable Version](https://img.shields.io/packagist/v/nimut/phpunit-merger.svg)](https://packagist.org/packages/nimut/phpunit-merger)
[![StyleCI](https://styleci.io/repos/114540931/shield?branch=master)](https://styleci.io/repos/114540931)
[![StyleCI](https://styleci.io/repos/114540931/shield?branch=main)](https://styleci.io/repos/114540931)
![GitHub Actions](https://github.com/Nimut/phpunit-merger/actions/workflows/test.yml/badge.svg?event=push)

Sometimes it is necessary to run multiple PHPUnit instances to execute all tests of a project. Unfortunately each run
writes its own coverage and log reports. There is no support in PHPUnit to merge the reports of multiple runs.
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@
"ext-dom": "*",
"ext-json": "*",
"ext-simplexml": "*",
"phpunit/php-code-coverage": "^9.0 || ^10.0|| ^11.0 || ^12.0",
"phpunit/php-code-coverage": "^11.0 || ^12.0",
"symfony/console": ">=2.7 <8.0",
"symfony/finder": ">=2.7 <8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3 || ^10.0 || ^11.0 || ^12.0",
"phpunit/phpunit": "^11.0 || ^12.0",
"symfony/filesystem": ">=2.7 <8.0",
"phpspec/prophecy": "^1.0"
"phpspec/prophecy": "^1.0",
"php-parallel-lint/php-parallel-lint": "^1.4"
},
"suggest": {
"friendsofphp/php-cs-fixer": "Tool to automatically fix PHP coding standards issues"
Expand Down
7 changes: 1 addition & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.4/phpunit.xsd"
bootstrap=".Build/vendor/autoload.php"
executionOrder="depends,defects"
forceCoversAnnotation="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
executionOrder="depends,defects">
<testsuites>
<testsuite name="coverage">
<directory suffix="Test.php">tests/PhpunitMerger/Command/Coverage</directory>
Expand Down
Loading