Skip to content

Commit

Permalink
coverage: Switch to raw coverage files (#40013)
Browse files Browse the repository at this point in the history
It turns out that there really aren't any really good generic coverage
reporting tools, the best you can get is something that highlights
covered lines without function/method stats, branch info, or anything
else fancy.

To provide useful coverage output, we're going to look instead at
generating separate coverage dashboards for PHP (PHPUnit) and JS
(jest/istanbul), each generated by those tools so we can get all the
useful info possible. To do that, we'll need all the coverage commands
to generate the tools' raw data formats rather than a lossy format like
clover.

As part of this conversion, we're adding `jest.config.cjs` everywhere so
we can consistently set `collectCoverageFrom`. By default the base
config will include non-test files under `src/`. Various packages need
additional dirs such as `components/`, and a root-level `index.jsx` or
`global.d.ts` seems common too. Then, since we have config files
everywhere, we can move `coverageDirectory` and `coverageReporters` into
the configs too.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11642430412

Upstream-Ref: Automattic/jetpack@161c7a6
  • Loading branch information
anomiex authored and matticbot committed Nov 2, 2024
1 parent 888cc7a commit 6a5108e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"./vendor/phpunit/phpunit/phpunit --colors=always"
],
"test-coverage": [
"php -dpcov.directory=. ./vendor/bin/phpunit --coverage-clover \"$COVERAGE_DIR/php/clover.xml\""
"php -dpcov.directory=. ./vendor/bin/phpunit --coverage-php \"$COVERAGE_DIR/php.cov\""
],
"test-php": [
"@composer phpunit"
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-device-detection/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"./vendor/phpunit/phpunit/phpunit --colors=always"
],
"test-coverage": [
"php -dpcov.directory=. ./vendor/bin/phpunit --coverage-clover \"$COVERAGE_DIR/php/clover.xml\""
"php -dpcov.directory=. ./vendor/bin/phpunit --coverage-php \"$COVERAGE_DIR/php.cov\""
],
"test-php": [
"@composer phpunit"
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"packages": [
{
"name": "automattic/jetpack-device-detection",
"version": "2.1.6-alpha.1730371893",
"version_normalized": "2.1.6.0-alpha1730371893",
"version": "2.1.6-alpha.1730548010",
"version_normalized": "2.1.6.0-alpha1730548010",
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-device-detection",
"reference": "ce2d88faa4e94f8d11bddafcbf7d707d95c1eb75"
"reference": "460f09d797ba050711d2bc3a813742d427a8660e"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -41,7 +41,7 @@
"./vendor/phpunit/phpunit/phpunit --colors=always"
],
"test-coverage": [
"php -dpcov.directory=. ./vendor/bin/phpunit --coverage-clover \"$COVERAGE_DIR/php/clover.xml\""
"php -dpcov.directory=. ./vendor/bin/phpunit --coverage-php \"$COVERAGE_DIR/php.cov\""
],
"test-php": [
"@composer phpunit"
Expand Down
6 changes: 3 additions & 3 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
),
'versions' => array(
'automattic/jetpack-device-detection' => array(
'pretty_version' => '2.1.6-alpha.1730371893',
'version' => '2.1.6.0-alpha1730371893',
'reference' => 'ce2d88faa4e94f8d11bddafcbf7d707d95c1eb75',
'pretty_version' => '2.1.6-alpha.1730548010',
'version' => '2.1.6.0-alpha1730548010',
'reference' => '460f09d797ba050711d2bc3a813742d427a8660e',
'type' => 'jetpack-library',
'install_path' => __DIR__ . '/../automattic/jetpack-device-detection',
'aliases' => array(),
Expand Down

0 comments on commit 6a5108e

Please sign in to comment.