36 Commits

Author SHA1 Message Date
John Blackbourn
6f89bd0064 Build/Test Tools: Switch away from npx install-changed in GitHub Actions to increase the cache performance.
Using `npm ci` makes better use of the npm cache that's in use, speeding up the test runs by around 30 seconds.

See #52660


git-svn-id: https://develop.svn.wordpress.org/trunk@50446 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-26 22:47:33 +00:00
John Blackbourn
d59c227764 Build/Test Tools: Split the PHPUnit tests for PHP versions below 7.0 in half, allowing them to run in parallel and reduce the overall test run duration on GitHub Actions.
The `external-http`, `media`, and `restapi` groups combined take roughly the same time as all the other tests combined. Splitting the test run in two speeds up the PHP 5.6 test runs which are the slowest by quite a margin. The net reduction in duration is only seen on PHP versions older than 7.0 where the reduction is greater than the time taken for the job to be set up.

Props peterwilsoncc, desrosj, johnbillion

Special shout out to manzoorwanijk whose article about running steps in parallel started me down this path.

Fixes #52645


git-svn-id: https://develop.svn.wordpress.org/trunk@50444 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-26 15:07:03 +00:00
John Blackbourn
58b33ec47c Build/Test Tools: Avoid attempting to redeclare the origin remote prior to sending the test results to the test reporting API.
Props desroj
See #51734


git-svn-id: https://develop.svn.wordpress.org/trunk@50442 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-26 14:28:02 +00:00
John Blackbourn
4ab922d224 Build/Test Tools: Switch back to running the PHPUnit test suite against the src directory instead of build.
Some PHPUnit tests were concerned with the state of files in the `build` directory. In order to allow the tests to run without requiring a build to be run first, these have been moved into assertions that run after the build step (and therefore cause it to fail if they do not pass), or into QUnit tests as necessary.

Various other PHPUnit tests implictly depend on built JavaScript files being present. These files are now touched during the test setup to avoid PHP warnings if the `build` files are not present.

The `wp-tests-config-sample.php` file and the GitHub Actions configuration have also been changed so `ABSPATH` uses `src` instead of `build`, therefore allowing the PHPUnit tests to be run without a build having to be run first. This means all new local installations of WordPress will use `src` for PHPUnit testing. If you would like to switch your existing installation over then change the location of `ABSPATH` in `wp-tests-config.php` to point to `src` instead of `build`.

Props peterwilsoncc, iandunn, gziolo, desroj, johnbillion

Fixes #51734
See #45863


git-svn-id: https://develop.svn.wordpress.org/trunk@50441 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-26 14:07:53 +00:00
Jonathan Desrosiers
33af39335e Build/Test Tools: Prevent the NPM/Composer caches in GitHub Actions from snowballing.
The `actions/cache` GitHub action uses a `key` input to find the desired cache in storage. Currently, this is defined as a combination of the operating system being used, the software being cached (NPM or Composer), PHP version (Composer only), and a hash of the relevant lock file.

The `cache` action also supports a `restore-keys` input, which is an ordered list of keys to use for restoring a cache if no cache hit occurred for the specified key.

However, this means that every time a lock file is updated, the cache is being recreated by first restoring a previous one (when available), and then installing new versions of dependencies on top of that. This results in old, unused versions of dependencies never being removed from the cache.

In this change, the `restore-keys` are removed. This will force a new, fresh cache to be generated when the desired `key` is not matched. In testing, this results in a ~40% reduction in cache size when compared to the latest successful workflow runs. Since there is no way to manually flush the cache in GHA, the benefits of this change will not be seen until the `package-lock.json` and `composer.lock` files are updated, or the cache at the desired key is evicted.

Props johbillion.
See #52660.

git-svn-id: https://develop.svn.wordpress.org/trunk@50436 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-25 20:47:28 +00:00
Jonathan Desrosiers
f2b56883f0 Build/Test Tools: Disable fail-fast for PHPUnit testing.
In GitHub Actions, there is a `fail-fast` option that will cancel all incomplete jobs within a workflow as soon as one failure is encountered. This defaults to `true`.

This is great for alerting you of a failure faster, but does not give you the full picture of what is failing. For example, it’s possible that there is a failing test on 2 versions of PHP, but not others. If `fail-fast` is enabled, it’s impossible to know this.

Even with `fail-fast` disabled, the workflow will still report a failure if one or more jobs produce a failing result.

Props johbillion, jorbin.
Fixes #52612.

