Skip to content

Commit

Permalink
[FEATURE] Ajout du support d'ember-testing-library
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 27, 2021
2 parents f2b9962 + 6bbfd07 commit b6778f7
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
9 changes: 9 additions & 0 deletions common/controllers/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ module.exports = {
};
},

createAndDeployEmberTestingLibraryRelease(request) {
const payload = request.pre.payload;
commandsFromRun.createAndDeployEmberTestingLibrary(payload);

return {
'text': _getDeployStartedMessage(payload.text, 'EMBER-TESTING-LIBRARY')
};
},

createAndDeployPixBotRelease(request) {
const payload = request.pre.payload;
commandsFromRun.createAndDeployPixBotRelease(payload);
Expand Down
6 changes: 6 additions & 0 deletions common/routes/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ module.exports = [
handler: slackbotController.createAndDeployPixUIRelease,
config: slackConfig
},
{
method: 'POST',
path: '/slack/commands/create-and-deploy-ember-testing-library-release',
handler: slackbotController.createAndDeployEmberTestingLibraryRelease,
config: slackConfig
},
{
method: 'POST',
path: '/slack/commands/create-and-deploy-pix-bot-release',
Expand Down
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ module.exports = (function() {
PIX_LCMS_REPO_NAME: 'pix-editor',
PIX_LCMS_APP_NAME: 'pix-lcms',
PIX_UI_REPO_NAME: 'pix-ui',
PIX_EMBER_TESTING_LIBRARY_REPO_NAME: 'ember-testing-library',
PIX_SITE_REPO_NAME: 'pix-site',
PIX_SITE_APPS: ['pix-site', 'pix-pro'],
PIX_DATAWAREHOUSE_REPO_NAME: 'pix-db-replication',
Expand Down
22 changes: 22 additions & 0 deletions run/services/slack/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
PIX_LCMS_REPO_NAME,
PIX_LCMS_APP_NAME,
PIX_UI_REPO_NAME,
PIX_EMBER_TESTING_LIBRARY_REPO_NAME,
} = require('../../../config');
const releasesService = require('../../../common/services/releases');
const ScalingoClient = require('../../../common/services/scalingo-client');
Expand Down Expand Up @@ -61,6 +62,23 @@ async function publishAndDeployPixUI(repoName, releaseType, responseUrl) {
}
}

async function publishAndDeployEmberTestingLibrary(repoName, releaseType, responseUrl) {
if (_isReleaseTypeInvalid(releaseType)) {
postSlackMessage('Erreur lors du choix de la nouvelle version d\'ember-testing-library. Veuillez indiquer "major", "minor" ou "patch".');
throw new Error('Erreur lors du choix de la nouvelle version d\'ember-testing-library. Veuillez indiquer "major", "minor" ou "patch".');
}
const releaseTagBeforeRelease = await githubServices.getLatestReleaseTag(repoName);
await releasesService.publishPixRepo(repoName, releaseType);
const releaseTagAfterRelease = await githubServices.getLatestReleaseTag(repoName);

if (releaseTagBeforeRelease === releaseTagAfterRelease) {
sendResponse(responseUrl, getErrorReleaseMessage(releaseTagAfterRelease, repoName));
} else {
postSlackMessage(`[EMBER-TESTING-LIBRARY] Lib deployed (${releaseTagAfterRelease})`);
sendResponse(responseUrl, getSuccessMessage(releaseTagAfterRelease, repoName));
}
}

async function publishAndDeployRelease(repoName, appNamesList = [], releaseType, responseUrl) {
try {
if (_isReleaseTypeInvalid(releaseType)) {
Expand Down Expand Up @@ -130,6 +148,10 @@ module.exports = {
await publishAndDeployPixUI(PIX_UI_REPO_NAME, payload.text, payload.response_url);
},

async createAndDeployEmberTestingLibrary(payload) {
await publishAndDeployEmberTestingLibrary(PIX_EMBER_TESTING_LIBRARY_REPO_NAME, payload.text, payload.response_url);
},

async createAndDeployPixSiteRelease(payload) {
await publishAndDeployRelease(PIX_SITE_REPO_NAME, PIX_SITE_APPS, payload.text, payload.response_url);
},
Expand Down
37 changes: 37 additions & 0 deletions test/unit/run/services/slack/commands_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { catchErr, sinon } = require('../../../../test-helper');
const {
createAndDeployPixLCMS,
createAndDeployPixUI,
createAndDeployEmberTestingLibrary,
createAndDeployPixSiteRelease,
createAndDeployPixDatawarehouse,
createAndDeployPixBotRelease,
Expand Down Expand Up @@ -113,6 +114,42 @@ describe('Services | Slack | Commands', () => {
});
});

describe('#createAndDeployEmberTestingLibrary', () => {

it('should publish a new release', async () => {
// given
const payload = { text: 'minor' };

// when
await createAndDeployEmberTestingLibrary(payload);

// then
sinon.assert.calledWith(releasesServices.publishPixRepo, 'ember-testing-library', 'minor');
});

it('should retrieve the last release tag from GitHub', async () => {
// given
const payload = { text: 'minor' };

// when
await createAndDeployEmberTestingLibrary(payload);

// then
sinon.assert.calledWith(githubServices.getLatestReleaseTag, 'ember-testing-library');
});

it('should stop release if no version is given', async () => {
// given
const payload = { text: '' };

// when
const response = await catchErr(createAndDeployEmberTestingLibrary)(payload);

// then
expect(response).to.be.instanceOf(Error);
});
});

describe('#createAndDeployPixLCMS', () => {
beforeEach(async () => {
// given
Expand Down

0 comments on commit b6778f7

Please sign in to comment.