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 d2c4580 commit fd55d20
Show file tree
Hide file tree
Showing 30 changed files with 285 additions and 285 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
160 changes: 80 additions & 80 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-a8c-mc-stats/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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-admin-ui/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-assets/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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\"",
"pnpm run test-coverage"
],
"test-js": [
Expand Down
4 changes: 2 additions & 2 deletions vendor/automattic/jetpack-assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"build-production": "pnpm run clean && pnpm run build-production-js && pnpm run validate",
"build-production-js": "NODE_ENV=production BABEL_ENV=production pnpm run build-js",
"clean": "rm -rf build",
"test": "jest tests",
"test-coverage": "pnpm run test --coverage --collectCoverageFrom='src/**/*.js' --coverageDirectory=\"$COVERAGE_DIR/js\" --coverageReporters=clover",
"test": "jest --config=tests/jest.config.cjs",
"test-coverage": "pnpm run test --coverage",
"validate": "pnpm exec validate-es build/"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-blaze/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-blocks/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"post-install-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-calypsoify/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"post-install-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-connection/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"post-install-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-constants/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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
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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-google-analytics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-ip/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-jitm/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-logo/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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-masterbar/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"test-coverage": [
"pnpm run build-production",
"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": [
"pnpm run build-production",
Expand Down
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-mu-wpcom/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-password-checker/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-plans/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-redirect/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-roles/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-stats-admin/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-stats/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-status/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-sync/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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
2 changes: 1 addition & 1 deletion vendor/automattic/scheduled-updates/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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
Loading

0 comments on commit fd55d20

Please sign in to comment.