Skip to content

Commit

Permalink
Showing 7 changed files with 70 additions and 3 deletions.
4 changes: 4 additions & 0 deletions init/action.yml
@@ -19,6 +19,10 @@ inputs:
queries:
description: Comma-separated list of additional queries to run. By default, this overrides the same setting in a configuration file; prefix with "+" to use both sets of queries.
required: false
setup-python-dependencies:
description: Try to auto-install your python dependencies
required: true
default: 'true'
runs:
using: 'node12'
main: '../lib/init-action.js'
6 changes: 6 additions & 0 deletions lib/init-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/init-action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions lib/init.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/init.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/init-action.ts
@@ -2,7 +2,7 @@ import * as core from '@actions/core';

import { CodeQL } from './codeql';
import * as configUtils from './config-utils';
import { initCodeQL, initConfig, injectWindowsTracer, runInit } from './init';
import { initCodeQL, initConfig, injectWindowsTracer, installPythonDeps, runInit} from './init';
import { getActionsLogger } from './logging';
import { parseRepositoryNwo } from './repository';
import * as util from './util';
@@ -66,6 +66,13 @@ async function run() {
util.getRequiredEnvParam('RUNNER_TOOL_CACHE'),
'actions',
logger);

try {
await installPythonDeps(codeql, logger);
} catch (err) {
logger.warning(err.message + 'You can call this action with "setup-python-dependencies: false" to disable this process');
}

config = await initConfig(
core.getInput('languages'),
core.getInput('queries'),
26 changes: 26 additions & 0 deletions src/init.ts
@@ -167,3 +167,29 @@ export async function injectWindowsTracer(
],
{ env: { 'ODASA_TRACER_CONFIGURATION': tracerConfig.spec } }).exec();
}

export async function installPythonDeps(codeql: CodeQL, logger: Logger) {
logger.startGroup('Setup Python dependencies');

const scriptsFolder = path.resolve(__dirname, '../python-setup');

// Setup tools
try {
await new toolrunnner.ToolRunner(path.join(scriptsFolder, 'install_tools.sh')).exec();
} 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
logger.endGroup();
throw new Error('Unable to download and extract the scripts needed for installing the python dependecies');
}
// Install dependencies
try {
await new toolrunnner.ToolRunner(
path.join(scriptsFolder, 'auto_install_packages.py'),
[path.dirname(codeql.getPath())]).exec();
} catch (e) {
logger.endGroup();
throw new Error('We were unable to install your python dependencies.');
}
logger.endGroup();
}

0 comments on commit 8cea215

Please sign in to comment.