This fixes the code added in [53466] to look at the correct workflow object when determining the outcome of the previous workflow run.
See #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53468 602fd350-edb4-49c9-b593-d223f7449a82
When searching for previous workflow runs by branch, GitHub currently includes matches within forks.
If a contributor opens a pull request from their fork with a `head_ref` matching a Core branch that triggers a workflow on `push` event, the outcomes of the workflows associated with that pull request are currently used to determine if the previous workflow run had failed.
The result is a false “fixed” notifications when a commit immediately follows a failed workflow run from the pull request.
This adds a check to skip any workflow runs not triggered by a `push` event to prevent these inaccurate notifications.
Props SergeyBiryukov.
See #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53466 602fd350-edb4-49c9-b593-d223f7449a82
This adjusts the workflow run URLs included in Slack notifications to link to the specific attempt being reported on making it easier for someone to see the proper context of a specific notification.
Additionally, this eliminates the need for a contributor to share the reason for a failure in Slack before restarting the workflow, as the link will always be to that specificattempt. When a “fixed” notification occurs for a subsequent run attempt, the link will be to the new, successful run attempt.
See #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53427 602fd350-edb4-49c9-b593-d223f7449a82
This updates all 3rd party GitHub actions to their latest versions.
- `actions/cache` from `2.1.6` to `3.0.1`.
- `actions/github-script` from `5.0.0` to `6.0.0`.
- `actions/setup-node` from `2.4.1` to `3.1.0`.
- `codecov/codecov-action` from `2.1.0` to `3.0.0`.
- `ramsey/composer-install` from `1.3.0` to `2.1.0`.
- `shivammathur/setup-php` from `2.15.0` to `2.18.0`.
Additionally, this updates all instances of the `actions/setup-node` action to replace the `node-version` option with the new `node-version-file`. This simplifies the process of changing the version of NodeJS used in workflows by only requiring the version to be changed once in the `.nvmrc` file.
See #54725.
git-svn-id: https://develop.svn.wordpress.org/trunk@53112 602fd350-edb4-49c9-b593-d223f7449a82
This adjusts the logic of the Slack Notifications workflow to make the “fixed” notifications more reliable.
Currently, the workflow looks at the immediately preceding workflow run for the current branch. This fails to indicate that a workflow is fixed when other unrelated commits are made, and when rerunning the workflow after a false failure (timeout, etc.).
The workflow will now use the following logic to determine if something has been fixed:
- When a workflow is rerun, the conclusion for the immediately preceding run attempt will now be used to determine if the current attempt has “fixed” the workflow.
- When on the first run attempt for a workflow run, the workflow conclusion for the immediately preceding commit will be used.
- When on the first run attempt for a workflow run and no preceding commits for the current branch are present (this is a fresh tag or branch), always consider it “fixed”.
Props davidbaumwald.
See #54742.
git-svn-id: https://develop.svn.wordpress.org/trunk@53108 602fd350-edb4-49c9-b593-d223f7449a82
This fixes a JavaScript error in the Slack notifications workflow. This was causing the first workflow run for each workflow in a new branch or tag to be reported as a failure, even if the important parts of the workflow succeed.
When running a workflow for the first time, a default of `failure` is now used for the previous outcome. This will trigger a success notification to be sent to report successful branching/tagging.
Props davidbaumwald.
Fixes#54742.
git-svn-id: https://develop.svn.wordpress.org/trunk@53077 602fd350-edb4-49c9-b593-d223f7449a82
After the 5.9 branch was created, [52449] updated the workflow for testing old branches to include 5.9. However, the E2E tests `-branch` condition was updated to 5.9 instead of adding an additional branch condition for 5.9. This commit re-enables the E2E tests for 5.8.
Props desrosj, hellofromTonya.
Fixes#54749.
git-svn-id: https://develop.svn.wordpress.org/trunk@52546 602fd350-edb4-49c9-b593-d223f7449a82
This eliminates the need to manually check all GitHub Actions used within workflow files for updates.
Fixes#54503.
git-svn-id: https://develop.svn.wordpress.org/trunk@52241 602fd350-edb4-49c9-b593-d223f7449a82
This ensures that the cache is busted properly when the ruleset is adjusted but the `composer.json` file is not.
See #54425.
git-svn-id: https://develop.svn.wordpress.org/trunk@52220 602fd350-edb4-49c9-b593-d223f7449a82
When the `PHP_CodeSniffer` runs, it produces a cache file. When a cache file is present, only changed files are rescanned, making subsequent scans significantly faster.
This adds the needed steps to the corresponding GitHub Actions workflows to cache these files across runs. The cache keys include the date of the previous Monday to ensure that the cache is flushed at least weekly.
Since GitHub Action caches cannot be updated once created, the scans will take slightly longer as the week progresses and more PHP files are updated. The date within the cache key can be updated to purge twice weekly if the scan time starts to approach the current scan times.
This change also introduces a `.cache` directory for all caching files related to build/test tools.
Props johnbillion, jrf.
Fixes#49783.
git-svn-id: https://develop.svn.wordpress.org/trunk@52179 602fd350-edb4-49c9-b593-d223f7449a82
When using a workflow as a callable workflow, the job status check functions do not take the called workflow into account. This has caused some failures to be incorrectly reported as successful.
This adds an input to the Slack notifications workflow for when the `workflow_call` event is used.
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@52002 602fd350-edb4-49c9-b593-d223f7449a82
This makes the needed adjustments to fix Slack notifications for `scheduled` and `workflow_dispatch` events. The data needed to send notifications for these events are stored in different locations, or need to be accessed through API requests.
Follow up to [51921], [51937].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51953 602fd350-edb4-49c9-b593-d223f7449a82
When a workflow is triggered through a `workflow_run` event, the context is not the original workflow. The details about the original workflow are passed through the `github.event` context.
This also moves the conditional check controlling whether the Slack workflow is run into the calling workflows to prevent them from running for pull requests.
Follow up to [51921-51922,51924-51925,51934].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51937 602fd350-edb4-49c9-b593-d223f7449a82
In [51921], the GitHub Actions workflows were updated to utilize the Slack notifications workflow as a callable one instead of on the `workflow_run` event.
This eliminated the need for an additional “Slack Notifications” workflow run for every completed workflow, but only when other workflows are updated as well. This resulted in notifications from older branches breaking, as the changes in [51921] were not backported.
Instead of backporting the needed changes now (the Slack workflow is still being polished), this commit partially restores the `workflow_run` event for older branches so that notifications will resume.
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51934 602fd350-edb4-49c9-b593-d223f7449a82
Secrets are not available within callable workflows by default. They must be defined within the callable workflow, and passed from the calling workflow.
Follow up to [51921-51922].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51924 602fd350-edb4-49c9-b593-d223f7449a82
The ability to reuse workflow files within GitHub Action workflows was recently added and allows for less code duplication.
In the context of WordPress Core, this also eliminates the need for an additional “Slack Notifications” workflow to run for every completed workflow.
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51921 602fd350-edb4-49c9-b593-d223f7449a82
This unpins the version of PHP 5.6.20 used when testing the 5.6 branch of PHP.
Using 5.6.20 was an intentional decision in [49162], as that patch version is the oldest version of PHP 5.6 still supported by WordPress. However, as of September 30, 2021, the `5.6.20` image contains a version of OpenSSL with an expired certificate, sometimes resulting in an expired trust chain.
Props Clorith, hellofromTonya, SergeyBiryukov, desrosj.
Merges [51889] to `trunk`.
Fixes#54223.
git-svn-id: https://develop.svn.wordpress.org/trunk@51890 602fd350-edb4-49c9-b593-d223f7449a82
This commit:
* Removes the PHPUnit `wordpressdevelop/phpunit` container as a service to the Docker environment.
* Updates `test:php` (the default way to run tests) to run the Composer PHPUnit package default.
* Removes the `test:php-composer` script.
There is no longer a need for core to keep the `wordpressdevelop/phpunit` container as a service in `docker-compose.yml`. Removing it will reduce the overhead and bandwidth needed to set up WordPress locally and remove confusion about its use.
Follow-up to [45783-45784], [49099], [49362], [51545], [51736], [51685].
Props johnbillion, hellofromTonya.
Fixes#54112.
git-svn-id: https://develop.svn.wordpress.org/trunk@51868 602fd350-edb4-49c9-b593-d223f7449a82
This fixes the CI for PHP 8.1 while retaining the needed improvements for local testing when running `npm run test:php-composer` by:
* Replacing the npm script with the full node command
* Removing the `composer update` command from the `env:install` process
Props BinaryKitten, hellofromTonya
See #53945
git-svn-id: https://develop.svn.wordpress.org/trunk@51736 602fd350-edb4-49c9-b593-d223f7449a82
bash is the default shell for all non-Windows GitHub Action runners, so this is not necessary.
Follow up to [51670].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51671 602fd350-edb4-49c9-b593-d223f7449a82
This gives more context to GitHub Action related Slack messages without the need to click the workflow URL, or unfurl the links (which shows lots of unnecessary information, such as the repository description and image).
Props earnjam.
See #52644.
git-svn-id: https://develop.svn.wordpress.org/trunk@51647 602fd350-edb4-49c9-b593-d223f7449a82
This removes the previously duplicated set of test runs specifically for PHP 8.1 in favor of combining `if` conditions for individual test runs with the `continue-on-error` option.
Follow-up to [51588].
Props desrosj, swissspidy, jrf.
Fixes#53891.
git-svn-id: https://develop.svn.wordpress.org/trunk@51604 602fd350-edb4-49c9-b593-d223f7449a82
PHP 8.1 is expected to be released at the end of November 2021.
Enabling the tests to run in CI on PHP 8.1 allows us to get WordPress ready in time.
As an interim measure, while working through the PHP 8.1 issues, separate conditional steps are added to run the tests on PHP 8.1 with the `continue-on-error` option. That allows the test builds to show as "successful" if all non-PHP 8.1 test runs pass.
Follow-up to [51517], [51543], [51545], [51574], [51582], [51586].
Props jrf.
Fixes#53891. See #53635.
git-svn-id: https://develop.svn.wordpress.org/trunk@51588 602fd350-edb4-49c9-b593-d223f7449a82
Since branch filtering happens prior to the workflow run being created, filtering the branches that `workflow_run` will fire on for this workflow should cut down on the number of skipped “Slack Notifications” runs listed in the Actions section of the repository.
This also removes the check for a `skipped` outcome in the requesting workflow. Workflows for push events resulting from WordPress Core commits are never skipped.
See #52644.
git-svn-id: https://develop.svn.wordpress.org/trunk@51558 602fd350-edb4-49c9-b593-d223f7449a82
This updates the conditional check for the Slack notifications workflow to check the event of the original workflow and not the one requested through the `workflow_run:completed` event.
The run triggering the event is accessible at `github.event.workflow_run`.
Props Clorith.
See #52644.
git-svn-id: https://develop.svn.wordpress.org/trunk@51555 602fd350-edb4-49c9-b593-d223f7449a82
Previously the tests were run via a PHPUnit Phar file for PHP 5.6–7.4, with PHP 8.0 using a Composer-installed version of PHPUnit.
Running the tests via a Phar without the need for a `composer install` is (marginally) faster in overall build time, however, this commit is part of a larger chain of changes which will make the test suite PHPUnit cross-version compatible.
With an eye on those upcoming changes, which will allow us to run the tests on the most appropriate PHPUnit version for each supported PHP version, it is opportune to switch to using a Composer-installed version of PHPUnit for all PHP versions supported by WordPress. Previously this was not possible without additional conditional `update` commands being run, due to the `composer.lock` file being in place and being locked at PHPUnit 7.5.20.
Switching over to using the Composer-installed PHPUnit version, with that PHPUnit version adjusting based on the PHP version, allows for some minor simplifications in the GitHub Actions script.
This means we need additional measures to make sure that the Composer cache file does not go too far out of date as that would significantly slow down the builds.
By adding a "Last Monday" date to the cache key, in combination with the pre-existing OS, PHP version and the hash of the `composer.json` file, we can guarantee that:
1. There will be a cache created for each OS/PHP combination.
2. These caches will be replaced whenever a change is made to the `composer.json` file.
3. These caches will be replaced every Monday of each week ensuring that the cache file does not go too far out of date.
Note: The NPM script `test:php` is now no longer needed during the builds. However, to prevent breaking the workflow of contributors who may be used to having the command available, the command remains available.
In a future iteration we may be able to replace the caching of the Composer dependencies with the Composer cache action as offered on the GitHub marketplace, which would further simplify the script.
Follow-up to [42960], [46290], [47881], [48957], [49037], [51543], [51544].
Props jrf, desrosj.
Fixes#47381.
git-svn-id: https://develop.svn.wordpress.org/trunk@51545 602fd350-edb4-49c9-b593-d223f7449a82
This expands Slack notifications to include success, cancelled, and “fixed” GitHub Action workflow run outcomes in addition to failures.
A “fixed” outcome occurs when the previous run for a workflow failed and the current one succeeds. This matches the behavior that was native to TravisCI by setting `on_success` for notifications to `change`.
The message details and where each outcome is posted is controlled by Slack workflows.
The Slack notification logic has also been pulled into a separate workflow to prevent repeating code in every workflow.
See #52644.
git-svn-id: https://develop.svn.wordpress.org/trunk@51535 602fd350-edb4-49c9-b593-d223f7449a82
This adds an additional step to each GitHub Action workflow file that posts a message to #core in Slack every time a workflow run fails.
A minor test and spacing change is included in this commit in order to that messages are posted correctly and will be reverted after testing.
See #52644.
git-svn-id: https://develop.svn.wordpress.org/trunk@51511 602fd350-edb4-49c9-b593-d223f7449a82
This workflow does not perform a `git checkout` and is only used to dispatch workflows for old branches, so this check is not needed here.
Fixes#53799.
git-svn-id: https://develop.svn.wordpress.org/trunk@51498 602fd350-edb4-49c9-b593-d223f7449a82
Some tests and some commands that run during the build steps modify files that are under version control. This adds assertions to ensure that these files don't remain in a modified state after the test runs on CI.
This also fixes the `grunt clean` command which erroneously deletes `script-loader-packages.php`. This file is re-populated during the build, but deleting it during the clean is undesirable.
Fixes#53606
git-svn-id: https://develop.svn.wordpress.org/trunk@51355 602fd350-edb4-49c9-b593-d223f7449a82
This updates the `actions/setup-node` action to version 2.2.2 and takes advantage of the cache feature now built in. This removes the need for an additional step using `actions/cache` to cache NPM dependencies.
The cache key used will be `${{ runner.os }}-npm-${{ hashFiles('') }}`, which matches the recommendation in the `actions/cache` documentation and the key currently in use in the WordPress workflows.
Props gziolo.
Fixes#53584.
git-svn-id: https://develop.svn.wordpress.org/trunk@51341 602fd350-edb4-49c9-b593-d223f7449a82
The new `concurrency` setting can be used to ensure only a single workflow run or job is in progress. When used in combination with the `cancel-in-progress` setting, incomplete workflow runs can be cancelled automatically to prevent running workflows unnecessarily.
The workflows that take longer to run previously had this built into a step and utilized a 3rd-party action. Now that this is natively supported by GitHub Actions, using that is preferred.
This option is currently in beta, but is stable enough to use in our workflows for the time being.
Props ocean90.
Fixes#53080.
git-svn-id: https://develop.svn.wordpress.org/trunk@50930 602fd350-edb4-49c9-b593-d223f7449a82
Because the `--` separator was missing, the `--dev` flag was not being passed to the script, thus not testing properly.
See #52625.
git-svn-id: https://develop.svn.wordpress.org/trunk@50796 602fd350-edb4-49c9-b593-d223f7449a82
This adjusts the workflow responsible for testing old branches to only test old branches once per month. This more closely resembles the testing practices previously in place on TravisCI.
The latest, supported branch will continue to be tested twice per month.
This also makes adjustments so that the workflow is run whenever changes are made to it. This will help verify changes without having to wait until the next scheduled run.
Fixes#52653.
git-svn-id: https://develop.svn.wordpress.org/trunk@50763 602fd350-edb4-49c9-b593-d223f7449a82
The reorganization of the PHPUnit workflow in [50441] unintentionally caused the tests to be run for every `push` event, even for forks and private mirrors.
Previously, the second job required the first one to pass, and the conditional check on the first prevented both from running. Because the first job is no longer required for the second, both jobs must have the appropriate conditional check.
Fixes#52983.
git-svn-id: https://develop.svn.wordpress.org/trunk@50670 602fd350-edb4-49c9-b593-d223f7449a82