git-svn-id: https://develop.svn.wordpress.org/trunk@50435 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-25 14:03:16 +00:00
Jonathan Desrosiers
4a09e7d877 Build/Test Tools: Limit when GitHub Action workflows run on pull_request.
Different branches have support for different types of testing based on the tooling that was in place at the time each version was branched. The workflows currently in place have patterns configured to match the relevant `branches` and `tags` for each workflow, but only for `push` events.

This copies the patterns for matching supported `branches` over to the `pull_request` event to prevent workflows from running for a pull request to a branch that does not support that workflow.

Fixes #52643.

git-svn-id: https://develop.svn.wordpress.org/trunk@50432 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-24 19:34:41 +00:00
Jonathan Desrosiers
da710d81e5 Build/Test Tools: Stop running the restapi-jsclient tests separately.
This group is not specified in the list of excluded groups within the test configuration file, so they already run as part of the main test suite.

Props johnbillion.
Fixes #52608.

git-svn-id: https://develop.svn.wordpress.org/trunk@50413 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-23 15:45:45 +00:00
Jonathan Desrosiers
4935d34e84 Build/Test Tools: Update actions within test workflows to the latest versions.
This updates two published GitHub actions to their latest versions:

- `actions/setup-node` from `v1` to `v2`.
- `styfle/cancel-workflow-action` from `0.5.0` to `0.8.0`.

See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@50387 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-18 18:45:23 +00:00
John Blackbourn
4f25e74baa Build/Test Tools: Split the single site and Multisite PHPUnit test runs on CI into separate jobs so they run in parallel.
This reduces the total duration of the test suite from ~26 minutes to ~16 minutes. Hurrah!

Fixes #52548


git-svn-id: https://develop.svn.wordpress.org/trunk@50379 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-17 19:31:25 +00:00
Jonathan Desrosiers
4e080befee Build/Test Tools: Run xDebug tests on PHP 8.0.
The PHP 8 Docker container for the local WordPress environment now contains xDebug 3.x (the version required for running on PHP 8), so the `xdebug` test group can now be run.

See #50401, #51802.

git-svn-id: https://develop.svn.wordpress.org/trunk@50299 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-12 16:36:14 +00:00
Jonathan Desrosiers
14c3fb1d43 Build/Test Tools: Run automated testing when tags are created.
This expands the list of events that triggers automated testing to include tags.

It also refines the matched version ranges for several workflows.

See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@50298 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-12 16:01:54 +00:00
Jonathan Desrosiers
6e49ac2e96 Build/Test Tools: Install WordPress Importer plugin when installing the Docker-based local environment.
The WordPress Importer plugin is now downloaded to the `tests/phpunit/data/plugins` directory when running `npm run env:install`.

This ensures that the PHPUnit test suite will not fail when the plugin is missing.

This also introduces a new `WP_IMPORTER_REVISION` variable to the `.env` file, to control the SVN revision that is checked out.

Props johnbillion.
Fixes #49720.

git-svn-id: https://develop.svn.wordpress.org/trunk@50285 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-10 16:52:13 +00:00
Jonathan Desrosiers
2833031cce Build/Test Tools: Correct some inline documentation within GitHub Action files.
This corrects several inaccuracies within the GitHub Action workflow files.

See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@50268 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-09 14:15:50 +00:00
Jonathan Desrosiers
563a4c3e08 Build/Test Tools: Simplify Composer package caching.
This simplifies the caching of Composer dependencies in the coding standards and PHP compatibility workflows by using a published action. This combines 3 steps into 1 within these workflows.

Because the Composer implementation within the PHPUnit test workflow is a bit specialized (`composer install` is run within the Docker container), caching has been left as is in that workflow. However, the cache key has been changed to include the version of PHP being tested. This will prevent incorrect versions of dependencies being present when they are required on jobs other than PHP 8.

Props jrf.
See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49938 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-05 19:21:50 +00:00
Jonathan Desrosiers
abe9dd3c03 Build/Test Tools: Change the frequency of code coverage reporting.
Before the coverage reports were submitted to Codecov.io, HTML coverage reports were compressed into ZIP files and uploaded to the workflow run as an artifact. A weekly schedule was chosen to run this workflow because generating a coverage report is more time consuming, and the resulting reports are quite large (~150-200MB each).

This changes the schedule for the code coverage workflow from weekly to daily and eliminates the ZIP artifacts that were previously generated. This will ensure the code coverage data found at https://codecov.io/gh/WordPress/wordpress-develop is relatively accurate on any given day of the week without needlessly consuming artifact storage.

