Skip to content

Commit

Permalink
Change spirit to shepherd
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Mar 31, 2019
1 parent e2f9a25 commit 6a7c0f2
Show file tree
Hide file tree
Showing 20 changed files with 46 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -31,7 +31,7 @@ install:

script:
- vendor/bin/phpunit tests
- vendor/bin/psalm --with-spirit
- vendor/bin/psalm --shepherd

# Base test matrix (php/env)
matrix:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
@@ -1,6 +1,6 @@
{
"name": "psalm/shepherd",
"description": "What runs on spirit.psalm.dev",
"description": "What runs on shepherd.dev",
"type": "project",
"require": {
"php": "^7.1",
Expand All @@ -18,7 +18,7 @@
],
"autoload": {
"psr-4": {
"Psalm\\Spirit\\": "src"
"Psalm\\Shepherd\\": "src"
}
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/Api.php
@@ -1,6 +1,6 @@
<?php

namespace Psalm\Spirit;
namespace Psalm\Shepherd;

class Api
{
Expand Down
2 changes: 1 addition & 1 deletion src/Auth.php
@@ -1,6 +1,6 @@
<?php

namespace Psalm\Spirit;
namespace Psalm\Shepherd;

class Auth
{
Expand Down
2 changes: 1 addition & 1 deletion src/Config.php
@@ -1,6 +1,6 @@
<?php

namespace Psalm\Spirit;
namespace Psalm\Shepherd;

abstract class Config
{
Expand Down
4 changes: 2 additions & 2 deletions src/Config/Custom.php
@@ -1,8 +1,8 @@
<?php

namespace Psalm\Spirit\Config;
namespace Psalm\Shepherd\Config;

class Custom extends \Psalm\Spirit\Config
class Custom extends \Psalm\Shepherd\Config
{
/** @var string */
public $personal_token;
Expand Down
4 changes: 2 additions & 2 deletions src/Config/OAuthApp.php
@@ -1,8 +1,8 @@
<?php

namespace Psalm\Spirit\Config;
namespace Psalm\Shepherd\Config;

class OAuthApp extends \Psalm\Spirit\Config
class OAuthApp extends \Psalm\Shepherd\Config
{
/** @var string */
public $client_id;
Expand Down
2 changes: 1 addition & 1 deletion src/DiffLineFinder.php
@@ -1,6 +1,6 @@
<?php

namespace Psalm\Spirit;
namespace Psalm\Shepherd;

class DiffLineFinder
{
Expand Down
2 changes: 1 addition & 1 deletion src/GithubData.php
@@ -1,6 +1,6 @@
<?php

namespace Psalm\Spirit;
namespace Psalm\Shepherd;

class GithubData
{
Expand Down
2 changes: 1 addition & 1 deletion src/PsalmData.php
@@ -1,6 +1,6 @@
<?php

namespace Psalm\Spirit;
namespace Psalm\Shepherd;

class PsalmData
{
Expand Down
2 changes: 1 addition & 1 deletion src/PsalmPlugin/GitApiReturnTypeProvider.php
@@ -1,6 +1,6 @@
<?php

namespace Psalm\Spirit\PsalmPlugin;
namespace Psalm\Shepherd\PsalmPlugin;

use PhpParser;
use Psalm\CodeLocation;
Expand Down
2 changes: 1 addition & 1 deletion src/Sender.php
@@ -1,6 +1,6 @@
<?php

namespace Psalm\Spirit;
namespace Psalm\Shepherd;

class Sender
{
Expand Down
2 changes: 1 addition & 1 deletion tests/GithubDiffLineTest.php
Expand Up @@ -14,7 +14,7 @@ public function testValidCode(
?int $expected
) {
$this->assertSame(
\Psalm\Spirit\DiffLineFinder::getGitHubPositionFromDiff(
\Psalm\Shepherd\DiffLineFinder::getGitHubPositionFromDiff(
$line_from,
$file_name,
file_get_contents(__DIR__ . '/test.diff')
Expand Down
4 changes: 2 additions & 2 deletions views/auth/github.php
Expand Up @@ -2,9 +2,9 @@

require '../../vendor/autoload.php';

$config = Psalm\Spirit\Config::getInstance();
$config = Psalm\Shepherd\Config::getInstance();

if (!$config instanceof Psalm\Spirit\Config\OAuthApp) {
if (!$config instanceof Psalm\Shepherd\Config\OAuthApp) {
throw new \UnexpectedValueException('Cannot use oauth flow if config not proper');
}

Expand Down
4 changes: 2 additions & 2 deletions views/auth/github_configure.php
Expand Up @@ -2,9 +2,9 @@

require '../../vendor/autoload.php';

$config = Psalm\Spirit\Config::getInstance();
$config = Psalm\Shepherd\Config::getInstance();

if (!$config instanceof Psalm\Spirit\Config\OAuthApp) {
if (!$config instanceof Psalm\Shepherd\Config\OAuthApp) {
throw new \UnexpectedValueException('Cannot use oauth flow if config not proper');
}

Expand Down
6 changes: 3 additions & 3 deletions views/auth/github_redirect.php
Expand Up @@ -2,9 +2,9 @@

require '../../vendor/autoload.php';

$config = Psalm\Spirit\Config::getInstance();
$config = Psalm\Shepherd\Config::getInstance();

if (!$config instanceof Psalm\Spirit\Config\OAuthApp) {
if (!$config instanceof Psalm\Shepherd\Config\OAuthApp) {
throw new \UnexpectedValueException('Cannot use oauth flow if config not proper');
}

Expand All @@ -21,7 +21,7 @@
throw new \UnexpectedValueException('No code sent');
}

$github_token = Psalm\Spirit\Auth::fetchTokenFromGithub($code, $state, $config);
$github_token = Psalm\Shepherd\Auth::fetchTokenFromGithub($code, $state, $config);

setcookie('github_token', $github_token);

Expand Down
8 changes: 4 additions & 4 deletions views/hook.php
Expand Up @@ -8,7 +8,7 @@

error_reporting(E_ALL);

$config = Psalm\Spirit\Config::getInstance();
$config = Psalm\Shepherd\Config::getInstance();

$raw_post = file_get_contents('php://input');

Expand All @@ -25,7 +25,7 @@
throw new \UnexpectedValueException('Unrecognised payload');
}

if ($config instanceof Psalm\Spirit\Config\Custom && $config->webhook_secret) {
if ($config instanceof Psalm\Shepherd\Config\Custom && $config->webhook_secret) {
$hash = 'sha1=' . hash_hmac('sha1', $raw_post, $config->webhook_secret, false);

if (!isset($_SERVER['HTTP_X_HUB_SIGNATURE'])) {
Expand All @@ -44,7 +44,7 @@
&& ($payload['ref'] ?? '') === 'refs/heads/master'
&& isset($payload['repository'])
) {
Psalm\Spirit\GithubData::storeMasterData(
Psalm\Shepherd\GithubData::storeMasterData(
$payload['after'],
$payload
);
Expand All @@ -63,7 +63,7 @@
throw new \UnexpectedValueException('Bad git commit hash given');
}

Psalm\Spirit\GithubData::storePullRequestData(
Psalm\Shepherd\GithubData::storePullRequestData(
$git_commit_hash,
$payload
);
42 changes: 17 additions & 25 deletions views/reprocess.php
Expand Up @@ -14,33 +14,25 @@
throw new \UnexpectedValueException('Bad git commit hash given');
}

$psalm_storage_path = Psalm\Spirit\PsalmData::getStoragePath($git_commit_hash);
$github_storage_path = Psalm\Shepherd\GithubData::getPullRequestStoragePath($git_commit_hash);

if (!file_exists($github_storage_path)) {
throw new \UnexpectedValueException('No data from GitHub');
}

$psalm_storage_path = Psalm\Shepherd\PsalmData::getStoragePath($git_commit_hash);

if (!file_exists($psalm_storage_path)) {
throw new \UnexpectedValueException('No data from Psalm CI');
}

$payload = json_decode(file_get_contents($psalm_storage_path), true);

$github_pr_storage_path = Psalm\Spirit\GithubData::getPullRequestStoragePath($git_commit_hash);

if (!file_exists($github_pr_storage_path)) {
if (!empty($payload['build']['CI_PR_REPO_OWNER'])
&& !empty($payload['build']['CI_PR_REPO_NAME'])
&& !empty($payload['build']['CI_PR_NUMBER'])
&& !empty($payload['build']['CI_REPO_OWNER'])
&& !empty($payload['build']['CI_REPO_NAME'])
&& $payload['build']['CI_PR_NUMBER'] !== "false"
) {
$owner = $payload['build']['CI_REPO_OWNER'];
$repo_name = $payload['build']['CI_REPO_NAME'];
$pr_number = (int) $payload['build']['CI_PR_NUMBER'];

Psalm\Spirit\GithubData::fetchPullRequestDataForCommit(
$git_commit_hash,
$owner,
$repo_name,
$pr_number
);
}
}
$gh_pr_data = json_decode(file_get_contents($github_storage_path), true);

Psalm\Shepherd\Sender::send(
Psalm\Shepherd\Auth::getToken(
$gh_pr_data['pull_request']['base']['repo']['owner']['login'],
$gh_pr_data['pull_request']['base']['repo']['name']
),
$gh_pr_data,
json_decode(file_get_contents($psalm_storage_path), true)
);
2 changes: 1 addition & 1 deletion views/shield.php
Expand Up @@ -12,7 +12,7 @@
throw new \UnexpectedValueException('Unexpected values in repository name');
}

$pct = Psalm\Spirit\Api::getTypeCoverage($repository);
$pct = Psalm\Shepherd\Api::getTypeCoverage($repository);

header('Content-type: image/svg+xml;charset=utf-8');
header('Cache-control: max-age=0, no-cache');
Expand Down
2 changes: 1 addition & 1 deletion views/telemetry.php
Expand Up @@ -20,4 +20,4 @@
throw new \UnexpectedValueException('Bad git commit hash given');
}

Psalm\Spirit\PsalmData::storeJson($git_commit_hash, $payload);
Psalm\Shepherd\PsalmData::storeJson($git_commit_hash, $payload);

0 comments on commit 6a7c0f2

Please sign in to comment.