Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-140554 FG: pages are LIVE after 'promote only' workflow #83

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion actions/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
************************************************************************* */

const crypto = require('crypto');
const { strToArray, getAioLogger } = require('./utils');
const { strToArray, strToBool, getAioLogger } = require('./utils');
const UrlInfo = require('./urlInfo');

// Max activation is 1hrs, set to 2hrs
Expand Down Expand Up @@ -222,6 +222,10 @@ class AppConfig {
}
return draftsOnly;
}

getDoPublish() {
return strToBool(this.getPayload().doPublish);
}
}

module.exports = new AppConfig();
3 changes: 1 addition & 2 deletions actions/promote/postCopyWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ async function main(params) {
const fgAction = new FgAction(`${PROMOTE_BATCH}_${batchNumber}`, params);
fgAction.init({ ow, skipUserDetails: true, fgStatusParams: { keySuffix: `Batch_${batchNumber}` } });
const { fgStatus } = fgAction.getActionParams();
const payload = appConfig.getPayload();
const fgRootFolder = appConfig.getSiteFgRootPath();

let respPayload;
Expand All @@ -61,7 +60,7 @@ async function main(params) {
statusMessage: respPayload
});

respPayload = await previewPublish(payload.doPublish, batchManager);
respPayload = await previewPublish(appConfig.getDoPublish(), batchManager);
await fgStatus.updateStatusToStateLib({
status: FgStatus.PROJECT_STATUS.COMPLETED,
statusMessage: respPayload
Expand Down
5 changes: 2 additions & 3 deletions actions/promote/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ async function main(params) {
const fgAction = new FgAction(`${PROMOTE_BATCH}_${batchNumber}`, params);
fgAction.init({ ow, skipUserDetails: true, fgStatusParams: { keySuffix: `Batch_${batchNumber}` } });
const { fgStatus } = fgAction.getActionParams();
const payload = appConfig.getPayload();
const fgRootFolder = appConfig.getSiteFgRootPath();

let respPayload;
Expand All @@ -73,7 +72,7 @@ async function main(params) {
});
respPayload = 'Promote files';
logger.info(respPayload);
respPayload = await promoteFloodgatedFiles(payload.doPublish, batchManager);
respPayload = await promoteFloodgatedFiles(batchManager);
respPayload = `Promoted files ${JSON.stringify(respPayload)}`;
await fgStatus.updateStatusToStateLib({
status: FgStatus.PROJECT_STATUS.IN_PROGRESS,
Expand Down Expand Up @@ -130,7 +129,7 @@ async function promoteCopy(srcPath, destinationFolder) {
return copySuccess;
}

async function promoteFloodgatedFiles(doPublish, batchManager) {
async function promoteFloodgatedFiles(batchManager) {
const logger = getAioLogger();

async function promoteFile(batchItem) {
Expand Down
10 changes: 9 additions & 1 deletion actions/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ function strToArray(val) {
return val;
}

function strToBool(val) {
if (val !== undefined && typeof val === 'string') {
return val.trim().toLowerCase() === 'true';
}
return val;
}

function toUTCStr(dt) {
const ret = new Date(dt);
return Number.isNaN(ret.getTime()) ? dt : ret.toUTCString();
Expand Down Expand Up @@ -192,5 +199,6 @@ module.exports = {
strToArray,
toUTCStr,
isFilePathWithWildcard,
isFilePatternMatched
isFilePatternMatched,
strToBool
};
1 change: 1 addition & 0 deletions test/appConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ describe('appConfig', () => {
}
});
expect(appConfig.isDraftOnly()).toBeTruthy();
expect(appConfig.getDoPublish()).not.toBeTruthy();

appConfig.removePayload();
expect(() => appConfig.getPayload()).toThrow();
Expand Down
15 changes: 15 additions & 0 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,18 @@ describe('isFilePatternMatched', () => {
expect(utils.isFilePatternMatched('/a/b/query-index.xlsx', patterns)).toBe(true);
});
});

describe('strToBool', () => {
test('Check for a set of true and false inputs', () => {
expect(utils.strToBool('true')).toBeTruthy();
expect(utils.strToBool('TRUE')).toBeTruthy();
expect(utils.strToBool(true)).toBeTruthy();
expect(utils.strToBool('false')).not.toBeTruthy();
expect(utils.strToBool('FALSE')).not.toBeTruthy();
expect(utils.strToBool(false)).not.toBeTruthy();
expect(utils.strToBool('something')).not.toBeTruthy();
expect(utils.strToBool('')).not.toBeTruthy();
expect(utils.strToBool(null)).not.toBeTruthy();
expect(utils.strToBool(undefined)).not.toBeTruthy();
});
});
Loading