Props jorbin.
See #50401, #52141.

git-svn-id: https://develop.svn.wordpress.org/trunk@49931 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-04 19:46:34 +00:00
Aaron Jorbin
a0a03bfb6e Build/Test: Send Code Coverage reports to Codecov.
Help visualize and explore code coverage reports to avoid blunders.

Props desrosj, swissspidy.
Fixes #52141.



git-svn-id: https://develop.svn.wordpress.org/trunk@49903 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-23 18:17:51 +00:00
Jonathan Desrosiers
3723941a9c Build/Test Tools: Run the Ajax test group for multisite.
This will help catch issues with Ajax related functionality on multisite.

A few tests have also been marked as `skipWithMultisite()` as they require network admin level capabilities when performing the same operations on a multisite install.

Props garrett-eclipse, netweb.
Fixes #46567.

git-svn-id: https://develop.svn.wordpress.org/trunk@49835 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-18 14:38:28 +00:00
Jonathan Desrosiers
8bc7e0c0e5 Build/Test Tools: Generate a code coverage report using GitHub Actions.
This introduces a new GitHub Action workflow to generate a code coverage report when running the PHPUnit test suite as both a single and multisite install.

The workflow will run once per week on Sunday at 00:00 UTC.

For now, the reports are not submitted anywhere, but they will be uploaded to the workflow run as ZIP file artifacts where they will persist for 90 days.

Making code coverage reports more readily available will hopefully better highlight areas of Core with poor coverage, and encourage more contributors to help increase test coverage of those areas.

Props ocean90, johnbillion.
Fixes #52034.

git-svn-id: https://develop.svn.wordpress.org/trunk@49834 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-18 00:28:27 +00:00
Jonathan Desrosiers
14cda0388b Build/Test Tools: Reestablish the codebase as a Git repo before reporting test results.
The test reporter uses the hidden `.svn` or `.git` directories to determine which changeset to send to WordPress.org along with the test report.

Because the GitHub Action workflow builds and prepares WordPress in a preceding job to share with each test job, the `.git` directory is missing (it is purposefully not included to limit artifact size).

This re-establishes the directory as a checkout of the `wordpress-develop` repository so that test results can be reported correctly.

See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49786 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-10 19:17:28 +00:00
Jonathan Desrosiers
668581d0f3 Build/Test Tools: Inline documentation updates for the PHPUnit workflow.
See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49784 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-10 15:28:09 +00:00
Jonathan Desrosiers
e86d912e3c Build/Test Tools: Enable reporting of results to WordPress.org.
This configures reporting of the test results to the WordPress.org Host Test Results in the new GitHub Actions workflow for PHPUnit testing.

See https://make.wordpress.org/hosting/test-results/

Props mikeschroder, dd32.
See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49783 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-10 14:18:12 +00:00
Jonathan Desrosiers
2a46c3987f Build/Test Tools: Use NodeJS 14 in GitHub Action workflows.
14.x is the current LTS release, and is what `trunk` currently runs.

See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49782 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-09 20:55:42 +00:00
Jonathan Desrosiers
cf909e11d3 Build/Test Tools: Disable GitHub Action workflow runs triggered on push for forks and mirrors.
In the current state, the workflows run regardless of the repository context. This results many needless workflow runs that waste resources.

Workflow runs for private repositories are not free (accounts have a finite allotment of minutes for private repositories). This becomes problematic in private repositories that also mirror the WordPress develop repository, as any workflow runs will draw from a user’s or organization’s allotted action minutes.

Without blanket disabling the workflow manually for all event triggers, or modifying the workflow files in the forked/mirrored repository, there is no way to tune when the workflows run.

This change introduces a conditional statement into all GitHub Action workflows that prevents them from running on forked/mirrored repositories that are not `wordpress-develop`, except when a pull request is being submitted to that repository.

The exception to this is the Welcome workflow that posts a helpful message to first time contributors to `wordpress-develop`. This message is specific to this repository, so should only run when a PR is submitted to that repository.

See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49781 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-09 20:05:01 +00:00
Jonathan Desrosiers
63db886240 Build/Test Tools: Clean up the new contributor welcome message.
Props ocean90, jeffpaul.
See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49548 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-09 17:29:21 +00:00
Jonathan Desrosiers
ed2b1a43e0 Build/Test Tools: Avoid logging the same debug info twice in the PHPUnit workflow.
Also includes some inline documentation fixes for workflow files.

