check environment before running autobuild or analyze
This commit is contained in:
parent
a542021200
commit
f80d660e33
3 changed files with 22 additions and 3 deletions
9
lib/runner.js
generated
9
lib/runner.js
generated
|
|
@ -60,6 +60,13 @@ function getToolsDir(userInput) {
|
|||
}
|
||||
return toolsDir;
|
||||
}
|
||||
function checkEnvironmentSetup(config) {
|
||||
if (config.languages.some(languages_1.isTracedLanguage) && !('ODASA_TRACER_CONFIGURATION' in process.env)) {
|
||||
throw new Error("Could not detect 'ODASA_TRACER_CONFIGURATION' in environment. " +
|
||||
"Make sure that environment variables were correctly exported to future processes. " +
|
||||
"See end out output from 'init' command for instructions.");
|
||||
}
|
||||
}
|
||||
const logger = logging_1.getRunnerLogger();
|
||||
program
|
||||
.command('init')
|
||||
|
|
@ -135,6 +142,7 @@ program
|
|||
.action(async (cmd) => {
|
||||
try {
|
||||
const config = await config_utils_1.getConfig(getTempDir(cmd.tempDir), logger);
|
||||
checkEnvironmentSetup(config);
|
||||
let language = undefined;
|
||||
if (cmd.language !== undefined) {
|
||||
language = languages_1.parseLanguage(cmd.language);
|
||||
|
|
@ -173,6 +181,7 @@ program
|
|||
const tempDir = getTempDir(cmd.tempDir);
|
||||
const outputDir = cmd.outputDir || path.join(tempDir, 'codeql-sarif');
|
||||
const config = await config_utils_1.getConfig(getTempDir(cmd.tempDir), logger);
|
||||
checkEnvironmentSetup(config);
|
||||
await analyze_1.runAnalyze(repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, cmd.ref, undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, cmd.githubAuth, parseGithubUrl(cmd.githubUrl), cmd.upload, 'runner', outputDir, config, logger);
|
||||
}
|
||||
catch (e) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -7,9 +7,9 @@ import * as path from 'path';
|
|||
import { runAnalyze } from './analyze';
|
||||
import { determineAutobuildLanguage, runAutobuild } from './autobuild';
|
||||
import { CodeQL, getCodeQL } from './codeql';
|
||||
import { getConfig} from './config-utils';
|
||||
import { Config, getConfig } from './config-utils';
|
||||
import { initCodeQL, initConfig, runInit } from './init';
|
||||
import { Language, parseLanguage } from './languages';
|
||||
import { isTracedLanguage, Language, parseLanguage } from './languages';
|
||||
import { getRunnerLogger } from './logging';
|
||||
import { parseRepositoryNwo } from './repository';
|
||||
import * as upload_lib from './upload-lib';
|
||||
|
|
@ -57,6 +57,14 @@ function getToolsDir(userInput: string | undefined): string {
|
|||
return toolsDir;
|
||||
}
|
||||
|
||||
function checkEnvironmentSetup(config: Config) {
|
||||
if (config.languages.some(isTracedLanguage) && !('ODASA_TRACER_CONFIGURATION' in process.env)) {
|
||||
throw new Error("Could not detect 'ODASA_TRACER_CONFIGURATION' in environment. " +
|
||||
"Make sure that environment variables were correctly exported to future processes. " +
|
||||
"See end out output from 'init' command for instructions.");
|
||||
}
|
||||
}
|
||||
|
||||
const logger = getRunnerLogger();
|
||||
|
||||
interface InitArgs {
|
||||
|
|
@ -176,6 +184,7 @@ program
|
|||
.action(async (cmd: AutobuildArgs) => {
|
||||
try {
|
||||
const config = await getConfig(getTempDir(cmd.tempDir), logger);
|
||||
checkEnvironmentSetup(config);
|
||||
let language: Language | undefined = undefined;
|
||||
if (cmd.language !== undefined) {
|
||||
language = parseLanguage(cmd.language);
|
||||
|
|
@ -225,6 +234,7 @@ program
|
|||
const tempDir = getTempDir(cmd.tempDir);
|
||||
const outputDir = cmd.outputDir || path.join(tempDir, 'codeql-sarif');
|
||||
const config = await getConfig(getTempDir(cmd.tempDir), logger);
|
||||
checkEnvironmentSetup(config);
|
||||
await runAnalyze(
|
||||
parseRepositoryNwo(cmd.repository),
|
||||
cmd.commit,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue