Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ci/phan.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);
require realpath(dirname(__FILE__)).'/../vendor/autoload.php';
use Expensify\Bedrock\CI\PhanAnalyzer;

$analyzer = new PhanAnalyzer($_SERVER['TRAVIS_BRANCH']);
$analyzer = new PhanAnalyzer($_SERVER['GITHUB_REF']);
if ($analyzer->analyze()) {
exit(0);
} else {
exit(1);
}
exit(1);
14 changes: 7 additions & 7 deletions ci/src/PHPStyler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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';

Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions ci/src/PhanAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand All @@ -52,7 +52,7 @@ public function analyze()
}
}
Travis::timeFinish();
Travis::fold("end", "phan.analyze");
Travis::fold('end', 'phan.analyze');

return $lintOK;
}
Expand Down
2 changes: 1 addition & 1 deletion ci/style.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
Expand Down