See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49371 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-29 01:46:44 +00:00
Jonathan Desrosiers
886a9ddaa4 Build/Test Tools: Use install-changed to install NPM dependencies in GitHub Action workflows.
The `install-changed` package records a hash of the `package.json` file locally in a text file and only runs `npm install` when there are changes to account for. 

This builds on [47497], which only hashes the `package.json` file after a Grunt task is called. By using `npx install-changed` within the workflow files, the package is hashed before the first Grunt task is run.

Props ocean90.
See #50401, #49594.

git-svn-id: https://develop.svn.wordpress.org/trunk@49369 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-29 01:20:42 +00:00
Jonathan Desrosiers
643754dc67 Build/Test Tools: Cancel previous active workflow runs for pull requests.
Because workflow results are reported for each commit, it’s important to let all runs against main and version branches to complete so that the checks are reported accurately.

When considering and reviewing pull requests, the only workflow run that matters is the most recent.

Props ocean90, helen.
See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49244 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-20 17:44:27 +00:00
Jonathan Desrosiers
3d1f3c302d Build/Test Tools: Download Chromium for JS tests.
Partial revert of [49227].

See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49228 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-20 14:09:15 +00:00
Jonathan Desrosiers
6d32bc5192 Build/Test Tools: Download Chromium for E2E tests only.
This prevents Chromium from being downloaded in workflows where it is not required.

See #49621, #50649, #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49227 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-20 13:52:28 +00:00
Jonathan Desrosiers
6c31412a70 Build/Test Tools: Improve the clarity for PHPUnit workflow strategy.
This change makes better use of the job strategy matrix for workflows. By using `include`, the memcached and test reporting job can be configured more clearly.

Props ocean90.
See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49204 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-19 18:22:21 +00:00
Jonathan Desrosiers
b52dd8a173 Build/Test Tools: Specify the full working directory for PHPCS
Props ocean90.
See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49175 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-16 17:12:16 +00:00
Jonathan Desrosiers
01e62f0cc3 Build/Test Tools: Change the event that triggers the “Welcome” workflow.
When a contributor opens their first pull request to `wordpress-develop`, the “Welcome” workflow runs and leaves a comment with guidance, helpful information, and resources.

However, because a workflow run triggered by the `pull_request` event runs against the workflow and code from the merge commit, the needed context and permissions to comment on the pull request are missing. By changing the trigger event to `pull_request_target`, the workflow runs against the workflow and code in the base of the pull request and is able to comment on when appropriate.

See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49169 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-16 00:37:03 +00:00
Jonathan Desrosiers
285048ed3f Build/Test Tools: Do not cancel previous workflow runs.
When a workflow is cancelled, it’s marked as a failure. This is not ideal because the commit attached to the workflow run will appear as though it introduced a problem, but this may not be true.

Because GitHub Actions work a bit differently than Travis builds, it’s unlikely that the same bottleneck will be encountered in workflows.

This change removes all workflow job steps that cancel previous workflows.

See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49168 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-16 00:25:18 +00:00
Jonathan Desrosiers
e5b9d995a8 Build/Test Tools: Introduce GitHub Action workflows.
This change introduces 6 different workflows accounting for all of the testing and analysis currently performed in Travis CI & Appveyor:

- Checking PHP & JS coding standards are followed
- Running the end-to-end test suite.
- Running QUnit tests on JavaScript files.
- Scanning for PHP compatibility issues with supported version.
- Running the PHPUnit test suite.
- Verifying NPM related tasks do not cause errors on Windows.

Additionally, a seventh workflow is included that will leave a "welcome" comment when a contributor opens their first pull request to the `wordpress-develop` mirror.

These workflows are currently in an experimental phase. For that reason, Travis CI and Appveyor will continue to run until all of the bugs can be worked out.

Props ayeshrajans, helen, ocean90, desrosj.
See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49162 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-15 19:40:33 +00:00
Jonathan Desrosiers
35ddd5c97d General: Introduce a pull request template.
This ensures that contributors opening a pull request on GitHub for code review have proper guidance.

See https://make.wordpress.org/core/2020/02/21/working-on-trac-tickets-using-github-pull-requests/ and https://meta.trac.wordpress.org/ticket/4903.

Props noisysocks, desrosj.
Fixes #49489.

git-svn-id: https://develop.svn.wordpress.org/trunk@47342 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-21 18:23:28 +00:00