Build/Test Tools: Pass GitHub Action related environment variables to the Docker container.
This ensures that `WP_UnitTestCase::skipOnAutomatedBranches()` has access to these variables so that time sensitive tests can be skipped when appropriate. This also updates that logic to be more clear. Follow up to [49264]. Props ocean90, johnbillion. See #50401, #49050, #47767. git-svn-id: https://develop.svn.wordpress.org/trunk@49267 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
530493396b
commit
91b5e5255e
@ -110,6 +110,8 @@ services:
|
||||
PHP_FPM_GID: ${PHP_FPM_GID-1000}
|
||||
TRAVIS_BRANCH: ${TRAVIS_BRANCH-false}
|
||||
TRAVIS_PULL_REQUEST: ${TRAVIS_PULL_REQUEST-false}
|
||||
GITHUB_REF: ${GITHUB_REF-false}
|
||||
GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME-false}
|
||||
|
||||
volumes:
|
||||
- ./tools/local-env/phpunit-config.ini:/usr/local/etc/php/conf.d/phpunit-config.ini
|
||||
|
@ -193,14 +193,18 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase {
|
||||
$github_event_name = getenv( 'GITHUB_EVENT_NAME' );
|
||||
$github_ref = getenv( 'GITHUB_REF' );
|
||||
|
||||
if ( ( ! $travis_branch || ! $travis_pull_request ) && ! $github_event_name ) {
|
||||
return;
|
||||
}
|
||||
if ( 'false' !== $github_event_name ) {
|
||||
// We're on GitHub Actions.
|
||||
$skipped = array( 'pull_request', 'pull_request_target' );
|
||||
|
||||
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' );
|
||||
if ( in_array( $github_event_name, $skipped, true ) || 'refs/heads/master' !== $github_ref ) {
|
||||
$this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master - GitHub only' );
|
||||
}
|
||||
} elseif ( 'false' !== $travis_branch ) {
|
||||
// We're on Travis CI.
|
||||
if ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) {
|
||||
$this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master - Travis only' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user