Add autoinstaller for python deps

This commit is contained in:
David Verdeguer
2020-07-23 12:45:21 +02:00
parent 9769e4a6df
commit 1c95faf847
4 changed files with 72 additions and 1 deletions
+32
View File
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec"));
const io = __importStar(require("@actions/io"));
const toolcache = __importStar(require("@actions/tool-cache"));
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const analysisPaths = __importStar(require("./analysis-paths"));
@@ -121,6 +122,33 @@ function concatTracerConfigs(configs) {
fs.writeFileSync(envPath, buffer);
return { env, spec };
}
async function installPythonDeps(codeql) {
core.startGroup('Setup Python dependencies');
let scriptsFolder = '';
try {
const repoPath = await toolcache.downloadTool('https://github.com/github/codeql-python-autobuild-playground/archive/master.zip');
const extracted = await toolcache.extractZip(repoPath);
scriptsFolder = path.join(extracted, 'codeql-python-autobuild-playground-master');
}
catch (e) {
// The download should not fail, but in case it fails we just abort trying to setup the python deps
core.warning('Unable to download and extract the scripts needed for installing the python dependecies');
return;
}
// Setup tools
try {
await exec.exec(path.join(scriptsFolder, 'install_tools.sh'));
}
catch (e) {
// This script tries to install some needed tools in the runner. It should not fail, but if it does
// we just abort the process without failing the action
core.warning('Unable to download and extract the scripts needed for installing the python dependecies');
return;
}
// Install dependencies
await exec.exec(path.join(scriptsFolder, 'auto_install_packages.py'), [codeql.getDir()]);
core.endGroup();
}
async function run() {
let config;
let codeql;
@@ -150,6 +178,10 @@ async function run() {
core.exportVariable('GOFLAGS', goFlags);
core.warning("Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action.");
}
const setupPythonDependencies = core.getInput('setup-python-dependencies', { required: true });
if (config.languages.includes('python') && setupPythonDependencies === 'true') {
await installPythonDeps(codeql);
}
// Setup CODEQL_RAM flag (todo improve this https://github.com/github/dsp-code-scanning/issues/935)
const codeqlRam = process.env['CODEQL_RAM'] || '6500';
core.exportVariable('CODEQL_RAM', codeqlRam);
File diff suppressed because one or more lines are too long