mirror of
https://github.com/github/codeql-action.git
synced 2026-05-08 06:40:19 +00:00
Add autoinstaller for python deps
This commit is contained in:
Generated
+32
@@ -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
Reference in New Issue
Block a user