Skip to content

Commit

Permalink
Remove remnants of automated code coverage support (#28982)
Browse files Browse the repository at this point in the history
PR #28542 removed the calls to the coverage scripts (except for one
line), but didn't update the documentation, remove the scripts
themselves, or adjust `jetpack generate` to stop generating those
scripts. This does all that.

It does not remove the PHPUnit or Jest definitions of which files should
be looked at for coverage, or any `@codeCoverageIgnore` directives, or
the `test-coverage-html` script in packages/waf, as those may still be
useful for people manually looking at coverage locally.
  • Loading branch information
anomiex authored Feb 20, 2023
1 parent c8207e1 commit 8cc3246
Show file tree
Hide file tree
Showing 229 changed files with 697 additions and 1,587 deletions.
5 changes: 1 addition & 4 deletions .github/actions/tool-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ description: "Setup needed versions of PHP, Node, and Pnpm."
inputs:
php:
description: "Override the PHP version, or set 'false' to skip setting up PHP."
coverage:
description: "Set the PHP coverage driver, e.g. 'none' or 'pcov'."
default: 'none'
node:
description: "Override the Node version, or set 'false' to skip setting up Node and Pnpm."
runs:
Expand Down Expand Up @@ -65,7 +62,7 @@ runs:
ini-values: error_reporting=E_ALL, display_errors=On, zend.assertions=1
tools: composer:${{ steps.versions.outputs.composer-version }}
extensions: mysql, imagick
coverage: ${{ inputs.coverage }}
coverage: none

- name: Configure composer
if: steps.versions.outputs.php-version != 'false'
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ jobs:
EXIT=0
mkdir artifacts
[[ "$TEST_SCRIPT" == "test-coverage" ]] && mkdir coverage
for P in composer.json projects/*/*/composer.json; do
if [[ "$P" == "composer.json" ]]; then
DIR="."
Expand Down
17 changes: 0 additions & 17 deletions codecov.yml

This file was deleted.

15 changes: 3 additions & 12 deletions composer.lock

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

