Skip to content

Commit

Permalink
[FEATURE] Envoyer le commentaire de déploiement des RAs sur les PRs q…
Browse files Browse the repository at this point in the history
…uelque soit leur état

 #511
  • Loading branch information
pix-service-auto-merge authored Jan 28, 2025
2 parents f72ff40 + 96b1a91 commit cef6bc7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build/controllers/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ async function deployPullRequest(
const reviewAppName = `${appName}-pr${prId}`;
try {
const reviewAppExists = await client.reviewAppExists(reviewAppName);
deployedRA.push({ name: appName, isCreated: !reviewAppExists });
if (reviewAppExists) {
await client.deployUsingSCM(reviewAppName, ref);
} else {
Expand All @@ -173,7 +174,6 @@ async function deployPullRequest(
await client.disableAutoDeploy(reviewAppName);
await client.deployUsingSCM(reviewAppName, ref);
}
deployedRA.push({ name: appName, isCreated: !reviewAppExists });
} catch (error) {
logger.error({
event: 'review-app',
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/build/github_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ describe('Acceptance | Build | Github', function () {
expect(addRADeploymentCheck.isDone()).to.be.true;
expect(res.statusCode).to.equal(200);
expect(res.result).to.eql(
'Triggered deployment of RA on app pix-api-review, pix-audit-logger-review with pr 2',
'Triggered deployment of RA on app pix-api-review, pix-audit-logger-review, pix-front-review with pr 2',
);
});
});
Expand Down
18 changes: 0 additions & 18 deletions test/unit/build/controllers/github_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,24 +662,6 @@ Les variables d'environnement seront accessibles sur scalingo https://dashboard.
});
});

it('throws an error on scalingo deployment fails', async function () {
// given
const scalingoClientStub = sinon.stub();
const deployUsingSCMStub = sinon.stub().rejects(new Error('Deployment error'));
const reviewAppExistsStub = sinon.stub().resolves(true);
scalingoClientStub.getInstance = sinon.stub().returns({
deployUsingSCM: deployUsingSCMStub,
reviewAppExists: reviewAppExistsStub,
});

// when
const result = await catchErr(githubController.handleRA)(request, scalingoClientStub);

// then
expect(result).to.be.instanceOf(Error);
expect(result.message).to.equal('No RA deployed for repository pix and pr3');
});

describe('when the review app does not exist', function () {
it('should call scalingo to create and deploy the corresponding applications', async function () {
// given
Expand Down

0 comments on commit cef6bc7

Please sign in to comment.