diff --git a/ci/phan.php b/ci/phan.php index ecf99f3..f162456 100755 --- a/ci/phan.php +++ b/ci/phan.php @@ -1,12 +1,12 @@ #!/usr/bin/env php analyze()) { exit(0); -} else { - exit(1); } +exit(1); diff --git a/ci/src/PHPStyler.php b/ci/src/PHPStyler.php index 7e29e17..9c78024 100755 --- a/ci/src/PHPStyler.php +++ b/ci/src/PHPStyler.php @@ -8,12 +8,12 @@ class PHPStyler extends CommandLine { /** - * @var string Branch we are checking (usually coming from['TRAVIS_BRANCH']) + * @var string Branch we are checking (usually coming from['GITHUB_REF']) */ private $branch; /** - * @var string Commit we are checking (usually coming from['TRAVIS_COMMIT']) + * @var string Commit we are checking (usually coming from['GITHUB_SHA']) */ private $commit; @@ -39,7 +39,7 @@ public function check() $PHPLintCommand = "find . -name '*.php' -not \\( -path './externalLib/*' -or -path './vendor/*' -or -path './build/*' \\) -print0 | xargs -0 -L 1 -n 1 -P 8 php -l 1>/dev/null"; if ($this->branch === 'main') { - Travis::foldCall("lintmaster.php", $PHPLintCommand); + Travis::foldCall('lintmaster.php', $PHPLintCommand); echo 'Skipping style check for merge commits'; @@ -48,9 +48,9 @@ public function check() $this->checkoutBranch($this->branch); - Travis::foldCall("lint.php", $PHPLintCommand); + Travis::foldCall('lint.php', $PHPLintCommand); - Travis::fold("start", "style.php"); + Travis::fold('start', 'style.php'); Travis::timeStart(); echo 'Enforce PHP style'.PHP_EOL; $output = $this->getModifiedFiles($this->branch); @@ -83,13 +83,13 @@ public function check() } Travis::timeFinish(); - Travis::fold("end", "style.php"); + Travis::fold('end', 'style.php'); if (!$lintOK) { return false; } - Travis::foldCall("git.checkout2", "git checkout {$this->commit} 2>&1"); + Travis::foldCall('git.checkout2', "git checkout {$this->commit} 2>&1"); return true; } diff --git a/ci/src/PhanAnalyzer.php b/ci/src/PhanAnalyzer.php index ec81446..b581c1b 100755 --- a/ci/src/PhanAnalyzer.php +++ b/ci/src/PhanAnalyzer.php @@ -8,7 +8,7 @@ class PhanAnalyzer extends CommandLine { /** - * @var string Branch we are checking (usually coming from['TRAVIS_BRANCH']) + * @var string Branch we are checking (usually coming from['GITHUB_REF']) */ private $branch; @@ -35,12 +35,12 @@ public function analyze() $this->checkoutBranch($this->branch); - Travis::fold("start", "phan.analyze"); + Travis::fold('start', 'phan.analyze'); Travis::timeStart(); echo 'Analyze PHP using Phan'.PHP_EOL; $changedFiles = $this->eexec("git diff main...{$this->branch} --name-status | egrep \"^[A|M].*\\.php$\" | cut -f 2"); - echo "Analyzing files:".PHP_EOL; - $lintErrors = $this->eexec("./vendor/bin/phan -p -z --processes 5", false); + echo 'Analyzing files:'.PHP_EOL; + $lintErrors = $this->eexec('./vendor/bin/phan -p -z --processes 5', false); $lintOK = true; foreach ($lintErrors as $lintError) { foreach ($changedFiles as $file) { @@ -52,7 +52,7 @@ public function analyze() } } Travis::timeFinish(); - Travis::fold("end", "phan.analyze"); + Travis::fold('end', 'phan.analyze'); return $lintOK; } diff --git a/ci/style.php b/ci/style.php index 8498688..88b6404 100755 --- a/ci/style.php +++ b/ci/style.php @@ -5,6 +5,6 @@ require realpath(dirname(__FILE__)).'/../vendor/autoload.php'; use Expensify\Bedrock\CI\PHPStyler; -$styler = new PHPStyler($_SERVER['TRAVIS_BRANCH'], $_SERVER['TRAVIS_COMMIT']); +$styler = new PHPStyler($_SERVER['GITHUB_REF'], $_SERVER['GITHUB_SHA']); $valid = $styler->check(); exit((int) !$valid); diff --git a/composer.json b/composer.json index a2f8c63..6c18749 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "expensify/bedrock-php", "description": "Bedrock PHP Library", "type": "library", - "version": "2.2.2", + "version": "2.2.4", "authors": [ { "name": "Expensify", diff --git a/src/Client.php b/src/Client.php index a9c5ea8..1725b38 100644 --- a/src/Client.php +++ b/src/Client.php @@ -607,14 +607,14 @@ private function sendRawRequest(string $host, int $port, string $rawRequest) * @param ?string $preferredHost If passed, it will prefer this host over any of the configured ones. This does not * ensure it will use that host, but it will try to use it if its not blacklisted. * - * @suppress PhanUndeclaredConstant - suppresses TRAVIS_RUNNING + * @suppress PhanUndeclaredConstant - suppresses ARE_GITHUB_ACTIONS_RUNNING */ private function getPossibleHosts(?string $preferredHost, bool $resetHosts = false) { // We get the host configs from the APC cache. Then, we check the configuration there with the passed // configuration and if it's outdated (ie: it has different hosts from the one in the config), we reset it. This // is so that we don't keep the old cache after changing the hosts or failover configuration. - if (!defined('TRAVIS_RUNNING') || !TRAVIS_RUNNING) { + if (!defined('ARE_GITHUB_ACTIONS_RUNNING') || !ARE_GITHUB_ACTIONS_RUNNING) { $apcuKey = self::APCU_CACHE_PREFIX.$this->clusterName; if ($resetHosts) { $this->logger->info('Bedrock\Client - Resetting host configs'); @@ -838,12 +838,12 @@ private static function toUTF8($str) * configuration. * We also close and clear the socket from the cache, so we don't reuse it. * - * @suppress PhanUndeclaredConstant - suppresses TRAVIS_RUNNING + * @suppress PhanUndeclaredConstant - suppresses ARE_GITHUB_ACTIONS_RUNNING */ private function markHostAsFailed(string $host) { $blacklistedUntil = time() + rand(1, $this->maxBlackListTimeout); - if (!defined('TRAVIS_RUNNING') || !TRAVIS_RUNNING) { + if (!defined('ARE_GITHUB_ACTIONS_RUNNING') || !ARE_GITHUB_ACTIONS_RUNNING) { $apcuKey = self::APCU_CACHE_PREFIX.$this->clusterName; $hostConfigs = apcu_fetch($apcuKey); $hostConfigs[$host]['blacklistedUntil'] = $blacklistedUntil;