Skip to content

Commit

Permalink
add slack command release for pix-api-data
Browse files Browse the repository at this point in the history
Co-authored-by: Laura Bergoens <laura.bergoens@pix.fr>
Co-authored-by: Thomas Estrabaud <thomas.estrabaud@pix.fr>
Co-authored-by: Gilles Vieira <gilles.vieira@pix.fr>
Co-authored-by: Aurélie Crouillebois <aurelie.crouillebois@pix.fr>
  • Loading branch information
5 people committed Jul 18, 2023
1 parent 8f49b55 commit 30df189
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ module.exports = (function () {
production: ['pix-lcms-production'],
recette: ['pix-lcms-minimal-production'],
},
PIX_API_DATA_REPO_NAME: 'pix-api-data',
PIX_API_DATA_APPS: {
production: ['pix-api-data-production'],
},
PIX_UI_REPO_NAME: 'pix-ui',
PIX_EMBER_TESTING_LIBRARY_REPO_NAME: 'ember-testing-library',
PIX_DB_STATS_REPO_NAME: 'pix-db-stats',
Expand Down
9 changes: 9 additions & 0 deletions run/controllers/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ module.exports = {
};
},

createAndDeployPixAPIDataRelease(request) {
const payload = request.pre.payload;
commands.createAndDeployPixAPIData(payload);

return {
text: _getDeployStartedMessage(payload.text, 'PIX API DATA'),
};
},

createAndDeployPixDatawarehouseRelease(request) {
const payload = request.pre.payload;
commands.createAndDeployPixDatawarehouse(payload);
Expand Down
9 changes: 9 additions & 0 deletions run/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ manifest.registerSlashCommand({
handler: slackbotController.createAndDeployPixLCMSRelease,
});

manifest.registerSlashCommand({
command: '/deploy-pix-api-data',
path: '/slack/commands/create-and-deploy-pix-api-data-release',
description: 'Crée une release de pix-api-data et la déploie en production (https://api-data.pix.fr)',
usage_hint: '[patch, minor, major]',
should_escape: false,
handler: slackbotController.createAndDeployPixAPIDataRelease,
});

manifest.registerSlashCommand({
command: '/deploy-pix-datawarehouse',
path: '/slack/commands/create-and-deploy-pix-datawarehouse-release',
Expand Down
11 changes: 11 additions & 0 deletions run/services/slack/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const {
PIX_DATAWAREHOUSE_APPS_NAME,
PIX_LCMS_REPO_NAME,
PIX_LCMS_APPS,
PIX_API_DATA_REPO_NAME,
PIX_API_DATA_APPS,
PIX_UI_REPO_NAME,
PIX_EMBER_TESTING_LIBRARY_REPO_NAME,
PIX_DB_STATS_REPO_NAME,
Expand Down Expand Up @@ -209,6 +211,15 @@ module.exports = {
);
},

async createAndDeployPixAPIData(payload) {
await _publishAndDeployReleaseWithAppsByEnvironment(
PIX_API_DATA_REPO_NAME,
PIX_API_DATA_APPS,
payload.text,
payload.response_url,
);
},

async createAndDeployPixUI(payload) {
await _publishPixUI(PIX_UI_REPO_NAME, payload.text, payload.response_url);
},
Expand Down
7 changes: 7 additions & 0 deletions test/acceptance/run/manifest_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ describe('Acceptance | Run | Manifest', function () {
usage_hint: '[patch, minor, major]',
should_escape: false,
},
{
command: '/deploy-pix-api-data',
url: `http://${hostname}/slack/commands/create-and-deploy-pix-api-data-release`,
description: 'Crée une release de pix-api-data et la déploie en production (https://api-data.pix.fr)',
usage_hint: '[patch, minor, major]',
should_escape: false,
},
{
command: '/deploy-pix-datawarehouse',
url: `http://${hostname}/slack/commands/create-and-deploy-pix-datawarehouse-release`,
Expand Down
24 changes: 24 additions & 0 deletions test/unit/run/services/slack/commands_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const axios = require('axios');
const { catchErr, sinon } = require('../../../../test-helper');
const {
createAndDeployPixLCMS,
createAndDeployPixAPIData,
createAndDeployPixUI,
createAndDeployEmberTestingLibrary,
createAndDeployPixSiteRelease,
Expand Down Expand Up @@ -179,6 +180,29 @@ describe('Unit | Run | Services | Slack | Commands', () => {
});
});

describe('#createAndDeployPixAPIData', () => {
let client;

beforeEach(async function () {
// given
client = { deployFromArchive: sinon.spy() };
sinon.stub(ScalingoClient, 'getInstance').resolves(client);
const payload = { text: 'minor' };
// when
await createAndDeployPixAPIData(payload);
});

it('should publish a new release', () => {
// then
sinon.assert.calledWith(releasesServices.publishPixRepo, 'pix-api-data', 'minor');
});

it('should deploy the release on production', () => {
// then
sinon.assert.calledWith(client.deployFromArchive, 'pix-api-data-production', 'v1.0.0');
});
});

describe('#createAndDeployPixBotRelease', () => {
let client;
beforeEach(async function () {
Expand Down

0 comments on commit 30df189

Please sign in to comment.