Merge pull request #81 from github/report-action-aborted
Report that an action has been aborted on configuration failures
This commit is contained in:
commit
6846c702da
6 changed files with 50 additions and 17 deletions
18
lib/setup-tracer.js
generated
18
lib/setup-tracer.js
generated
|
|
@ -127,22 +127,28 @@ function concatTracerConfigs(configs) {
|
||||||
return { env, spec };
|
return { env, spec };
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
|
let languages;
|
||||||
try {
|
try {
|
||||||
if (util.should_abort('init', false) || !await util.reportActionStarting('init')) {
|
if (util.should_abort('init', false) || !await util.reportActionStarting('init')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// The config file MUST be parsed in the init action
|
|
||||||
const config = await configUtils.loadConfig();
|
|
||||||
core.startGroup('Load language configuration');
|
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
|
// If the languages parameter was not given and no languages were
|
||||||
// detected then fail here as this is a workflow configuration error.
|
// detected then fail here as this is a workflow configuration error.
|
||||||
if (languages.length === 0) {
|
if (languages.length === 0) {
|
||||||
core.setFailed("Did not detect any languages to analyze. Please update input in workflow.");
|
throw new Error("Did not detect any languages to analyze. Please update input in workflow.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
core.endGroup();
|
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config, languages);
|
analysisPaths.includeAndExcludeAnalysisPaths(config, languages);
|
||||||
|
core.endGroup();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
core.setFailed(e.message);
|
||||||
|
await util.reportActionAborted('init', e.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
const sourceRoot = path.resolve();
|
const sourceRoot = path.resolve();
|
||||||
core.startGroup('Setup CodeQL tools');
|
core.startGroup('Setup CodeQL tools');
|
||||||
const codeqlSetup = await setuptools.setupCodeQL();
|
const codeqlSetup = await setuptools.setupCodeQL();
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
10
lib/util.js
generated
10
lib/util.js
generated
|
|
@ -327,6 +327,16 @@ async function reportActionSucceeded(action) {
|
||||||
await sendStatusReport(await createStatusReport(action, 'success'));
|
await sendStatusReport(await createStatusReport(action, 'success'));
|
||||||
}
|
}
|
||||||
exports.reportActionSucceeded = reportActionSucceeded;
|
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, 'aborted', cause));
|
||||||
|
}
|
||||||
|
exports.reportActionAborted = reportActionAborted;
|
||||||
/**
|
/**
|
||||||
* Get the array of all the tool names contained in the given sarif contents.
|
* 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
|
|
@ -139,30 +139,37 @@ function concatTracerConfigs(configs: { [lang: string]: TracerConfig }): TracerC
|
||||||
return { env, spec };
|
return { env, spec };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
|
|
||||||
|
let languages: string[];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (util.should_abort('init', false) || !await util.reportActionStarting('init')) {
|
if (util.should_abort('init', false) || !await util.reportActionStarting('init')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The config file MUST be parsed in the init action
|
|
||||||
const config = await configUtils.loadConfig();
|
|
||||||
|
|
||||||
core.startGroup('Load language configuration');
|
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
|
// If the languages parameter was not given and no languages were
|
||||||
// detected then fail here as this is a workflow configuration error.
|
// detected then fail here as this is a workflow configuration error.
|
||||||
if (languages.length === 0) {
|
if (languages.length === 0) {
|
||||||
core.setFailed("Did not detect any languages to analyze. Please update input in workflow.");
|
throw new Error("Did not detect any languages to analyze. Please update input in workflow.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
analysisPaths.includeAndExcludeAnalysisPaths(config, languages);
|
||||||
|
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
|
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config, languages);
|
} catch (e) {
|
||||||
|
core.setFailed(e.message);
|
||||||
|
await util.reportActionAborted('init', e.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
const sourceRoot = path.resolve();
|
const sourceRoot = path.resolve();
|
||||||
|
|
||||||
|
|
|
||||||
10
src/util.ts
10
src/util.ts
|
|
@ -365,6 +365,16 @@ export async function reportActionSucceeded(action: string) {
|
||||||
await sendStatusReport(await createStatusReport(action, 'success'));
|
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, 'aborted', cause));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the array of all the tool names contained in the given sarif contents.
|
* Get the array of all the tool names contained in the given sarif contents.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue