Ensure release ZIP is built from latest commit
[MAILPOET-1883]
This commit is contained in:
@ -38,6 +38,7 @@ class CircleCiController {
|
|||||||
],
|
],
|
||||||
'base_uri' => 'https://circleci.com/api/v1.1/project/github/' . urlencode($username) . "/$circle_ci_project/",
|
'base_uri' => 'https://circleci.com/api/v1.1/project/github/' . urlencode($username) . "/$circle_ci_project/",
|
||||||
]);
|
]);
|
||||||
|
$this->github_controller = $github_controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function downloadLatestBuild($target_path) {
|
public function downloadLatestBuild($target_path) {
|
||||||
@ -75,6 +76,14 @@ class CircleCiController {
|
|||||||
if ($job['has_artifacts'] === false) {
|
if ($job['has_artifacts'] === false) {
|
||||||
throw new \Exception('Job has no artifacts');
|
throw new \Exception('Job has no artifacts');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensure we're downloading latest revision on given branch
|
||||||
|
$revision = $this->github_controller->getLatestCommitRevisionOnBranch(self::RELEASE_BRANCH);
|
||||||
|
if ($revision === null || $job['vcs_revision'] !== $revision) {
|
||||||
|
throw new \Exception(
|
||||||
|
"Found ZIP was built from revision '$revision' but the latest one is '$job[vcs_revision]'"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getReleaseZipUrl($build_number) {
|
private function getReleaseZipUrl($build_number) {
|
||||||
|
@ -43,6 +43,19 @@ class GitHubController {
|
|||||||
$this->publishDraftAsRelease($release_info['id']);
|
$this->publishDraftAsRelease($release_info['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLatestCommitRevisionOnBranch($branch) {
|
||||||
|
try {
|
||||||
|
$response = $this->http_client->get('commits/' . urlencode($branch));
|
||||||
|
$data = json_decode($response->getBody()->getContents(), true);
|
||||||
|
} catch (ClientException $e) {
|
||||||
|
if ($e->getCode() === 404) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
return $data['sha'];
|
||||||
|
}
|
||||||
|
|
||||||
private function ensureNoDraftReleaseExists() {
|
private function ensureNoDraftReleaseExists() {
|
||||||
$response = $this->http_client->get('releases');
|
$response = $this->http_client->get('releases');
|
||||||
$data = json_decode($response->getBody()->getContents(), true);
|
$data = json_decode($response->getBody()->getContents(), true);
|
||||||
|
Reference in New Issue
Block a user