Skip to content
Merged
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
40 changes: 35 additions & 5 deletions app/client/cypress-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,51 @@ function getEnvNumber(
return value;
}

function getEnvValue(
varName: string,
{ required = false }: GetEnvOptions = {},
) {
if (required && process.env[varName] === undefined) {
throw Error(`${varName} is not set.`);
}
const value = process.env[varName] === undefined ? "" : process.env[varName];
return value;
}

function getArgs() {
return {
totalRunners: getEnvNumber("TOTAL_RUNNERS", { required: true }),
thisRunner: getEnvNumber("THIS_RUNNER", { required: true }),
specs: getEnvNumber("SPECS", { required: true }),
specs: getEnvValue("CYPRESS_SPECS", { required: true }),
env: getEnvValue("CYPRESS_ENV", { required: true }),
config_file: getEnvValue("CYPRESS_CONFIG_FILE", { required: true }),
headless: getEnvValue("CYPRESS_HEADLESS", { required: true }),
browser: getEnvValue("CYPRESS_BROWSER", { required: true }),
};
}

(async () => {
try {
const { thisRunner, totalRunners, specs } = getArgs();
const command = `yarn cypress run --spec "$(yarn --silent ts-node --quiet cypress-split.ts ${totalRunners} ${thisRunner} ${specs})"`;
console.log(`Running: ${command}`);
const {
browser,
config_file,
env,
headless,
specs,
thisRunner,
totalRunners,
} = getArgs();

let command = "yarn cypress run";
command += browser != "" ? `--browser ${browser}` : "";
command += config_file != "" ? `--config-file ${config_file}` : "";
command += env != "" ? `--env ${env}` : "";
command += headless != "true" ? `--headed` : "";

const final_command = `${command} --spec "$(yarn --silent ts-node --quiet cypress-split.ts ${totalRunners} ${thisRunner} ${specs})"`;
console.log(`Running: ${final_command}`);

const commandProcess = exec(command);
const commandProcess = exec(final_command);

// pipe output because we want to see the results of the run
if (commandProcess.stdout) {
Expand Down