Skip to content

Commit dec412f

Browse files
authored
Merge pull request #174 from LambdaTest/dev
2.5.4
2 parents 541c4e5 + e8d50c7 commit dec412f

File tree

6 files changed

+58
-7
lines changed

6 files changed

+58
-7
lines changed

commands/utils/batch/batch_runner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ async function run(lt_config, batches, env, i = 0) {
182182
});
183183
})
184184
.catch(function (err) {
185-
console.log("No able to archive the project");
185+
console.log("Unable to archive the project");
186186
console.log(err);
187187
reject(err);
188188
});

commands/utils/constants.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
DEFAULT_TEST_PATH: ".",
1010
LAMBDA_CONFIG: "./lambdatest-config.json",
1111
SUPPORTED_CYPRESS_VERSIONS: ["5", "6"],
12+
WHITELISTED_ENV_VARS: ["CI_BUILD_ID"],
1213
BUILD_END_STATES:
1314
"&status=running,queued,created,initiated,pqueued,error,lambda error,failed",
1415
BUILD_ERROR_STATES: "&status=error,lambda error,failed",
@@ -35,15 +36,15 @@ module.exports = {
3536
"https://api.cypress-v3.dev.lambdatest.io/automation/api/v1/cypress/artefacts/test/",
3637
},
3738
stage: {
38-
INTEGRATION_BASE_URL: "https://stage-api.lambdatest.com/liis",
39+
INTEGRATION_BASE_URL: "https://stage-api.lambdatestinternal.com/liis",
3940
BUILD_BASE_URL:
40-
"https://stage-api.lambdatest.com/automation/api/v1/builds/",
41+
"https://stage-api.lambdatestinternal.com/automation/api/v1/builds/",
4142
BUILD_STOP_URL:
42-
"https://stage-api.lambdatest.com/api/v1/test/stop?sessionId=",
43+
"https://stage-api.lambdatestinternal.com/api/v1/test/stop?sessionId=",
4344
SESSION_URL:
44-
"https://stage-api.lambdatest.com/automation/api/v1/sessions?limit=200&session_id=",
45+
"https://stage-api.lambdatestinternal.com/automation/api/v1/sessions?limit=200&session_id=",
4546
REPORT_URL:
46-
"https://stage-api.lambdatest.com/automation/api/v1/cypress/artefacts/test/",
47+
"https://stage-api.lambdatestinternal.com/automation/api/v1/cypress/artefacts/test/",
4748
},
4849

4950
stage_new: {

commands/utils/set_args.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const constants = require("./constants.js");
22
const fs = require("fs");
33
const path = require("path");
44
const process = require("process");
5+
const { type } = require("os");
56

67
function write_file(file_path, content) {
78
fs.writeFileSync(file_path, content, function (err) {
@@ -322,6 +323,33 @@ function sync_args_from_cmd(args) {
322323
} else {
323324
lt_config["run_settings"]["reject_unauthorized"] = false;
324325
}
326+
327+
//Set the env variables
328+
let sys_env_vars = undefined;
329+
let envs = {};
330+
if ("sys-envs" in args) {
331+
sys_env_vars = args["sys-envs"];
332+
} else if (lt_config["run_settings"]["sys_envs"]) {
333+
sys_env_vars = lt_config["run_settings"]["sys_envs"];
334+
}
335+
336+
if (sys_env_vars){
337+
sys_env_vars = sys_env_vars.trim();
338+
sys_env_vars = sys_env_vars.split(";");
339+
340+
for (index in sys_env_vars) {
341+
envItem = sys_env_vars[index];
342+
if (envItem){
343+
envKeyValue = envItem.split("=");
344+
envKey = envKeyValue[0];
345+
envValue = envKeyValue[1];
346+
envs[envKey] = envValue;
347+
}
348+
}
349+
}
350+
lt_config["run_settings"]["sys_envs"] = envs;
351+
352+
325353
//get specs from current directory if specs are not passed in config or cli
326354
if (
327355
(lt_config["run_settings"]["specs"] == undefined ||

commands/utils/validate.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require("fs");
22
const constants = require("./constants.js");
33
module.exports = validate_config = function (lt_config, validation_configs) {
4+
console.log("validating config");
45
return new Promise(function (resolve, reject) {
56
//validate auth keys are present
67
if (
@@ -319,6 +320,22 @@ module.exports = validate_config = function (lt_config, validation_configs) {
319320
reject("Error!! boolean value is expected in reject_unauthorized key");
320321
}
321322
}
323+
324+
// validate system env variables to be set up
325+
if ("sys_envs" in lt_config["run_settings"]) {
326+
let sys_envs = lt_config["run_settings"]["sys_envs"];
327+
let envValue;
328+
Object.keys(sys_envs).forEach(function(envKey) {
329+
envValue = sys_envs[envKey];
330+
if (envKey && ! constants.WHITELISTED_ENV_VARS.includes(envKey)){
331+
reject(`Usage of unwanted environment variable detected. Allowed variables are - ${constants.WHITELISTED_ENV_VARS}`);
332+
}
333+
if (envValue == undefined || envValue === ""){
334+
reject("Value of environment variable cannot be left blank");
335+
}
336+
})
337+
338+
}
322339
resolve("Validated the Config");
323340
});
324341
};

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ const argv = require("yargs")
127127
alias: "build-tags",
128128
describe: "build tags",
129129
type: "string",
130+
})
131+
.option("sys-envs", {
132+
alias: "sys-env-variables",
133+
describe: "system environment variables",
134+
type: "string",
130135
});
131136
},
132137
function (argv) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lambdatest-cypress-cli",
3-
"version": "2.5.3",
3+
"version": "2.5.4",
44
"description": "The lambdatest-cypress-cli is LambdaTest's command-line interface (CLI) aimed to help you run your Cypress tests on LambdaTest platform.",
55
"homepage": "https://github.com/LambdaTest/lambdatest-cypress-cli",
66
"author": "LambdaTest <[email protected]>",

0 commit comments

Comments
 (0)