Skip to content

Commit

Permalink
Use deploy-configuration for pix-apim, GeoAPI and pix-360
Browse files Browse the repository at this point in the history
Co-authored-by: François de Metz <francois.de-metz@pix.fr>
Co-authored-by: Guillaume Lagorce <guillaume.lagorce@pix.fr>
  • Loading branch information
3 people committed Jul 18, 2023
1 parent 91d2339 commit 1d1732a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 160 deletions.
6 changes: 0 additions & 6 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,8 @@ module.exports = (function () {
PIX_APPS_ENVIRONMENTS: ['integration', 'recette', 'production'],
PIX_TUTOS_REPO_NAME: 'pix-tutos',
PIX_TUTOS_APP_NAME: 'pix-tutos',
PIX_APIM_REPO_NAME: 'pix-nginx-apim',
PIX_APIM_APPS_NAME: 'pix-nginx-apim-production',
PIX_GEOAPI_REPO_NAME: 'geoapi',
PIX_GEOAPI_APP_NAME: 'pix-geoapi-production',
PIX_AIRFLOW_APP_NAME: 'pix-airflow-production',
PIX_DBT_APPS_NAME: ['pix-dbt-production', 'pix-dbt-external-production'],
PIX_360_REPO_NAME: 'pix-360',
PIX_360_APP_NAME: 'pix-360-production',
};

if (process.env.NODE_ENV === 'test') {
Expand Down
26 changes: 0 additions & 26 deletions run/controllers/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,6 @@ function _getDeployStartedMessage(release, appName) {
}

module.exports = {
deployPixAPIM(request) {
const payload = request.pre.payload;
commands.deployPixAPIM(payload);

return {
text: 'Commande de déploiement de Pix APIM en production bien reçue.',
};
},

deployGeoAPI(request) {
const payload = request.pre.payload;
commands.deployGeoAPI(payload);

return {
text: 'Commande de déploiement de GeoAPI en production bien reçue.',
};
},

deployAirflow(request) {
const payload = request.pre.payload;
commands.deployAirflow(payload);
Expand Down Expand Up @@ -135,14 +117,6 @@ module.exports = {
};
},

deployPix360() {
commands.deployPix360();

return {
text: 'Commande de déploiement de Pix 360 en production bien reçue.',
};
},

interactiveEndpoint(request) {
const payload = request.pre.payload;

Expand Down
27 changes: 27 additions & 0 deletions run/deploy-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,31 @@ module.exports = [
slackReturnText: 'Commande de déploiement de Metabase en production bien reçue.',
deployFunction: fromBranch('metabase-deploy', ['pix-metabase-production', 'pix-data-metabase-production'], 'master'),
},
{
slashCommand: {
command: '/deploy-pix-apim',
description: 'Pour déployer les applications Pix APIM depuis la branche main',
usage_hint: '/deploy-pix-apim',
},
slackReturnText: 'Commande de déploiement de Pix APIM en production bien reçue.',
deployFunction: fromBranch('pix-nginx-apim', ['pix-nginx-apim-production'], 'main'),
},
{
slashCommand: {
command: '/deploy-geoapi',
description: 'Déploie GeoAPI en production depuis la branche main',
usage_hint: '/deploy-geoapi',
},
slackReturnText: 'Commande de déploiement de GeoAPI en production bien reçue.',
deployFunction: fromBranch('geoapi', ['pix-geoapi-production'], 'main'),
},
{
slashCommand: {
command: '/deploy-pix-360',
description: 'Pour déployer pix 360 depuis la branche main',
usage_hint: '/deploy-pix-360',
},
slackReturnText: 'Commande de déploiement de Pix 360 en production bien reçue.',
deployFunction: fromBranch('pix-360', ['pix-360-production'], 'main'),
},
];
26 changes: 0 additions & 26 deletions run/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,6 @@ manifest.registerSlashCommand({
handler: slackbotController.createAndDeployPixTutosRelease,
});

manifest.registerSlashCommand({
command: '/deploy-pix-apim',
path: '/slack/commands/deploy-pix-apim',
description: 'Pour déployer les applications Pix APIM depuis la branche main',
should_escape: false,
handler: slackbotController.deployPixAPIM,
});

manifest.registerSlashCommand({
command: '/deploy-airflow',
path: '/slack/commands/deploy-airflow',
Expand All @@ -102,24 +94,6 @@ manifest.registerSlashCommand({
handler: slackbotController.deployAirflow,
});

manifest.registerSlashCommand({
command: '/deploy-geoapi',
path: '/slack/commands/deploy-geoapi',
description: 'Déploie GeoAPI en production depuis la branche main',
usage_hint: '/deploy-geoapi',
should_escape: false,
handler: slackbotController.deployGeoAPI,
});

manifest.registerSlashCommand({
command: '/deploy-pix-360',
path: '/slack/commands/deploy-pix-360',
description: 'Pour déployer pix 360 depuis la branche main',
usage_hint: '/deploy-pix-360',
should_escape: false,
handler: slackbotController.deployPix360,
});

manifest.registerSlashCommand({
command: '/app-status',
path: '/slack/commands/app-status',
Expand Down
18 changes: 0 additions & 18 deletions run/services/slack/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ const {
PIX_DB_STATS_APPS_NAME,
PIX_TUTOS_REPO_NAME,
PIX_TUTOS_APP_NAME,
PIX_APIM_REPO_NAME,
PIX_APIM_APPS_NAME,
PIX_GEOAPI_REPO_NAME,
PIX_GEOAPI_APP_NAME,
PIX_AIRFLOW_APP_NAME,
PIX_DBT_APPS_NAME,
PIX_360_REPO_NAME,
PIX_360_APP_NAME,
} = require('../../../config');
const releasesService = require('../../../common/services/releases');
const ScalingoClient = require('../../../common/services/scalingo-client');
Expand Down Expand Up @@ -178,18 +172,6 @@ module.exports = {
await deployTagUsingSCM(PIX_DBT_APPS_NAME, version);
},

async deployPixAPIM() {
await deployer.fromBranch(PIX_APIM_REPO_NAME, [PIX_APIM_APPS_NAME], 'main')();
},

async deployGeoAPI() {
await deployer.fromBranch(PIX_GEOAPI_REPO_NAME, [PIX_GEOAPI_APP_NAME], 'main')();
},

async deployPix360() {
await deployer.fromBranch(PIX_360_REPO_NAME, [PIX_360_APP_NAME], 'main')();
},

async createAndDeployPixLCMS(payload) {
await _publishAndDeployReleaseWithAppsByEnvironment(
PIX_LCMS_REPO_NAME,
Expand Down
64 changes: 0 additions & 64 deletions test/integration/run/services/slack/commands_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,6 @@ const commands = require('../../../../../run/services/slack/commands');
const { expect, nock } = require('../../../../test-helper');

describe('Integration | Run | Services | Slack | Commands', function () {
describe('#deployPixAPIM', function () {
it('should call Scalingo API to deploy the main branch', async function () {
const scalingoTokenNock = nock(`https://auth.scalingo.com`).post('/v1/tokens/exchange').reply(200, {});

const deploymentPayload = {
deployment: {
git_ref: 'main',
source_url: 'https://undefined@github.com/github-owner/pix-nginx-apim/archive/main.tar.gz',
},
};
const nockDeploys = nock('https://scalingo.production')
.post(`/v1/apps/pix-nginx-apim-production/deployments`, deploymentPayload)
.reply(200, {});

await commands.deployPixAPIM();

expect(scalingoTokenNock.isDone()).to.be.true;

expect(nockDeploys.isDone()).to.be.true;
});
});

describe('#deployGeoAPI', function () {
it('should call Scalingo API to deploy the main branch', async function () {
const scalingoTokenNock = nock(`https://auth.scalingo.com`).post('/v1/tokens/exchange').reply(200, {});

const deploymentPayload = {
deployment: {
git_ref: 'main',
source_url: 'https://undefined@github.com/github-owner/geoapi/archive/main.tar.gz',
},
};
const nockDeploy = nock('https://scalingo.production')
.post(`/v1/apps/pix-geoapi-production/deployments`, deploymentPayload)
.reply(200, {});

await commands.deployGeoAPI();

expect(scalingoTokenNock.isDone()).to.be.true;
expect(nockDeploy.isDone()).to.be.true;
});
});

describe('#deployPix360', function () {
it('should call Scalingo API to deploy the main branch', async function () {
const scalingoTokenNock = nock(`https://auth.scalingo.com`).post('/v1/tokens/exchange').reply(200, {});

const deploymentPayload = {
deployment: {
git_ref: 'main',
source_url: 'https://undefined@github.com/github-owner/pix-360/archive/main.tar.gz',
},
};
const nockDeploy = nock('https://scalingo.production')
.post(`/v1/apps/pix-360-production/deployments`, deploymentPayload)
.reply(200, {});

await commands.deployPix360();

expect(scalingoTokenNock.isDone()).to.be.true;
expect(nockDeploy.isDone()).to.be.true;
});
});

describe('#deployAirflow', function () {
it('should call Scalingo API to deploy a specified tag', async function () {
const scalingoTokenNock = nock(`https://auth.scalingo.com`).post('/v1/tokens/exchange').reply(200, {});
Expand Down
20 changes: 0 additions & 20 deletions test/unit/run/services/slack/commands_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const {
createAndDeployPixBotRelease,
getAndDeployLastVersion,
createAndDeployDbStats,
deployGeoAPI,
createAndDeployPixTutosRelease,
} = require('../../../../../run/services/slack/commands');
const releasesServices = require('../../../../../common/services/releases');
Expand Down Expand Up @@ -296,23 +295,4 @@ describe('Unit | Run | Services | Slack | Commands', () => {
sinon.assert.calledWith(releasesServices.deployPixRepo);
});
});

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

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

it('should deploy the release', () => {
// then
sinon.assert.calledWith(client.deployFromArchive, 'pix-geoapi-production', 'main', 'geoapi', {
withEnvSuffix: false,
});
});
});
});

0 comments on commit 1d1732a

Please sign in to comment.