Skip to content

Commit 5bb2ac9

Browse files
authored
VACMS-4222: Refactor and add tests for BRD frontend build class. (#4231)
* Throws exception when we fail to retrieve the Jenkins API token. * VACMS-4222: Refactor in progress, adds test class. * Factors out BRD client stuff into a separate Jenkins-specific client class. * Sneaks in PHPStan through the back door. * Ugh, fine. * Fixes some issues turned up by static analysis. * Adds SystemsManagerClient service, refactors JenkinsClient further, adds embryonic test for JenkinsClient. * Factors out build-time recording into a separate service. * Adds BuildTimeRecorderTest and SystemsManagerClientTest. * Factors out Jenkins-specific HTTP client and middleware generation and adds an overarching BRD environment plugin class test.
1 parent 7176bd4 commit 5bb2ac9

19 files changed

+1078
-135
lines changed

composer.json

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"require": {
1515
"alchemy/zippy": "^0.4.9",
16+
"aws/aws-sdk-php": "^3.173",
1617
"bower-asset/blazy": "^1.8",
1718
"bower-asset/cropper": "^4.1",
1819
"bower-asset/dropzone": "^5.5",
@@ -135,6 +136,7 @@
135136
"http-interop/http-factory-guzzle": "^1.0",
136137
"knplabs/github-api": "^2.12.1",
137138
"michelf/php-markdown": "^1.8",
139+
"mikey179/vfsstream": "^1.6",
138140
"mouf/nodejs-installer": "^1.0",
139141
"npm-asset/yarn": "1.21.1",
140142
"oomphinc/composer-installers-extender": "1.1.2",

composer.lock

+199-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace Drupal\va_gov_build_trigger\Exception;
4+
5+
use GuzzleHttp\Psr7\Response;
6+
7+
/**
8+
* A wrapper for exceptions that occur in the Jenkins client.
9+
*/
10+
class JenkinsClientException extends \Exception {
11+
12+
/**
13+
* The Jenkins build job URL.
14+
*
15+
* @var string
16+
*/
17+
public $buildJobUrl;
18+
19+
/**
20+
* Create with a response object.
21+
*
22+
* @param \GuzzleHttp\Psr7\Response $response
23+
* An error response.
24+
* @param string $buildJobUrl
25+
* The build job URL.
26+
*
27+
* @return \Drupal\va_gov_build_trigger\Exception\JenkinsClientException
28+
* An exception of this class.
29+
*/
30+
public static function createWithResponse(Response $response, string $buildJobUrl): JenkinsClientException {
31+
$statusCode = $response->getStatusCode();
32+
$reasonPhrase = $response->getReasonPhrase();
33+
$message = "Site rebuild failed with status code {$statusCode} {$reasonPhrase} and URL {$buildJobUrl}.";
34+
$result = new static($message);
35+
$result->buildJobUrl = $buildJobUrl;
36+
return $result;
37+
}
38+
39+
}

0 commit comments

Comments
 (0)