Skip to content

2.5.4 #174

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

Merged
merged 11 commits into from
Jul 24, 2022
Merged

2.5.4 #174

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
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