report action has aborted

This commit is contained in:
Alex Kalyvitis 2020-06-23 18:36:08 +02:00
parent 98f8945cfb
commit af252d2f0d
6 changed files with 50 additions and 15 deletions

15
lib/setup-tracer.js generated
View file

@ -127,22 +127,29 @@ function concatTracerConfigs(configs) {
return { env, spec };
}
async function run() {
let languages;
try {
if (util.should_abort('init', false) || !await util.reportActionStarting('init')) {
return;
}
// The config file MUST be parsed in the init action
const config = await configUtils.loadConfig();
core.startGroup('Load language configuration');
const languages = await util.getLanguages();
const config = await configUtils.loadConfig();
languages = await util.getLanguages();
// If the languages parameter was not given and no languages were
// detected then fail here as this is a workflow configuration error.
if (languages.length === 0) {
core.setFailed("Did not detect any languages to analyze. Please update input in workflow.");
return;
}
core.endGroup();
analysisPaths.includeAndExcludeAnalysisPaths(config, languages);
core.endGroup();
}
catch (e) {
core.setFailed(e.message);
await util.reportActionAborted('init', e.message);
return;
}
try {
const sourceRoot = path.resolve();
core.startGroup('Setup CodeQL tools');
const codeqlSetup = await setuptools.setupCodeQL();

File diff suppressed because one or more lines are too long

10
lib/util.js generated
View file

@ -327,6 +327,16 @@ async function reportActionSucceeded(action) {
await sendStatusReport(await createStatusReport(action, 'success'));
}
exports.reportActionSucceeded = reportActionSucceeded;
/**
* Report that an action has been aborted.
*
* Note that the started_at date is always that of the `init` action, since
* this is likely to give a more useful duration when inspecting events.
*/
async function reportActionAborted(action, cause) {
await sendStatusReport(await createStatusReport(action, 'abort', cause));
}
exports.reportActionAborted = reportActionAborted;
/**
* Get the array of all the tool names contained in the given sarif contents.
*

File diff suppressed because one or more lines are too long

View file

@ -139,20 +139,20 @@ function concatTracerConfigs(configs: { [lang: string]: TracerConfig }): TracerC
return { env, spec };
}
async function run() {
let languages: string[];
try {
if (util.should_abort('init', false) || !await util.reportActionStarting('init')) {
return;
}
// The config file MUST be parsed in the init action
const config = await configUtils.loadConfig();
core.startGroup('Load language configuration');
const languages = await util.getLanguages();
const config = await configUtils.loadConfig();
languages = await util.getLanguages();
// If the languages parameter was not given and no languages were
// detected then fail here as this is a workflow configuration error.
if (languages.length === 0) {
@ -160,10 +160,18 @@ async function run() {
return;
}
core.endGroup();
analysisPaths.includeAndExcludeAnalysisPaths(config, languages);
core.endGroup();
} catch (e) {
core.setFailed(e.message);
await util.reportActionAborted('init', e.message, );
return;
}
try {
const sourceRoot = path.resolve();
core.startGroup('Setup CodeQL tools');

View file

@ -365,6 +365,16 @@ export async function reportActionSucceeded(action: string) {
await sendStatusReport(await createStatusReport(action, 'success'));
}
/**
* Report that an action has been aborted.
*
* Note that the started_at date is always that of the `init` action, since
* this is likely to give a more useful duration when inspecting events.
*/
export async function reportActionAborted(action: string, cause?: string) {
await sendStatusReport(await createStatusReport(action, 'abort', cause));
}
/**
* Get the array of all the tool names contained in the given sarif contents.
*