Skip to content

Commit

Permalink
Merge pull request #174 from LambdaTest/dev
Browse files Browse the repository at this point in the history
2.5.4
  • Loading branch information
asad9711 authored Jul 24, 2022
2 parents 541c4e5 + e8d50c7 commit dec412f
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 7 deletions.
2 changes: 1 addition & 1 deletion commands/utils/batch/batch_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ async function run(lt_config, batches, env, i = 0) {
});
})
.catch(function (err) {
console.log("No able to archive the project");
console.log("Unable to archive the project");
console.log(err);
reject(err);
});
Expand Down
11 changes: 6 additions & 5 deletions commands/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
DEFAULT_TEST_PATH: ".",
LAMBDA_CONFIG: "./lambdatest-config.json",
SUPPORTED_CYPRESS_VERSIONS: ["5", "6"],
WHITELISTED_ENV_VARS: ["CI_BUILD_ID"],
BUILD_END_STATES:
"&status=running,queued,created,initiated,pqueued,error,lambda error,failed",
BUILD_ERROR_STATES: "&status=error,lambda error,failed",
Expand All @@ -35,15 +36,15 @@ module.exports = {
"https://api.cypress-v3.dev.lambdatest.io/automation/api/v1/cypress/artefacts/test/",
},
stage: {
INTEGRATION_BASE_URL: "https://stage-api.lambdatest.com/liis",
INTEGRATION_BASE_URL: "https://stage-api.lambdatestinternal.com/liis",
BUILD_BASE_URL:
"https://stage-api.lambdatest.com/automation/api/v1/builds/",
"https://stage-api.lambdatestinternal.com/automation/api/v1/builds/",
BUILD_STOP_URL:
"https://stage-api.lambdatest.com/api/v1/test/stop?sessionId=",
"https://stage-api.lambdatestinternal.com/api/v1/test/stop?sessionId=",
SESSION_URL:
"https://stage-api.lambdatest.com/automation/api/v1/sessions?limit=200&session_id=",
"https://stage-api.lambdatestinternal.com/automation/api/v1/sessions?limit=200&session_id=",
REPORT_URL:
"https://stage-api.lambdatest.com/automation/api/v1/cypress/artefacts/test/",
"https://stage-api.lambdatestinternal.com/automation/api/v1/cypress/artefacts/test/",
},

stage_new: {
Expand Down
28 changes: 28 additions & 0 deletions commands/utils/set_args.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const constants = require("./constants.js");
const fs = require("fs");
const path = require("path");
const process = require("process");
const { type } = require("os");

function write_file(file_path, content) {
fs.writeFileSync(file_path, content, function (err) {
Expand Down Expand Up @@ -322,6 +323,33 @@ function sync_args_from_cmd(args) {
} else {
lt_config["run_settings"]["reject_unauthorized"] = false;
}

//Set the env variables
let sys_env_vars = undefined;
let envs = {};
if ("sys-envs" in args) {
sys_env_vars = args["sys-envs"];
} else if (lt_config["run_settings"]["sys_envs"]) {
sys_env_vars = lt_config["run_settings"]["sys_envs"];
}

if (sys_env_vars){
sys_env_vars = sys_env_vars.trim();
sys_env_vars = sys_env_vars.split(";");

for (index in sys_env_vars) {
envItem = sys_env_vars[index];
if (envItem){
envKeyValue = envItem.split("=");
envKey = envKeyValue[0];
envValue = envKeyValue[1];
envs[envKey] = envValue;
}
}
}
lt_config["run_settings"]["sys_envs"] = envs;


//get specs from current directory if specs are not passed in config or cli
if (
(lt_config["run_settings"]["specs"] == undefined ||
Expand Down
17 changes: 17 additions & 0 deletions commands/utils/validate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require("fs");
const constants = require("./constants.js");
module.exports = validate_config = function (lt_config, validation_configs) {
console.log("validating config");
return new Promise(function (resolve, reject) {
//validate auth keys are present
if (
Expand Down Expand Up @@ -319,6 +320,22 @@ module.exports = validate_config = function (lt_config, validation_configs) {
reject("Error!! boolean value is expected in reject_unauthorized key");
}
}

// validate system env variables to be set up
if ("sys_envs" in lt_config["run_settings"]) {
let sys_envs = lt_config["run_settings"]["sys_envs"];
let envValue;
Object.keys(sys_envs).forEach(function(envKey) {
envValue = sys_envs[envKey];
if (envKey && ! constants.WHITELISTED_ENV_VARS.includes(envKey)){
reject(`Usage of unwanted environment variable detected. Allowed variables are - ${constants.WHITELISTED_ENV_VARS}`);
}
if (envValue == undefined || envValue === ""){
reject("Value of environment variable cannot be left blank");
}
})

}
resolve("Validated the Config");
});
};
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ const argv = require("yargs")
alias: "build-tags",
describe: "build tags",
type: "string",
})
.option("sys-envs", {
alias: "sys-env-variables",
describe: "system environment variables",
type: "string",
});
},
function (argv) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lambdatest-cypress-cli",
"version": "2.5.3",
"version": "2.5.4",
"description": "The lambdatest-cypress-cli is LambdaTest's command-line interface (CLI) aimed to help you run your Cypress tests on LambdaTest platform.",
"homepage": "https://github.com/LambdaTest/lambdatest-cypress-cli",
"author": "LambdaTest <[email protected]>",
Expand Down

0 comments on commit dec412f

Please sign in to comment.