itemengine-cypress-automation 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +4 -2
- package/scripts/sorry-cypress.mjs +64 -19
package/package.json
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "itemengine-cypress-automation",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.10",
|
4
4
|
"description": "",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
7
7
|
"build": "echo 'building'",
|
8
8
|
"test": "echo 'success'",
|
9
|
-
"spinnaker": "node scripts/spinnaker.mjs"
|
9
|
+
"spinnaker": "node scripts/spinnaker.mjs --env theme=ilc",
|
10
|
+
"spinnaker:untagged": "node scripts/spinnaker.mjs --env theme=ilc,grepUntagged=true",
|
11
|
+
"local": "node scripts/spinnaker.mjs"
|
10
12
|
},
|
11
13
|
"repository": {
|
12
14
|
"type": "git",
|
@@ -1,53 +1,98 @@
|
|
1
|
-
import {execSync} from "child_process";
|
1
|
+
import { execSync } from "child_process";
|
2
2
|
import * as OS from "os";
|
3
|
-
// import "dotenv/config";
|
4
3
|
|
5
4
|
let ciBuildId;
|
6
5
|
let startTime;
|
6
|
+
const envArgs = {};
|
7
|
+
|
8
|
+
if (process.argv.includes('--env')) {
|
9
|
+
const envArgsString = process.argv[process.argv.findIndex(elem => elem === '--env') + 1];
|
10
|
+
envArgsString.split(',').forEach(arg => {
|
11
|
+
const pair = arg.split('=')
|
12
|
+
const key = pair[0];
|
13
|
+
const value = pair[1];
|
14
|
+
envArgs[key] = value;
|
15
|
+
});
|
16
|
+
}
|
17
|
+
|
18
|
+
const env = process.env.STAGE ? process.env.STAGE : envArgs.fileConfig;
|
19
|
+
|
20
|
+
console.log(envArgs, env)
|
7
21
|
|
8
22
|
/**
|
9
23
|
* @param {string} user
|
10
24
|
* @param {string} startTime
|
11
25
|
*/
|
12
26
|
function setCiBuildId(user, startTime) {
|
13
|
-
console.log('process.env.fileConfig', process.env.fileConfig)
|
14
27
|
console.log('process.argv', process.argv)
|
15
|
-
let
|
16
|
-
|
17
|
-
|
28
|
+
let tags;
|
29
|
+
if (envArgs.grepUntagged) {
|
30
|
+
tags = 'untagged';
|
31
|
+
} else if (envArgs.grepTags) {
|
32
|
+
tags = envArgs.grepTags;
|
33
|
+
} else {
|
34
|
+
tags = '--'
|
35
|
+
}
|
36
|
+
return `${user}[E2E][env:${env}][tags:${tags}][${startTime}]`
|
37
|
+
}
|
38
|
+
|
39
|
+
function setCommandLineEnvArgs() {
|
40
|
+
let theme = envArgs.theme ? `theme=${envArgs.theme}` : '';
|
41
|
+
let tags;
|
42
|
+
let fileConfig;
|
43
|
+
|
44
|
+
if (env === 'dev') {
|
45
|
+
fileConfig = 'fileConfig=ildev'
|
46
|
+
} else if (env === 'stage') {
|
47
|
+
fileConfig = 'fileConfig=ilstage'
|
48
|
+
} else if (env === 'qa') {
|
49
|
+
fileConfig = 'fileConfig=ilqa'
|
50
|
+
} else if (env === 'prod') {
|
51
|
+
fileConfig = 'fileConfig=prod'
|
52
|
+
} else {
|
53
|
+
fileConfig = `fileConfig=${env}`
|
54
|
+
}
|
55
|
+
|
56
|
+
if (envArgs.grepUntagged) {
|
57
|
+
tags = `grepUntagged=${envArgs.grepUntagged}`;
|
58
|
+
} else if (envArgs.grepTags) {
|
59
|
+
tags = `grepTags=${envArgs.grepTags}`;
|
60
|
+
} else {
|
61
|
+
tags = ''
|
62
|
+
}
|
63
|
+
|
64
|
+
return `--env ${fileConfig}` + (theme ? `,${theme}`: '') + (tags ? `,${tags}`: '')
|
18
65
|
}
|
19
66
|
|
20
67
|
/**
|
21
68
|
* @method runSorryCypress
|
22
69
|
* @param {string} ciBuildId
|
23
70
|
*/
|
24
|
-
function runSorryCypress(ciBuildId) {
|
25
|
-
|
26
|
-
|
27
|
-
execSync(command, {stdio: "inherit"});
|
71
|
+
function runSorryCypress(ciBuildId, envArgs) {
|
72
|
+
let command = `cypress-cloud run --parallel --browser chrome --record --key ImagineLearning/itemengine-cypress-automation --ci-build-id ${ciBuildId} ${envArgs}`;
|
73
|
+
execSync(command, { stdio: "inherit" });
|
28
74
|
}
|
29
75
|
|
30
76
|
/**
|
31
77
|
* @method runSorryCypressSpinnaker
|
32
78
|
*/
|
33
79
|
export function runSorryCypressSpinnaker() {
|
34
|
-
//console.log('process.env.fileConfig', process.env.fileConfig)
|
35
80
|
console.log('process.argv', process.argv)
|
36
81
|
console.log('process.env.STAGE', process.env.STAGE)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
runSorryCypress(
|
82
|
+
startTime = process.env.START_TIME;
|
83
|
+
console.log('START_TIME', startTime)
|
84
|
+
ciBuildId = setCiBuildId("spinnaker", startTime);
|
85
|
+
const envArgs = setCommandLineEnvArgs()
|
86
|
+
runSorryCypress(ciBuildId, envArgs);
|
42
87
|
}
|
43
88
|
|
44
89
|
/**
|
45
90
|
* @method runSorryCypressLocal
|
46
91
|
*/
|
47
|
-
|
92
|
+
export function runSorryCypressLocal() {
|
48
93
|
process.env.CYPRESS_API_URL = "https://cypress-director.imaginelearning.engineering/";
|
49
94
|
const user = OS.userInfo().username;
|
50
|
-
startTime = Math.round(Date.now() /
|
95
|
+
startTime = Math.round(Date.now() / 100000);
|
51
96
|
ciBuildId = setCiBuildId(user, startTime);
|
52
|
-
runSorryCypress(ciBuildId);
|
97
|
+
runSorryCypress(ciBuildId, envArgs);
|
53
98
|
}
|