Make WordPress Core

Changeset 49264


Ignore:
Timestamp:
10/21/2020 02:05:39 PM (4 years ago)
Author:
desrosj
Message:

Build/Test Tools: Skip some tests when not in the primary branch.

This skips time sensitive tests when GitHub Actions workflows are not being run on master branch.

See #50401, #39486.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r49001 r49264  
    182182     * Allow tests to be skipped on some automated runs.
    183183     *
    184      * For test runs on Travis for something other than trunk/master
    185      * we want to skip tests that only need to run for master.
     184     * For test runs on Travis/GitHub Actions for something other than trunk/master, we want to skip tests that
     185     * only need to run for master.
    186186     */
    187187    public function skipOnAutomatedBranches() {
     
    190190        $travis_pull_request = getenv( 'TRAVIS_PULL_REQUEST' );
    191191
    192         if ( ! $travis_branch || ! $travis_pull_request ) {
     192        // https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
     193        $github_event_name = getenv( 'GITHUB_EVENT_NAME' );
     194        $github_ref        = getenv( 'GITHUB_REF' );
     195
     196        if ( ( ! $travis_branch || ! $travis_pull_request ) && ! $github_event_name ) {
    193197            return;
    194198        }
    195199
    196         if ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) {
     200        if ( ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) && empty( $github_event_name ) ) {
     201            $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
     202        } elseif ( in_array( $github_event_name, array( 'pull_request', 'pull_request_target' ), true ) || 'refs/heads/master' !== $github_ref ) {
    197203            $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
    198204        }
Note: See TracChangeset for help on using the changeset viewer.