From f9814793ddb315008e2b436df0d38d5b0fec3292 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 22 Jul 2025 21:52:06 +0100 Subject: [PATCH] feat: `skipOnCI` --- src/PendingCalls/TestCall.php | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index c65122b5..102f1640 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -314,6 +314,42 @@ final class TestCall // @phpstan-ignore-line : $this; } + /** + * Skips the current test when running on a CI environments. + */ + public function skipOnCI(): self + { + foreach ([ + 'CI', + 'GITHUB_ACTIONS', + 'GITLAB_CI', + 'CIRCLECI', + 'TRAVIS', + 'APPVEYOR', + 'BITBUCKET_BUILD_NUMBER', + 'BUILDKITE', + 'TEAMCITY_VERSION', + 'JENKINS_URL', + 'SYSTEM_COLLECTIONURI', + 'CI_NAME', + 'TASKCLUSTER_ROOT_URL', + 'DRONE', + 'WERCKER', + 'NEVERCODE', + 'SEMAPHORE', + 'NETLIFY', + 'NOW_BUILDER', + ] as $env) { + if (isset($_ENV[$env])) { + return $this->skip(sprintf( + 'This test is skipped on [CI].', + )); + } + } + + return $this; + } + /** * Skips the current test unless the given test is running on Windows. */