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. git-svn-id: https://develop.svn.wordpress.org/trunk@49264 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9648a29c05
commit
87ff38532d
@ -181,19 +181,25 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* Allow tests to be skipped on some automated runs.
|
||||
*
|
||||
* For test runs on Travis for something other than trunk/master
|
||||
* we want to skip tests that only need to run for master.
|
||||
* For test runs on Travis/GitHub Actions for something other than trunk/master, we want to skip tests that
|
||||
* only need to run for master.
|
||||
*/
|
||||
public function skipOnAutomatedBranches() {
|
||||
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
|
||||
$travis_branch = getenv( 'TRAVIS_BRANCH' );
|
||||
$travis_pull_request = getenv( 'TRAVIS_PULL_REQUEST' );
|
||||
|
||||
if ( ! $travis_branch || ! $travis_pull_request ) {
|
||||
// https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
|
||||
$github_event_name = getenv( 'GITHUB_EVENT_NAME' );
|
||||
$github_ref = getenv( 'GITHUB_REF' );
|
||||
|
||||
if ( ( ! $travis_branch || ! $travis_pull_request ) && ! $github_event_name ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) {
|
||||
if ( ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) && empty( $github_event_name ) ) {
|
||||
$this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
|
||||
} elseif ( in_array( $github_event_name, array( 'pull_request', 'pull_request_target' ), true ) || 'refs/heads/master' !== $github_ref ) {
|
||||
$this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user