@24i/smartapps-bigscreen-rnv-build-engine 0.17.12-alpha.2-test → 0.17.12-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/scripts/release/notifySlack/makePayload.js +1 -1
- package/dist/src/scripts/smokeTest/notifySlack.js +46 -0
- package/dist/src/scripts/smokeTest/smokeTestUtils.js +103 -0
- package/dist/src/scripts/smokeTest.js +63 -0
- package/dist/templates/platforms/_shared/webpack.base.js +0 -8
- package/package.json +1 -2
- /package/dist/src/scripts/{release/notifySlack → utils}/slackBlockKitBuilder.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeDistributionPayload = exports.makeReleaseCandidatePayload = exports.makeDevelopmentPayload = void 0;
|
|
4
|
-
const slackBlockKitBuilder_1 = require("
|
|
4
|
+
const slackBlockKitBuilder_1 = require("../../utils/slackBlockKitBuilder");
|
|
5
5
|
const buildSchemes_1 = require("../../../constants/buildSchemes");
|
|
6
6
|
const resolvers_1 = require("../../../resolvers");
|
|
7
7
|
const getVersionsObject = (c) => (0, resolvers_1.resolveDeployLocations)(c).versions;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.notifySlack = exports.getFailSlackPayload = exports.getSuccessSlackPayload = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const slackBlockKitBuilder_1 = require("../utils/slackBlockKitBuilder");
|
|
6
|
+
const getSuccessSlackPayload = (params) => {
|
|
7
|
+
const { appName, suitestConfigId } = params;
|
|
8
|
+
const title = `Smoke test *succeeded* for *${appName}* app! :large_green_circle:`;
|
|
9
|
+
return getSlackPayload({ title, suitestConfigId });
|
|
10
|
+
};
|
|
11
|
+
exports.getSuccessSlackPayload = getSuccessSlackPayload;
|
|
12
|
+
const getFailSlackPayload = (params) => {
|
|
13
|
+
const { appName, suitestConfigId, logsZipUrl } = params;
|
|
14
|
+
const title = `Smoke test *failed* for *${appName}* app! :red_circle:`;
|
|
15
|
+
return getSlackPayload({ title, suitestConfigId, logsZipUrl });
|
|
16
|
+
;
|
|
17
|
+
};
|
|
18
|
+
exports.getFailSlackPayload = getFailSlackPayload;
|
|
19
|
+
const getSlackPayload = (params) => {
|
|
20
|
+
const { title, suitestConfigId, logsZipUrl } = params;
|
|
21
|
+
return {
|
|
22
|
+
blocks: [
|
|
23
|
+
slackBlockKitBuilder_1.Divider.plain(),
|
|
24
|
+
slackBlockKitBuilder_1.Section.mrkdwn(title),
|
|
25
|
+
slackBlockKitBuilder_1.Context.mrkdwns([
|
|
26
|
+
`Suitest Config ID: ${suitestConfigId}`,
|
|
27
|
+
]),
|
|
28
|
+
slackBlockKitBuilder_1.Actions.buttons([
|
|
29
|
+
{
|
|
30
|
+
url: process.env.TRAVIS_BUILD_WEB_URL || 'https://travis-ci.com/',
|
|
31
|
+
text: 'View Travis Build Log',
|
|
32
|
+
},
|
|
33
|
+
...(logsZipUrl ? [{
|
|
34
|
+
text: 'View Suitest Log files',
|
|
35
|
+
url: logsZipUrl,
|
|
36
|
+
}] : []),
|
|
37
|
+
]),
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const notifySlack = (webHookUrl, data) => {
|
|
42
|
+
const contentType = '"Content-type: application/json"';
|
|
43
|
+
const cmd = `curl -X POST -H ${contentType} --data '${data}' ${webHookUrl}`;
|
|
44
|
+
(0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
|
|
45
|
+
};
|
|
46
|
+
exports.notifySlack = notifySlack;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.sendFailToSlack = exports.resolveLogsZipUrl = exports.uploadLogsZipToS3 = exports.zipLogFiles = exports.generateLogsZipName = exports.sendSuccessToSlack = exports.execTestbedCmd = void 0;
|
|
27
|
+
const child_process_1 = require("child_process");
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
const fs = __importStar(require("fs"));
|
|
30
|
+
const aws = __importStar(require("../../tasks/deploy/aswS3/aws"));
|
|
31
|
+
const notifySlack_1 = require("./notifySlack");
|
|
32
|
+
const execTestbedCmd = (cmd) => {
|
|
33
|
+
const configIdRegex = /^.*app configuration id: ([a-z\d\-]+)/m;
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const child = (0, child_process_1.exec)(cmd, (error, stdout) => {
|
|
36
|
+
const matches = stdout.match(configIdRegex) || [];
|
|
37
|
+
const suitestConfigId = matches[1] ?? '';
|
|
38
|
+
if (error) {
|
|
39
|
+
console.log(error);
|
|
40
|
+
resolve({ status: false, suitestConfigId });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
resolve({ status: true, suitestConfigId });
|
|
44
|
+
});
|
|
45
|
+
child.stdout?.on('data', (data) => {
|
|
46
|
+
process.stdout.write(data);
|
|
47
|
+
});
|
|
48
|
+
child.stderr?.on('data', (data) => {
|
|
49
|
+
process.stderr.write(data);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
exports.execTestbedCmd = execTestbedCmd;
|
|
54
|
+
const sendSuccessToSlack = (c, suitestConfigId) => {
|
|
55
|
+
console.log('sendSuccessToSlack');
|
|
56
|
+
const appName = c.buildConfig.common.appName ?? '';
|
|
57
|
+
const webHookUrl = c.buildConfig.common.deploy.slack?.webhookUrl ?? '';
|
|
58
|
+
const data = (0, notifySlack_1.getSuccessSlackPayload)({ appName, suitestConfigId });
|
|
59
|
+
(0, notifySlack_1.notifySlack)(webHookUrl, JSON.stringify(data));
|
|
60
|
+
};
|
|
61
|
+
exports.sendSuccessToSlack = sendSuccessToSlack;
|
|
62
|
+
const sendFailToSlack = (c, params) => {
|
|
63
|
+
console.log('sendFailToSlack');
|
|
64
|
+
const { logsZipUrl, suitestConfigId } = params;
|
|
65
|
+
const appName = c.buildConfig.common.appName ?? '';
|
|
66
|
+
const webHookUrl = c.buildConfig.common.deploy.slack?.webhookUrl ?? '';
|
|
67
|
+
const data = (0, notifySlack_1.getFailSlackPayload)({ appName, logsZipUrl, suitestConfigId });
|
|
68
|
+
(0, notifySlack_1.notifySlack)(webHookUrl, JSON.stringify(data));
|
|
69
|
+
};
|
|
70
|
+
exports.sendFailToSlack = sendFailToSlack;
|
|
71
|
+
const generateLogsZipName = (c) => {
|
|
72
|
+
const appNameInFileName = c.buildConfig.common.appNameInFileName ?? '';
|
|
73
|
+
return `${appNameInFileName}_${formatDateTime(new Date())}.zip`;
|
|
74
|
+
};
|
|
75
|
+
exports.generateLogsZipName = generateLogsZipName;
|
|
76
|
+
const zipLogFiles = (c, outputZipFilePath, logDir) => {
|
|
77
|
+
const srcDir = path.resolve(logDir);
|
|
78
|
+
fs.rmSync(outputZipFilePath, { force: true });
|
|
79
|
+
(0, child_process_1.execSync)(`zip ${outputZipFilePath} -0 -r *`, { cwd: srcDir });
|
|
80
|
+
};
|
|
81
|
+
exports.zipLogFiles = zipLogFiles;
|
|
82
|
+
const formatDateTime = (date) => {
|
|
83
|
+
const year = date.getFullYear();
|
|
84
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
85
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
86
|
+
const h = String(date.getHours()).padStart(2, '0');
|
|
87
|
+
const m = String(date.getMinutes()).padStart(2, '0');
|
|
88
|
+
const s = String(date.getSeconds()).padStart(2, '0');
|
|
89
|
+
return `${year}-${month}-${day}T${h}-${m}-${s}`;
|
|
90
|
+
};
|
|
91
|
+
const logsDirPathOnS3 = () => 'testbed';
|
|
92
|
+
const uploadLogsZipToS3 = (c, zipFilePath) => {
|
|
93
|
+
const zipFileName = path.parse(zipFilePath).base;
|
|
94
|
+
const bucketName = c.buildConfig?.common.deploy?.aws3?.bucketName || '';
|
|
95
|
+
const uploadPath = `${bucketName}/${logsDirPathOnS3()}/${zipFileName}`;
|
|
96
|
+
aws.cp(zipFilePath, uploadPath);
|
|
97
|
+
};
|
|
98
|
+
exports.uploadLogsZipToS3 = uploadLogsZipToS3;
|
|
99
|
+
const resolveLogsZipUrl = (c, zipFileName) => {
|
|
100
|
+
const hostedBaseUrl = c.buildConfig?.common?.hostedUrl?.baseUrl;
|
|
101
|
+
return `${hostedBaseUrl}/${logsDirPathOnS3()}/${zipFileName}`;
|
|
102
|
+
};
|
|
103
|
+
exports.resolveLogsZipUrl = resolveLogsZipUrl;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const path = __importStar(require("path"));
|
|
27
|
+
const resolvers_1 = require("../resolvers");
|
|
28
|
+
const constants_1 = require("../constants");
|
|
29
|
+
const smokeTestUtils_1 = require("./smokeTest/smokeTestUtils");
|
|
30
|
+
const smokeTest = async () => {
|
|
31
|
+
const command = process.argv[2];
|
|
32
|
+
const tokenId = process.env.SUITEST_TOKEN_ID ?? '';
|
|
33
|
+
const tokenPassword = process.env.SUITEST_TOKEN_PASSWORD ?? '';
|
|
34
|
+
const logDir = './testbed_log/';
|
|
35
|
+
let cmd = command ?? [
|
|
36
|
+
`npx testbed run`,
|
|
37
|
+
tokenId ? `-k ${tokenId}` : '',
|
|
38
|
+
tokenPassword ? `-p ${tokenPassword}` : '',
|
|
39
|
+
`-C .suitestrc_webtv`,
|
|
40
|
+
`--log-dir ${logDir}`,
|
|
41
|
+
`--log-level "normal"`,
|
|
42
|
+
`-- mocha "./test/platforms/common/smoke.test-suite.ts"`,
|
|
43
|
+
].filter(Boolean).join(' ');
|
|
44
|
+
const c = (0, resolvers_1.getBaseConfig)({ platform: constants_1.Platforms.WEBTV });
|
|
45
|
+
const { status, suitestConfigId } = await (0, smokeTestUtils_1.execTestbedCmd)(cmd);
|
|
46
|
+
if (status) {
|
|
47
|
+
(0, smokeTestUtils_1.sendSuccessToSlack)(c, suitestConfigId);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const zipFileName = (0, smokeTestUtils_1.generateLogsZipName)(c);
|
|
51
|
+
const zipFilePath = path.resolve(zipFileName);
|
|
52
|
+
(0, smokeTestUtils_1.zipLogFiles)(c, zipFilePath, logDir);
|
|
53
|
+
(0, smokeTestUtils_1.uploadLogsZipToS3)(c, zipFilePath);
|
|
54
|
+
const logsZipUrl = (0, smokeTestUtils_1.resolveLogsZipUrl)(c, zipFileName);
|
|
55
|
+
(0, smokeTestUtils_1.sendFailToSlack)(c, { logsZipUrl, suitestConfigId });
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const startTimestamp = Date.now();
|
|
60
|
+
smokeTest();
|
|
61
|
+
const msPerSecond = 1000;
|
|
62
|
+
const scriptTotalTimeInSeconds = Math.ceil((Date.now() - startTimestamp) / msPerSecond);
|
|
63
|
+
console.log(`smokeTest: done in ${scriptTotalTimeInSeconds} second(s)!`);
|
|
@@ -53,14 +53,6 @@ const makeRules = (config, projectDir, isDevServer) => ({
|
|
|
53
53
|
options: {
|
|
54
54
|
transpileOnly: true,
|
|
55
55
|
allowTsInNodeModules: true,
|
|
56
|
-
getCustomTransformers: () => ({
|
|
57
|
-
before: [
|
|
58
|
-
require('@svgr/babel-plugin-remove-jsx-attribute').default,
|
|
59
|
-
{
|
|
60
|
-
attributes: ['aria-label', 'aria-hidden']
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
}),
|
|
64
56
|
},
|
|
65
57
|
},
|
|
66
58
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24i/smartapps-bigscreen-rnv-build-engine",
|
|
3
|
-
"version": "0.17.12-alpha.
|
|
3
|
+
"version": "0.17.12-alpha.3",
|
|
4
4
|
"description": "Package with build engine for SmartApps BIGscreen projects...",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"xml2js": "^0.4.23"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@svgr/babel-plugin-remove-jsx-attribute": "^8.0.0",
|
|
43
42
|
"@types/fs-extra": "11.0.1",
|
|
44
43
|
"@types/inquirer": "8.2.1",
|
|
45
44
|
"@types/ip": "1.1.0",
|
|
File without changes
|