Skip to content

Commit b6778f7

Browse files
[FEATURE] Ajout du support d'ember-testing-library
2 parents f2b9962 + 6bbfd07 commit b6778f7

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

common/controllers/slack.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ module.exports = {
3131
};
3232
},
3333

34+
createAndDeployEmberTestingLibraryRelease(request) {
35+
const payload = request.pre.payload;
36+
commandsFromRun.createAndDeployEmberTestingLibrary(payload);
37+
38+
return {
39+
'text': _getDeployStartedMessage(payload.text, 'EMBER-TESTING-LIBRARY')
40+
};
41+
},
42+
3443
createAndDeployPixBotRelease(request) {
3544
const payload = request.pre.payload;
3645
commandsFromRun.createAndDeployPixBotRelease(payload);

common/routes/slack.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ module.exports = [
3030
handler: slackbotController.createAndDeployPixUIRelease,
3131
config: slackConfig
3232
},
33+
{
34+
method: 'POST',
35+
path: '/slack/commands/create-and-deploy-ember-testing-library-release',
36+
handler: slackbotController.createAndDeployEmberTestingLibraryRelease,
37+
config: slackConfig
38+
},
3339
{
3440
method: 'POST',
3541
path: '/slack/commands/create-and-deploy-pix-bot-release',

config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ module.exports = (function() {
9393
PIX_LCMS_REPO_NAME: 'pix-editor',
9494
PIX_LCMS_APP_NAME: 'pix-lcms',
9595
PIX_UI_REPO_NAME: 'pix-ui',
96+
PIX_EMBER_TESTING_LIBRARY_REPO_NAME: 'ember-testing-library',
9697
PIX_SITE_REPO_NAME: 'pix-site',
9798
PIX_SITE_APPS: ['pix-site', 'pix-pro'],
9899
PIX_DATAWAREHOUSE_REPO_NAME: 'pix-db-replication',

run/services/slack/commands.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
PIX_LCMS_REPO_NAME,
1212
PIX_LCMS_APP_NAME,
1313
PIX_UI_REPO_NAME,
14+
PIX_EMBER_TESTING_LIBRARY_REPO_NAME,
1415
} = require('../../../config');
1516
const releasesService = require('../../../common/services/releases');
1617
const ScalingoClient = require('../../../common/services/scalingo-client');
@@ -61,6 +62,23 @@ async function publishAndDeployPixUI(repoName, releaseType, responseUrl) {
6162
}
6263
}
6364

65+
async function publishAndDeployEmberTestingLibrary(repoName, releaseType, responseUrl) {
66+
if (_isReleaseTypeInvalid(releaseType)) {
67+
postSlackMessage('Erreur lors du choix de la nouvelle version d\'ember-testing-library. Veuillez indiquer "major", "minor" ou "patch".');
68+
throw new Error('Erreur lors du choix de la nouvelle version d\'ember-testing-library. Veuillez indiquer "major", "minor" ou "patch".');
69+
}
70+
const releaseTagBeforeRelease = await githubServices.getLatestReleaseTag(repoName);
71+
await releasesService.publishPixRepo(repoName, releaseType);
72+
const releaseTagAfterRelease = await githubServices.getLatestReleaseTag(repoName);
73+
74+
if (releaseTagBeforeRelease === releaseTagAfterRelease) {
75+
sendResponse(responseUrl, getErrorReleaseMessage(releaseTagAfterRelease, repoName));
76+
} else {
77+
postSlackMessage(`[EMBER-TESTING-LIBRARY] Lib deployed (${releaseTagAfterRelease})`);
78+
sendResponse(responseUrl, getSuccessMessage(releaseTagAfterRelease, repoName));
79+
}
80+
}
81+
6482
async function publishAndDeployRelease(repoName, appNamesList = [], releaseType, responseUrl) {
6583
try {
6684
if (_isReleaseTypeInvalid(releaseType)) {
@@ -130,6 +148,10 @@ module.exports = {
130148
await publishAndDeployPixUI(PIX_UI_REPO_NAME, payload.text, payload.response_url);
131149
},
132150

151+
async createAndDeployEmberTestingLibrary(payload) {
152+
await publishAndDeployEmberTestingLibrary(PIX_EMBER_TESTING_LIBRARY_REPO_NAME, payload.text, payload.response_url);
153+
},
154+
133155
async createAndDeployPixSiteRelease(payload) {
134156
await publishAndDeployRelease(PIX_SITE_REPO_NAME, PIX_SITE_APPS, payload.text, payload.response_url);
135157
},

test/unit/run/services/slack/commands_test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const { catchErr, sinon } = require('../../../../test-helper');
55
const {
66
createAndDeployPixLCMS,
77
createAndDeployPixUI,
8+
createAndDeployEmberTestingLibrary,
89
createAndDeployPixSiteRelease,
910
createAndDeployPixDatawarehouse,
1011
createAndDeployPixBotRelease,
@@ -113,6 +114,42 @@ describe('Services | Slack | Commands', () => {
113114
});
114115
});
115116

117+
describe('#createAndDeployEmberTestingLibrary', () => {
118+
119+
it('should publish a new release', async () => {
120+
// given
121+
const payload = { text: 'minor' };
122+
123+
// when
124+
await createAndDeployEmberTestingLibrary(payload);
125+
126+
// then
127+
sinon.assert.calledWith(releasesServices.publishPixRepo, 'ember-testing-library', 'minor');
128+
});
129+
130+
it('should retrieve the last release tag from GitHub', async () => {
131+
// given
132+
const payload = { text: 'minor' };
133+
134+
// when
135+
await createAndDeployEmberTestingLibrary(payload);
136+
137+
// then
138+
sinon.assert.calledWith(githubServices.getLatestReleaseTag, 'ember-testing-library');
139+
});
140+
141+
it('should stop release if no version is given', async () => {
142+
// given
143+
const payload = { text: '' };
144+
145+
// when
146+
const response = await catchErr(createAndDeployEmberTestingLibrary)(payload);
147+
148+
// then
149+
expect(response).to.be.instanceOf(Error);
150+
});
151+
});
152+
116153
describe('#createAndDeployPixLCMS', () => {
117154
beforeEach(async () => {
118155
// given

0 commit comments

Comments
 (0)