remove should_abort method
This commit is contained in:
parent
396f7167d8
commit
a0660c80bd
18 changed files with 14 additions and 77 deletions
|
|
@ -37,8 +37,7 @@ async function run() {
|
|||
let language;
|
||||
try {
|
||||
util.prepareLocalRunEnvironment();
|
||||
if (util.should_abort('autobuild', true) ||
|
||||
!await util.sendStatusReport(await util.createStatusReportBase('autobuild', 'starting', startedAt), true)) {
|
||||
if (!await util.sendStatusReport(await util.createStatusReportBase('autobuild', 'starting', startedAt), true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,8 +125,7 @@ async function run() {
|
|||
let uploadStats: upload_lib.UploadStatusReport | undefined = undefined;
|
||||
try {
|
||||
util.prepareLocalRunEnvironment();
|
||||
if (util.should_abort('finish', true) ||
|
||||
!await util.sendStatusReport(await util.createStatusReportBase('finish', 'starting', startedAt), true)) {
|
||||
if (!await util.sendStatusReport(await util.createStatusReportBase('finish', 'starting', startedAt), true)) {
|
||||
return;
|
||||
}
|
||||
const config = await configUtils.getConfig();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import * as path from 'path';
|
|||
import * as analysisPaths from './analysis-paths';
|
||||
import { CodeQL, isTracedLanguage, setupCodeQL } from './codeql';
|
||||
import * as configUtils from './config-utils';
|
||||
import * as sharedEnv from './shared-environment';
|
||||
import * as util from './util';
|
||||
|
||||
type TracerConfig = {
|
||||
|
|
@ -178,8 +177,7 @@ async function run() {
|
|||
|
||||
try {
|
||||
util.prepareLocalRunEnvironment();
|
||||
if (util.should_abort('init', false) ||
|
||||
!await util.sendStatusReport(await util.createStatusReportBase('init', 'starting', startedAt), true)) {
|
||||
if (!await util.sendStatusReport(await util.createStatusReportBase('init', 'starting', startedAt), true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -268,7 +266,6 @@ async function run() {
|
|||
return;
|
||||
}
|
||||
await sendSuccessStatusReport(startedAt, config);
|
||||
core.exportVariable(sharedEnv.CODEQL_ACTION_INIT_COMPLETED, 'true');
|
||||
}
|
||||
|
||||
run().catch(e => {
|
||||
|
|
|
|||
|
|
@ -5,5 +5,3 @@ export const ODASA_TRACER_CONFIGURATION = 'ODASA_TRACER_CONFIGURATION';
|
|||
// then this variable will be assigned the start time of the action invoked
|
||||
// rather that the init action.
|
||||
export const CODEQL_WORKFLOW_STARTED_AT = 'CODEQL_WORKFLOW_STARTED_AT';
|
||||
// Populated when the init action completes successfully
|
||||
export const CODEQL_ACTION_INIT_COMPLETED = 'CODEQL_ACTION_INIT_COMPLETED';
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ async function sendSuccessStatusReport(startedAt: Date, uploadStats: upload_lib.
|
|||
|
||||
async function run() {
|
||||
const startedAt = new Date();
|
||||
if (util.should_abort('upload-sarif', false) ||
|
||||
!await util.sendStatusReport(await util.createStatusReportBase('upload-sarif', 'starting', startedAt), true)) {
|
||||
if (!await util.sendStatusReport(await util.createStatusReportBase('upload-sarif', 'starting', startedAt), true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
25
src/util.ts
25
src/util.ts
|
|
@ -27,31 +27,6 @@ export function isEnterprise(): boolean {
|
|||
return getInstanceAPIURL() !== GITHUB_DOTCOM_API_URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the current action be aborted?
|
||||
*
|
||||
* This method should be called at the start of all CodeQL actions and they
|
||||
* should abort cleanly if this returns true without failing the action.
|
||||
* This method will call `core.setFailed` if necessary.
|
||||
*/
|
||||
export function should_abort(actionName: string, requireInitActionHasRun: boolean): boolean {
|
||||
|
||||
// Check that required aspects of the environment are present
|
||||
const ref = process.env['GITHUB_REF'];
|
||||
if (ref === undefined) {
|
||||
core.setFailed('GITHUB_REF must be set.');
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the init action is required, then check the it completed successfully.
|
||||
if (requireInitActionHasRun && process.env[sharedEnv.CODEQL_ACTION_INIT_COMPLETED] === undefined) {
|
||||
core.setFailed('The CodeQL ' + actionName + ' action cannot be used unless the CodeQL init action is run first. Aborting.');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an environment parameter, but throw an error if it is not set.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue