WordPress.org

Make WordPress Core

Ticket #50401: 50401.4.diff

File 50401.4.diff, 1.7 KB (added by desrosj, 12 months ago)

Detects GitHub Actions during automated tests.

  • tests/phpunit/includes/abstract-testcase.php

     
    181181        /**
    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
     185         * other than trunk/master, we want to skip tests that
     186         * only need to run for master.
    186187         */
    187188        public function skipOnAutomatedBranches() {
    188189                // https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
    189190                $travis_branch       = getenv( 'TRAVIS_BRANCH' );
    190191                $travis_pull_request = getenv( 'TRAVIS_PULL_REQUEST' );
    191192
    192                 if ( ! $travis_branch || ! $travis_pull_request ) {
    193                         return;
    194                 }
     193                // https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
     194                $github_branch = getenv( 'GITHUB_REF' );
    195195
    196                 if ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) {
    197                         $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
     196                if ( $travis_branch && $travis_pull_request ) {
     197                        if ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) {
     198                                $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
     199                        }
     200                } elseif ( $github_branch ) {
     201                        if ( false !== strpos( $github_branch, 'master' ) ) {
     202                                $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
     203                        }
    198204                }
    199205        }
    200206