12 changes: 0 additions & 12 deletions docs/monorepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ We use `composer.json` to hold metadata about projects. Much of our generic tool
* `.repositories`: If you include a repository entry referencing monorepo packages, it must have `.options.monorepo` set to true. This allows the build tooling to recognize and remove it.
* `.scripts.build-development`: If your project has a general build step, this must run the necessary commands. See [Building](#building) for details.
* `.scripts.build-production`: If your project requires a production-specific build step, this must run the necessary commands. See [Building](#building) for details.
* `.scripts.test-coverage`: If the package contains any tests, this must run the necessary commands to generate a coverage report. See [Code coverage](#code-coverage) for details.
* `.scripts.skip-test-coverage`: Run before `.scripts.test-coverage` in CI. If it exits with code 3, the test run will be skipped.
* `.scripts.test-e2e`: If the package contains any E2E tests, this must run the necessary commands. See [E2E tests](#e2e-tests) for details.
* `.scripts.test-js`: If the package contains any JavaScript tests, this must run the necessary commands. See [JavaScript tests](#javascript-tests) for details.
* `.scripts.skip-test-js`: Run before `.scripts.test-js` in CI. If it exits with code 3, the test run will be skipped.
Expand Down Expand Up @@ -248,16 +246,6 @@ JavaScript tests should use `jest`, not `mocha`/`chai`/`sinon`. For React testin

If a project contains end-to-end tests, it must define `.scripts.test-e2e` in `composer.json` to run the tests. If a build step is required before running tests, the necessary commands for that should also be included.

### Code coverage

If a project contains PHP or JavaScript tests, it should also define `.scripts.test-coverage` in `composer.json` to run the tests in a mode that will generate code coverage output. The CI environment will run `pnpm install` and `composer install` beforehand, but if a build step is required before running tests the necessary commands for that should also be included in `.scripts.test-coverage`.

Output should be written to the path specified via the `COVERAGE_DIR` environment variable. Subdirectories of that path may be used as desired.

For PHP tests, you'll probably run PHPUnit as `php -dpcov.directory=. "$(command -v phpunit)" --coverage-clover "$COVERAGE_DIR/clover.xml"`.

There's no need to be concerned about collisions with other projects' coverage files, a separate directory is used per project. The coverage files are also automatically copied to `ARTIFACTS_DIR`.

## Mirror repositories

Most projects in the monorepo should have a mirror repository holding a built version of the project, ready for deployment. Follow these steps to create the mirror repo and configure the monorepo tooling to push to it.
Expand Down
2 changes: 1 addition & 1 deletion docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Running the script will tell you if you have your environment already set up and

#### Running Tests

To run PHP, JS, and coverage tests, you can use the Jetpack CLI: `jetpack test` and then choose the project and type of test you'd like to run.
To run PHP and JS tests, you can use the Jetpack CLI: `jetpack test` and then choose the project and type of test you'd like to run.

# Development Workflow

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove `test-coverage` scripts and other remnants of automated code coverage.


3 changes: 1 addition & 2 deletions projects/github-actions/test-results-to-slack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
},
"scripts": {
"build": "ncc build src/index.js -o dist --source-map --license licenses.txt",
"test": "jest --config=tests/jest.config.js --verbose --runInBand",
"test-coverage": "jest --config=tests/jest.config.js --coverage --coverageDirectory=\"$COVERAGE_DIR\" --coverageReporters=clover"
"test": "jest --config=tests/jest.config.js --verbose --runInBand"
},
"engines": {
"node": "^18.13.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove `test-coverage` scripts and other remnants of automated code coverage.


3 changes: 0 additions & 3 deletions projects/js-packages/analytics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"scripts": {
"test-js": [
"pnpm run test"
],
"test-coverage": [
"pnpm run test-coverage"
]
},
"repositories": [
Expand Down
5 changes: 2 additions & 3 deletions projects/js-packages/analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@automattic/jetpack-analytics",
"version": "0.1.23",
"version": "0.1.24-alpha",
"description": "Jetpack Analytics Package",
"author": "Automattic",
"license": "GPL-2.0-or-later",
Expand All @@ -15,8 +15,7 @@
".": "./index.jsx"
},
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"test-coverage": "pnpm run test --coverageDirectory=\"$COVERAGE_DIR\" --coverage --coverageReporters=clover"
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
"engines": {
"node": "^18.13.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove `test-coverage` scripts and other remnants of automated code coverage.


3 changes: 0 additions & 3 deletions projects/js-packages/api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"scripts": {
"test-js": [
"pnpm run test"
],
"test-coverage": [
"pnpm run test-coverage"
]
},
"repositories": [
Expand Down
5 changes: 2 additions & 3 deletions projects/js-packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@automattic/jetpack-api",
"version": "0.15.0",
"version": "0.15.1-alpha",
"description": "Jetpack Api Package",
"author": "Automattic",
"license": "GPL-2.0-or-later",
Expand All @@ -19,8 +19,7 @@
".": "./index.jsx"
},
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"test-coverage": "pnpm run test --coverageDirectory=\"$COVERAGE_DIR\" --coverage --coverageReporters=clover"
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
"engines": {
"node": "^18.13.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove `test-coverage` scripts and other remnants of automated code coverage.


Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
"scripts": {
"test-js": [
"pnpm run test"
],
"test-coverage": [
"pnpm run test-coverage"
]
},
"repositories": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@automattic/babel-plugin-replace-textdomain",
"version": "1.0.22",
"version": "1.0.23-alpha",
"description": "A Babel plugin to replace the textdomain in gettext-style function calls.",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/babel-plugin-replace-textdomain/#readme",
"bugs": {
Expand All @@ -14,8 +14,7 @@
"license": "GPL-2.0-or-later",
"author": "Automattic",
"scripts": {
"test": "jest tests",
"test-coverage": "jest tests --coverage --collectCoverageFrom='src/**/*.js' --coverageDirectory=\"$COVERAGE_DIR\" --coverageReporters=clover"
"test": "jest tests"
},
"dependencies": {
"debug": "^4.3.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove `test-coverage` scripts and other remnants of automated code coverage.


3 changes: 0 additions & 3 deletions projects/js-packages/components/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
],
"test-js": [
"pnpm run test"
],
"test-coverage": [
"pnpm run test-coverage"
]
},
"repositories": [
Expand Down
3 changes: 1 addition & 2 deletions projects/js-packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
"scripts": {
"build": "pnpm run compile-ts",
"compile-ts": "tsc --pretty",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"test-coverage": "pnpm run test --coverageDirectory=\"$COVERAGE_DIR\" --coverage --coverageReporters=clover"
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
"engines": {
"node": "^18.13.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove `test-coverage` scripts and other remnants of automated code coverage.


3 changes: 0 additions & 3 deletions projects/js-packages/config/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
"scripts": {
"test-js": [
"pnpm run test"
],
"test-coverage": [
"pnpm run test-coverage"
]
},
"repositories": [
Expand Down
5 changes: 2 additions & 3 deletions projects/js-packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-config",
"version": "0.1.18",
"version": "0.1.19-alpha",
"description": "Handles Jetpack global configuration shared across all packages",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/config/#readme",
"bugs": {
Expand All @@ -15,8 +15,7 @@
"license": "GPL-2.0-or-later",
"author": "Automattic",
"scripts": {
"test": "jest",
"test-coverage": "pnpm run test --coverageDirectory=\"$COVERAGE_DIR\" --coverage --coverageReporters=clover"
"test": "jest"
},
"devDependencies": {
"jest": "29.3.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove `test-coverage` scripts and other remnants of automated code coverage.


3 changes: 0 additions & 3 deletions projects/js-packages/connection/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"scripts": {
"test-js": [
"pnpm run test"
],
"test-coverage": [
"pnpm run test-coverage"
]
},
"repositories": [
Expand Down
5 changes: 2 additions & 3 deletions projects/js-packages/connection/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@automattic/jetpack-connection",
"version": "0.25.0",
"version": "0.25.1-alpha",
"description": "Jetpack Connection Component",
"author": "Automattic",
"license": "GPL-2.0-or-later",
Expand Down Expand Up @@ -47,8 +47,7 @@
"*.scss"
],
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"test-coverage": "pnpm run test --coverageDirectory=\"$COVERAGE_DIR\" --coverage --coverageReporters=clover"
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
"engines": {
"node": "^18.13.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove `test-coverage` scripts and other remnants of automated code coverage.


3 changes: 0 additions & 3 deletions projects/js-packages/eslint-changed/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"automattic/jetpack-changelogger": "@dev"
},
"scripts": {
"test-coverage": [
"pnpm run test-coverage"
],
"test-js": [
"pnpm run test"
]
Expand Down
5 changes: 2 additions & 3 deletions projects/js-packages/eslint-changed/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@automattic/eslint-changed",
"version": "2.0.5",
"version": "2.0.6-alpha",
"description": "Run eslint on files, but only report warnings and errors from lines that were changed.",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/eslint-changed/#readme",
"type": "module",
Expand All @@ -18,8 +18,7 @@
"eslint-changed": "bin/eslint-changed.js"
},
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules jest --config=tests/jest.config.cjs",
"test-coverage": "NODE_OPTIONS=--experimental-vm-modules jest --config=tests/jest.config.cjs --coverage --coverageDirectory=\"$COVERAGE_DIR\" --coverageReporters=clover"
"test": "NODE_OPTIONS=--experimental-vm-modules jest --config=tests/jest.config.cjs"
},
"dependencies": {
"chalk": "5.0.1",
Expand Down
2 changes: 1 addition & 1 deletion projects/js-packages/eslint-changed/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Command } from 'commander';
import { ESLint } from 'eslint';
import parseDiff from 'parse-diff';

const APP_VERSION = '2.0.5';
const APP_VERSION = '2.0.6-alpha';

/**
* Create a Commander instance.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove `test-coverage` scripts and other remnants of automated code coverage.


Loading

0 comments on commit 8cc3246

Please sign in to comment.