Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #81 from github/report-action-aborted
Report that an action has been aborted on configuration failures
Alex Kalyvitis authored and GitHub committed Jun 24, 2020

Unverified

No user is associated with the committer email.
2 parents 5bb9e6e + 559e260 commit 6846c70
Showing 6 changed files with 49 additions and 16 deletions.
18 changes: 12 additions & 6 deletions lib/setup-tracer.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/setup-tracer.js.map

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

10 changes: 10 additions & 0 deletions lib/util.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/util.js.map

Large diffs are not rendered by default.

23 changes: 15 additions & 8 deletions src/setup-tracer.ts
@@ -139,30 +139,37 @@ function concatTracerConfigs(configs: { [lang: string]: TracerConfig }): TracerC
return { env, spec };
}

async function run() {

let languages: string[];

async function run() {
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;
throw new Error("Did not detect any languages to analyze. Please update input in workflow.");
}

analysisPaths.includeAndExcludeAnalysisPaths(config, languages);

core.endGroup();

analysisPaths.includeAndExcludeAnalysisPaths(config, languages);
} catch (e) {
core.setFailed(e.message);
await util.reportActionAborted('init', e.message);
return;
}

try {

const sourceRoot = path.resolve();

10 changes: 10 additions & 0 deletions src/util.ts
@@ -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, 'aborted', cause));
}

/**
* Get the array of all the tool names contained in the given sarif contents.
*

0 comments on commit 6846c70

Please sign in to comment.