All files / src buildExec.ts

97.44% Statements 114/117
95.89% Branches 70/73
100% Functions 4/4
97.37% Lines 111/114

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 1861x 1x       1x   1x 4x 4x                 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x   2x 2x                 2x 2x                 2x 3x 3x 3x 2x 2x       2x 1x   2x 1x   2x 1x   2x 1x   2x 1x   2x 1x   2x 1x   2x 1x   2x 1x 2x     2x 1x 9x     2x 1x   2x     2x 1x   2x 1x   2x 1x   2x 1x   2x 1x   2x 1x   2x 1x   2x 1x 1x           2x 1x 1x         2x 1x   2x 1x   2x 1x   2x 1x   2x 1x   2x 1x   2x 1x   2x 1x     2x     1x  
const core = require('@actions/core');
const github = require('@actions/github');
 
// const {version} = require('../package.json');
 
const context = github.context;
 
const isTrue = (variable) => {
  const lowercase = variable.toLowerCase();
  return (
    lowercase === '1' ||
    lowercase === 't' ||
    lowercase === 'true' ||
    lowercase === 'y' ||
    lowercase === 'yes'
  );
};
 
const buildExec = () => {
  const clean = core.getInput('move_coverage_to_trash');
  const commitParent = core.getInput('commit_parent');
  const curlAwsArgs = core.getInput('aws_curl_args');
  const curlCodecovArgs = core.getInput('codecov_curl_args');
  const envVars = core.getInput('env_vars');
  const failCi = isTrue(core.getInput('fail_ci_if_error'));
  const file = core.getInput('file');
  const files = core.getInput('files');
  const flags = core.getInput('flags');
  const functionalities = core.getInput('functionalities');
  const gcovArgs = core.getInput('gcov_args');
  const gcovDir = core.getInput('gcov_root_dir');
  const gcovExclude = core.getInput('gcov_path_exclude');
  const gcovExec = core.getInput('gcov_executable');
  const gcovInclude = core.getInput('gcov_path_include');
  const gcovPrefix = core.getInput('gcov_prefix');
  const name = core.getInput('name');
  const networkFilter = core.getInput('network_filter');
  const overrideBranch = core.getInput('override_branch');
  const overrideBuild = core.getInput('override_build');
  const overrideCommit = core.getInput('override_commit');
  const overridePr = core.getInput('override_pr');
  const overrideTag = core.getInput('override_tag');
  const rootDir = core.getInput('root_dir');
  const searchDir = core.getInput('directory');
  const token = core.getInput('token');
  const verbose = isTrue(core.getInput('verbose'));
  const workingDir = core.getInput('working-directory');
  const writePath = core.getInput('path_to_write_report');
  const xcodeDerivedData = core.getInput('xcode_derived_data');
  const xcodePackage = core.getInput('xcode_package');
 
  const execArgs = [];
  execArgs.push(
      '-n',
      `${name}`,
      '-F',
      `${flags}`,
      // '-Q',
      // `github-action-${version}`,
  );
 
  const options:any = {};
  options.env = Object.assign(process.env, {
    GITHUB_ACTION: process.env.GITHUB_ACTION,
    GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
    GITHUB_REF: process.env.GITHUB_REF,
    GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
    GITHUB_SHA: process.env.GITHUB_SHA,
    GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '',
  });
 
  const envVarsArg = [];
  for (const envVar of envVars.split(',')) {
    const envVarClean = envVar.trim();
    if (envVarClean) {
      options.env[envVarClean] = process.env[envVarClean];
      envVarsArg.push(envVarClean);
    }
  }
 
  if (token) {
    options.env.CODECOV_TOKEN = token;
  }
  if (clean) {
    execArgs.push('-c');
  }
  if (commitParent) {
    execArgs.push('-N', `${commitParent}`);
  }
  if (curlAwsArgs) {
    execArgs.push('-A', `${curlAwsArgs}`);
  }
  if (curlCodecovArgs) {
    execArgs.push('-U', `${curlCodecovArgs}`);
  }
  if (envVarsArg.length) {
    execArgs.push('-e', envVarsArg.join(','));
  }
  if (failCi) {
    execArgs.push('-Z');
  }
  if (file) {
    execArgs.push('-f', `${file}`);
  }
  if (files) {
    files.split(',').forEach((f) => {
      execArgs.push('-f', `${f}`);
    });
  }
  if (functionalities) {
    functionalities.split(',').forEach((f) => {
      execArgs.push('-X', `${f}`);
    });
  }
  if (gcovArgs) {
    execArgs.push('-a', `${gcovArgs}`);
  }
  Iif (gcovDir) {
    execArgs.push('-p', `${gcovDir}`);
  }
  if (gcovExclude) {
    execArgs.push('-g', `${gcovExclude}`);
  }
  if (gcovExec) {
    execArgs.push('-x', `${gcovExec}`);
  }
  if (gcovInclude) {
    execArgs.push('-G', `${gcovInclude}`);
  }
  if (gcovPrefix) {
    execArgs.push('-k', `${gcovPrefix}`);
  }
  if (networkFilter) {
    execArgs.push('-i', `${networkFilter}`);
  }
  if (overrideBranch) {
    execArgs.push('-B', `${overrideBranch}`);
  }
  if (overrideBuild) {
    execArgs.push('-b', `${overrideBuild}`);
  }
  if (overrideCommit) {
    execArgs.push('-C', `${overrideCommit}`);
  } else Iif (
    `${context.eventName}` == 'pull_request' ||
    `${context.eventName}` == 'pull_request_target'
  ) {
    execArgs.push('-C', `${context.payload.pull_request.head.sha}`);
  }
  if (overridePr) {
    execArgs.push('-P', `${overridePr}`);
  } else Iif (
    `${context.eventName}` == 'pull_request_target'
  ) {
    execArgs.push('-P', `${context.payload.number}`);
  }
  if (overrideTag) {
    execArgs.push('-T', `${overrideTag}`);
  }
  if (rootDir) {
    execArgs.push('-R', `${rootDir}`);
  }
  if (searchDir) {
    execArgs.push('-s', `${searchDir}`);
  }
  if (verbose) {
    execArgs.push('-v');
  }
  if (workingDir) {
    options.cwd = workingDir;
  }
  if (writePath) {
    execArgs.push('-q', `${writePath}`);
  }
  if (xcodeDerivedData) {
    execArgs.push('-D', `${xcodeDerivedData}`);
  }
  if (xcodePackage) {
    execArgs.push('-J', `${xcodePackage}`);
  }
 
  return {execArgs, options, failCi};
};
 
export default buildExec;