Merge pull request #1432 from github/henrymercer/init-post-telemetry
Add telemetry for uploading failed runs
This commit is contained in:
commit
899bf9c076
14 changed files with 297 additions and 92 deletions
File diff suppressed because one or more lines are too long
41
lib/init-action-post-helper.js
generated
41
lib/init-action-post-helper.js
generated
|
|
@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.run = exports.uploadFailedSarif = void 0;
|
||||
exports.run = exports.uploadSarifIfRunFailed = exports.uploadFailedSarif = void 0;
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const codeql_1 = require("./codeql");
|
||||
|
|
@ -29,15 +29,22 @@ const shared_environment_1 = require("./shared-environment");
|
|||
const uploadLib = __importStar(require("./upload-lib"));
|
||||
const util_1 = require("./util");
|
||||
const workflow_1 = require("./workflow");
|
||||
function createFailedUploadFailedSarifResult(error) {
|
||||
return {
|
||||
upload_failed_run_error: error instanceof Error ? error.message : String(error),
|
||||
upload_failed_run_stack_trace: error instanceof Error ? error.stack : undefined,
|
||||
};
|
||||
}
|
||||
async function uploadFailedSarif(config, repositoryNwo, featureEnablement, logger) {
|
||||
var _a;
|
||||
if (!config.codeQLCmd) {
|
||||
logger.warning("CodeQL command not found. Unable to upload failed SARIF file.");
|
||||
return;
|
||||
return { upload_failed_run_skipped_because: "CodeQL command not found" };
|
||||
}
|
||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||
if (!(await featureEnablement.getValue(feature_flags_1.Feature.UploadFailedSarifEnabled, codeql))) {
|
||||
logger.debug("Uploading failed SARIF is disabled.");
|
||||
return;
|
||||
return { upload_failed_run_skipped_because: "Feature disabled" };
|
||||
}
|
||||
const workflow = await (0, workflow_1.getWorkflow)();
|
||||
const jobName = (0, util_1.getRequiredEnvParam)("GITHUB_JOB");
|
||||
|
|
@ -45,7 +52,7 @@ async function uploadFailedSarif(config, repositoryNwo, featureEnablement, logge
|
|||
if ((0, workflow_1.getUploadInputOrThrow)(workflow, jobName, matrix) !== "true" ||
|
||||
(0, util_1.isInTestMode)()) {
|
||||
logger.debug("Won't upload a failed SARIF file since SARIF upload is disabled.");
|
||||
return;
|
||||
return { upload_failed_run_skipped_because: "SARIF upload is disabled" };
|
||||
}
|
||||
const category = (0, workflow_1.getCategoryInputOrThrow)(workflow, jobName, matrix);
|
||||
const checkoutPath = (0, workflow_1.getCheckoutPathInputOrThrow)(workflow, jobName, matrix);
|
||||
|
|
@ -54,19 +61,15 @@ async function uploadFailedSarif(config, repositoryNwo, featureEnablement, logge
|
|||
core.info(`Uploading failed SARIF file ${sarifFile}`);
|
||||
const uploadResult = await uploadLib.uploadFromActions(sarifFile, checkoutPath, category, logger);
|
||||
await uploadLib.waitForProcessing(repositoryNwo, uploadResult.sarifID, logger, { isUnsuccessfulExecution: true });
|
||||
return (_a = uploadResult === null || uploadResult === void 0 ? void 0 : uploadResult.statusReport) !== null && _a !== void 0 ? _a : {};
|
||||
}
|
||||
exports.uploadFailedSarif = uploadFailedSarif;
|
||||
async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, printDebugLogs, repositoryNwo, featureEnablement, logger) {
|
||||
const config = await (0, config_utils_1.getConfig)(actionsUtil.getTemporaryDirectory(), logger);
|
||||
if (config === undefined) {
|
||||
logger.warning("Debugging artifacts are unavailable since the 'init' Action failed before it could produce any.");
|
||||
return;
|
||||
}
|
||||
async function uploadSarifIfRunFailed(config, repositoryNwo, featureEnablement, logger) {
|
||||
// Environment variable used to integration test uploading a SARIF file for failed runs
|
||||
const expectFailedSarifUpload = process.env["CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF"] === "true";
|
||||
if (process.env[shared_environment_1.CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF] !== "true") {
|
||||
try {
|
||||
await uploadFailedSarif(config, repositoryNwo, featureEnablement, logger);
|
||||
return await uploadFailedSarif(config, repositoryNwo, featureEnablement, logger);
|
||||
}
|
||||
catch (e) {
|
||||
if (expectFailedSarifUpload) {
|
||||
|
|
@ -74,11 +77,26 @@ async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, p
|
|||
`the following error: ${e}`);
|
||||
}
|
||||
logger.info(`Failed to upload a SARIF file for the failed run. Error: ${e}`);
|
||||
return createFailedUploadFailedSarifResult(e);
|
||||
}
|
||||
}
|
||||
else if (expectFailedSarifUpload) {
|
||||
throw new Error("Expected to upload a SARIF file for the failed run, but didn't.");
|
||||
}
|
||||
else {
|
||||
return {
|
||||
upload_failed_run_skipped_because: "SARIF file already uploaded",
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.uploadSarifIfRunFailed = uploadSarifIfRunFailed;
|
||||
async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, printDebugLogs, repositoryNwo, featureEnablement, logger) {
|
||||
const config = await (0, config_utils_1.getConfig)(actionsUtil.getTemporaryDirectory(), logger);
|
||||
if (config === undefined) {
|
||||
logger.warning("Debugging artifacts are unavailable since the 'init' Action failed before it could produce any.");
|
||||
return;
|
||||
}
|
||||
const uploadFailedSarifResult = await uploadSarifIfRunFailed(config, repositoryNwo, featureEnablement, logger);
|
||||
// Upload appropriate Actions artifacts for debugging
|
||||
if (config.debugMode) {
|
||||
core.info("Debug mode is on. Uploading available database bundles and logs as Actions debugging artifacts...");
|
||||
|
|
@ -86,6 +104,7 @@ async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, p
|
|||
await uploadLogsDebugArtifact(config);
|
||||
await printDebugLogs(config);
|
||||
}
|
||||
return uploadFailedSarifResult;
|
||||
}
|
||||
exports.run = run;
|
||||
//# sourceMappingURL=init-action-post-helper.js.map
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"init-action-post-helper.js","sourceRoot":"","sources":["../src/init-action-post-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4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AE;QACpB,IAAI,CAAC,IAAI,CACP,mGAAmG,CACpG,CAAC;QACF,MAAM,iCAAiC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxD,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEtC,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;KAC9B;AACH,CAAC;AAlDD,kBAkDC"}
|
||||
{"version":3,"file":"init-action-post-helper.js","sourceRoot":"","sources":["../src/init-action-post-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,qCAAqC;AACrC,iDAAmD;AACnD,mDAA6D;AAG7D,6DAA8E;AAC9E,wDAA0C;AAC1C,iCAA6E;AAC7E,yCAKoB;AAWpB,SAAS,mCAAmC,CAC1C,KAAc;IAEd,OAAO;QACL,uBAAuB,EACrB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACxD,6BAA6B,EAC3B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;KACnD,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,aAA4B,EAC5B,iBAAoC,EACpC,MAAc;;IAEd,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;QACrB,MAAM,CAAC,OAAO,CACZ,+DAA+D,CAChE,CAAC;QACF,OAAO,EAAE,iCAAiC,EAAE,0BAA0B,EAAE,CAAC;KAC1E;IACD,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjD,IACE,CAAC,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAChC,uBAAO,CAAC,wBAAwB,EAChC,MAAM,CACP,CAAC,EACF;QACA,MAAM,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACpD,O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F,MAAM,iCAAiC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxD,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEtC,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;KAC9B;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAnCD,kBAmCC"}
|
||||
53
lib/init-action-post-helper.test.js
generated
53
lib/init-action-post-helper.test.js
generated
|
|
@ -103,6 +103,38 @@ const workflow = __importStar(require("./workflow"));
|
|||
]);
|
||||
await testFailedSarifUpload(t, actionsWorkflow, { category: "my-category" });
|
||||
});
|
||||
(0, ava_1.default)("doesn't upload failed SARIF for workflow with upload: false", async (t) => {
|
||||
const actionsWorkflow = createTestWorkflow([
|
||||
{
|
||||
name: "Checkout repository",
|
||||
uses: "actions/checkout@v3",
|
||||
},
|
||||
{
|
||||
name: "Initialize CodeQL",
|
||||
uses: "github/codeql-action/init@v2",
|
||||
with: {
|
||||
languages: "javascript",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Perform CodeQL Analysis",
|
||||
uses: "github/codeql-action/analyze@v2",
|
||||
with: {
|
||||
category: "my-category",
|
||||
upload: false,
|
||||
},
|
||||
},
|
||||
]);
|
||||
await testFailedSarifUpload(t, actionsWorkflow, {
|
||||
expectedLogs: [
|
||||
{
|
||||
message: "Won't upload a failed SARIF file since SARIF upload is disabled.",
|
||||
type: "debug",
|
||||
},
|
||||
],
|
||||
expectUpload: false,
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("uploading failed SARIF run fails when workflow does not reference github/codeql-action", async (t) => {
|
||||
const actionsWorkflow = createTestWorkflow([
|
||||
{
|
||||
|
|
@ -132,7 +164,7 @@ function createTestWorkflow(steps) {
|
|||
},
|
||||
};
|
||||
}
|
||||
async function testFailedSarifUpload(t, actionsWorkflow, { category } = {}) {
|
||||
async function testFailedSarifUpload(t, actionsWorkflow, { category, expectedLogs = [], expectUpload = true, } = {}) {
|
||||
const config = {
|
||||
codeQLCmd: "codeql",
|
||||
debugMode: true,
|
||||
|
|
@ -153,11 +185,18 @@ async function testFailedSarifUpload(t, actionsWorkflow, { category } = {}) {
|
|||
uploadFromActions.resolves({ sarifID: "42" });
|
||||
const waitForProcessing = sinon.stub(uploadLib, "waitForProcessing");
|
||||
await initActionPostHelper.uploadFailedSarif(config, (0, repository_1.parseRepositoryNwo)("github/codeql-action"), (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.UploadFailedSarifEnabled]), (0, testing_utils_1.getRecordingLogger)(messages));
|
||||
t.deepEqual(messages, []);
|
||||
t.true(diagnosticsExportStub.calledOnceWith(sinon.match.string, category), `Actual args were: ${diagnosticsExportStub.args}`);
|
||||
t.true(uploadFromActions.calledOnceWith(sinon.match.string, sinon.match.string, category, sinon.match.any), `Actual args were: ${uploadFromActions.args}`);
|
||||
t.true(waitForProcessing.calledOnceWith(sinon.match.any, "42", sinon.match.any, {
|
||||
isUnsuccessfulExecution: true,
|
||||
}));
|
||||
t.deepEqual(messages, expectedLogs);
|
||||
if (expectUpload) {
|
||||
t.true(diagnosticsExportStub.calledOnceWith(sinon.match.string, category), `Actual args were: ${diagnosticsExportStub.args}`);
|
||||
t.true(uploadFromActions.calledOnceWith(sinon.match.string, sinon.match.string, category, sinon.match.any), `Actual args were: ${uploadFromActions.args}`);
|
||||
t.true(waitForProcessing.calledOnceWith(sinon.match.any, "42", sinon.match.any, {
|
||||
isUnsuccessfulExecution: true,
|
||||
}));
|
||||
}
|
||||
else {
|
||||
t.true(diagnosticsExportStub.notCalled);
|
||||
t.true(uploadFromActions.notCalled);
|
||||
t.true(waitForProcessing.notCalled);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=init-action-post-helper.test.js.map
|
||||
File diff suppressed because one or more lines are too long
22
lib/init-action-post.js
generated
22
lib/init-action-post.js
generated
|
|
@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const api_client_1 = require("./api-client");
|
||||
const debugArtifacts = __importStar(require("./debug-artifacts"));
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
|
|
@ -34,18 +34,28 @@ const logging_1 = require("./logging");
|
|||
const repository_1 = require("./repository");
|
||||
const util_1 = require("./util");
|
||||
async function runWrapper() {
|
||||
const startedAt = new Date();
|
||||
let uploadFailedSarifResult;
|
||||
try {
|
||||
const logger = (0, logging_1.getActionsLogger)();
|
||||
const gitHubVersion = await (0, api_client_1.getGitHubVersion)();
|
||||
(0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger);
|
||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
|
||||
const features = new feature_flags_1.Features(gitHubVersion, repositoryNwo, actionsUtil.getTemporaryDirectory(), logger);
|
||||
await initActionPostHelper.run(debugArtifacts.uploadDatabaseBundleDebugArtifact, debugArtifacts.uploadLogsDebugArtifact, actionsUtil.printDebugLogs, repositoryNwo, features, logger);
|
||||
const features = new feature_flags_1.Features(gitHubVersion, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), logger);
|
||||
uploadFailedSarifResult = await initActionPostHelper.run(debugArtifacts.uploadDatabaseBundleDebugArtifact, debugArtifacts.uploadLogsDebugArtifact, actions_util_1.printDebugLogs, repositoryNwo, features, logger);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(`init post-action step failed: ${error}`);
|
||||
console.log(error);
|
||||
catch (e) {
|
||||
core.setFailed(e instanceof Error ? e.message : String(e));
|
||||
console.log(e);
|
||||
await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init-post", (0, actions_util_1.getActionsStatus)(e), startedAt, String(e), e instanceof Error ? e.stack : undefined));
|
||||
return;
|
||||
}
|
||||
const statusReportBase = await (0, actions_util_1.createStatusReportBase)("init-post", "success", startedAt);
|
||||
const statusReport = {
|
||||
...statusReportBase,
|
||||
...uploadFailedSarifResult,
|
||||
};
|
||||
await (0, actions_util_1.sendStatusReport)(statusReport);
|
||||
}
|
||||
void runWrapper();
|
||||
//# sourceMappingURL=init-action-post.js.map
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"init-action-post.js","sourceRoot":"","sources":["../src/init-action-post.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AAEtC,4DAA8C;AAC9C,6CAAgD;AAChD,kEAAoD;AACpD,mDAA2C;AAC3C,gFAAkE;AAClE,uCAA6C;AAC7C,6CAAkD;AAClD,iCAAwE;AAExE,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;QAClC,MAAM,aAAa,GAAG,MAAM,IAAA,6BAAgB,GAAE,CAAC;QAC/C,IAAA,gCAAyB,EAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAEjD,MAAM,aAAa,GAAG,IAAA,+BAAkB,EACtC,IAAA,0BAAmB,EAAC,mBAAmB,CAAC,CACzC,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,wBAAQ,CAC3B,aAAa,EACb,aAAa,EACb,WAAW,CAAC,qBAAqB,EAAE,EACnC,MAAM,CACP,CAAC;QAEF,MAAM,oBAAoB,CAAC,GAAG,CAC5B,cAAc,CAAC,iCAAiC,EAChD,cAAc,CAAC,uBAAuB,EACtC,WAAW,CAAC,cAAc,EAC1B,aAAa,EACb,QAAQ,EACR,MAAM,CACP,CAAC;KACH;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
{"version":3,"file":"init-action-post.js","sourceRoot":"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AC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CACzC,CACF,CAAC;QACF,OAAO;KACR;IACD,MAAM,gBAAgB,GAAG,MAAM,IAAA,qCAAsB,EACnD,WAAW,EACX,SAAS,EACT,SAAS,CACV,CAAC;IACF,MAAM,YAAY,GAAyB;QACzC,GAAG,gBAAgB;QACnB,GAAG,uBAAuB;KAC3B,CAAC;IACF,MAAM,IAAA,+BAAgB,EAAC,YAAY,CAAC,CAAC;AACvC,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
8
lib/workflow.js
generated
8
lib/workflow.js
generated
|
|
@ -264,7 +264,7 @@ function getStepsCallingAction(job, actionName) {
|
|||
* determine that no such input is passed to the Action.
|
||||
*/
|
||||
function getInputOrThrow(workflow, jobName, actionName, inputName, matrixVars) {
|
||||
var _a;
|
||||
var _a, _b;
|
||||
const preamble = `Could not get ${inputName} input to ${actionName} since`;
|
||||
if (!workflow.jobs) {
|
||||
throw new Error(`${preamble} the workflow has no jobs.`);
|
||||
|
|
@ -279,11 +279,11 @@ function getInputOrThrow(workflow, jobName, actionName, inputName, matrixVars) {
|
|||
else if (stepsCallingAction.length > 1) {
|
||||
throw new Error(`${preamble} the ${jobName} job calls ${actionName} multiple times.`);
|
||||
}
|
||||
let input = (_a = stepsCallingAction[0].with) === null || _a === void 0 ? void 0 : _a[inputName];
|
||||
let input = (_b = (_a = stepsCallingAction[0].with) === null || _a === void 0 ? void 0 : _a[inputName]) === null || _b === void 0 ? void 0 : _b.toString();
|
||||
if (input !== undefined && matrixVars !== undefined) {
|
||||
// Make a basic attempt to substitute matrix variables
|
||||
// First normalize by removing whitespace
|
||||
// Normalize by removing whitespace
|
||||
input = input.replace(/\${{\s+/, "${{").replace(/\s+}}/, "}}");
|
||||
// Make a basic attempt to substitute matrix variables
|
||||
for (const [key, value] of Object.entries(matrixVars)) {
|
||||
input = input.replace(`\${{matrix.${key}}}`, value);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -295,7 +295,12 @@ function getRefFromEnv(): string {
|
|||
return refEnv;
|
||||
}
|
||||
|
||||
type ActionName = "init" | "autobuild" | "finish" | "upload-sarif";
|
||||
type ActionName =
|
||||
| "init"
|
||||
| "autobuild"
|
||||
| "finish"
|
||||
| "upload-sarif"
|
||||
| "init-post";
|
||||
type ActionStatus =
|
||||
| "starting"
|
||||
| "aborted"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { parseRepositoryNwo } from "./repository";
|
|||
import {
|
||||
createFeatures,
|
||||
getRecordingLogger,
|
||||
LoggedMessage,
|
||||
setupTests,
|
||||
} from "./testing-utils";
|
||||
import * as uploadLib from "./upload-lib";
|
||||
|
|
@ -111,6 +112,40 @@ test("uploads failed SARIF run for typical workflow", async (t) => {
|
|||
await testFailedSarifUpload(t, actionsWorkflow, { category: "my-category" });
|
||||
});
|
||||
|
||||
test("doesn't upload failed SARIF for workflow with upload: false", async (t) => {
|
||||
const actionsWorkflow = createTestWorkflow([
|
||||
{
|
||||
name: "Checkout repository",
|
||||
uses: "actions/checkout@v3",
|
||||
},
|
||||
{
|
||||
name: "Initialize CodeQL",
|
||||
uses: "github/codeql-action/init@v2",
|
||||
with: {
|
||||
languages: "javascript",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Perform CodeQL Analysis",
|
||||
uses: "github/codeql-action/analyze@v2",
|
||||
with: {
|
||||
category: "my-category",
|
||||
upload: false,
|
||||
},
|
||||
},
|
||||
]);
|
||||
await testFailedSarifUpload(t, actionsWorkflow, {
|
||||
expectedLogs: [
|
||||
{
|
||||
message:
|
||||
"Won't upload a failed SARIF file since SARIF upload is disabled.",
|
||||
type: "debug",
|
||||
},
|
||||
],
|
||||
expectUpload: false,
|
||||
});
|
||||
});
|
||||
|
||||
test("uploading failed SARIF run fails when workflow does not reference github/codeql-action", async (t) => {
|
||||
const actionsWorkflow = createTestWorkflow([
|
||||
{
|
||||
|
|
@ -149,7 +184,15 @@ function createTestWorkflow(
|
|||
async function testFailedSarifUpload(
|
||||
t: ExecutionContext<unknown>,
|
||||
actionsWorkflow: workflow.Workflow,
|
||||
{ category }: { category?: string } = {}
|
||||
{
|
||||
category,
|
||||
expectedLogs = [],
|
||||
expectUpload = true,
|
||||
}: {
|
||||
category?: string;
|
||||
expectedLogs?: LoggedMessage[];
|
||||
expectUpload?: boolean;
|
||||
} = {}
|
||||
): Promise<void> {
|
||||
const config = {
|
||||
codeQLCmd: "codeql",
|
||||
|
|
@ -180,23 +223,29 @@ async function testFailedSarifUpload(
|
|||
createFeatures([Feature.UploadFailedSarifEnabled]),
|
||||
getRecordingLogger(messages)
|
||||
);
|
||||
t.deepEqual(messages, []);
|
||||
t.true(
|
||||
diagnosticsExportStub.calledOnceWith(sinon.match.string, category),
|
||||
`Actual args were: ${diagnosticsExportStub.args}`
|
||||
);
|
||||
t.true(
|
||||
uploadFromActions.calledOnceWith(
|
||||
sinon.match.string,
|
||||
sinon.match.string,
|
||||
category,
|
||||
sinon.match.any
|
||||
),
|
||||
`Actual args were: ${uploadFromActions.args}`
|
||||
);
|
||||
t.true(
|
||||
waitForProcessing.calledOnceWith(sinon.match.any, "42", sinon.match.any, {
|
||||
isUnsuccessfulExecution: true,
|
||||
})
|
||||
);
|
||||
t.deepEqual(messages, expectedLogs);
|
||||
if (expectUpload) {
|
||||
t.true(
|
||||
diagnosticsExportStub.calledOnceWith(sinon.match.string, category),
|
||||
`Actual args were: ${diagnosticsExportStub.args}`
|
||||
);
|
||||
t.true(
|
||||
uploadFromActions.calledOnceWith(
|
||||
sinon.match.string,
|
||||
sinon.match.string,
|
||||
category,
|
||||
sinon.match.any
|
||||
),
|
||||
`Actual args were: ${uploadFromActions.args}`
|
||||
);
|
||||
t.true(
|
||||
waitForProcessing.calledOnceWith(sinon.match.any, "42", sinon.match.any, {
|
||||
isUnsuccessfulExecution: true,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
t.true(diagnosticsExportStub.notCalled);
|
||||
t.true(uploadFromActions.notCalled);
|
||||
t.true(waitForProcessing.notCalled);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,17 +16,37 @@ import {
|
|||
getWorkflow,
|
||||
} from "./workflow";
|
||||
|
||||
export interface UploadFailedSarifResult extends uploadLib.UploadStatusReport {
|
||||
/** If there was an error while uploading a failed run, this is its message. */
|
||||
upload_failed_run_error?: string;
|
||||
/** If there was an error while uploading a failed run, this is its stack trace. */
|
||||
upload_failed_run_stack_trace?: string;
|
||||
/** Reason why we did not upload a SARIF payload with `executionSuccessful: false`. */
|
||||
upload_failed_run_skipped_because?: string;
|
||||
}
|
||||
|
||||
function createFailedUploadFailedSarifResult(
|
||||
error: unknown
|
||||
): UploadFailedSarifResult {
|
||||
return {
|
||||
upload_failed_run_error:
|
||||
error instanceof Error ? error.message : String(error),
|
||||
upload_failed_run_stack_trace:
|
||||
error instanceof Error ? error.stack : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export async function uploadFailedSarif(
|
||||
config: Config,
|
||||
repositoryNwo: RepositoryNwo,
|
||||
featureEnablement: FeatureEnablement,
|
||||
logger: Logger
|
||||
) {
|
||||
): Promise<UploadFailedSarifResult> {
|
||||
if (!config.codeQLCmd) {
|
||||
logger.warning(
|
||||
"CodeQL command not found. Unable to upload failed SARIF file."
|
||||
);
|
||||
return;
|
||||
return { upload_failed_run_skipped_because: "CodeQL command not found" };
|
||||
}
|
||||
const codeql = await getCodeQL(config.codeQLCmd);
|
||||
if (
|
||||
|
|
@ -36,7 +56,7 @@ export async function uploadFailedSarif(
|
|||
))
|
||||
) {
|
||||
logger.debug("Uploading failed SARIF is disabled.");
|
||||
return;
|
||||
return { upload_failed_run_skipped_because: "Feature disabled" };
|
||||
}
|
||||
const workflow = await getWorkflow();
|
||||
const jobName = getRequiredEnvParam("GITHUB_JOB");
|
||||
|
|
@ -48,7 +68,7 @@ export async function uploadFailedSarif(
|
|||
logger.debug(
|
||||
"Won't upload a failed SARIF file since SARIF upload is disabled."
|
||||
);
|
||||
return;
|
||||
return { upload_failed_run_skipped_because: "SARIF upload is disabled" };
|
||||
}
|
||||
const category = getCategoryInputOrThrow(workflow, jobName, matrix);
|
||||
const checkoutPath = getCheckoutPathInputOrThrow(workflow, jobName, matrix);
|
||||
|
|
@ -69,6 +89,48 @@ export async function uploadFailedSarif(
|
|||
logger,
|
||||
{ isUnsuccessfulExecution: true }
|
||||
);
|
||||
return uploadResult?.statusReport ?? {};
|
||||
}
|
||||
|
||||
export async function uploadSarifIfRunFailed(
|
||||
config: Config,
|
||||
repositoryNwo: RepositoryNwo,
|
||||
featureEnablement: FeatureEnablement,
|
||||
logger: Logger
|
||||
): Promise<UploadFailedSarifResult> {
|
||||
// Environment variable used to integration test uploading a SARIF file for failed runs
|
||||
const expectFailedSarifUpload =
|
||||
process.env["CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF"] === "true";
|
||||
|
||||
if (process.env[CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF] !== "true") {
|
||||
try {
|
||||
return await uploadFailedSarif(
|
||||
config,
|
||||
repositoryNwo,
|
||||
featureEnablement,
|
||||
logger
|
||||
);
|
||||
} catch (e) {
|
||||
if (expectFailedSarifUpload) {
|
||||
throw new Error(
|
||||
"Expected to upload a SARIF file for the failed run, but encountered " +
|
||||
`the following error: ${e}`
|
||||
);
|
||||
}
|
||||
logger.info(
|
||||
`Failed to upload a SARIF file for the failed run. Error: ${e}`
|
||||
);
|
||||
return createFailedUploadFailedSarifResult(e);
|
||||
}
|
||||
} else if (expectFailedSarifUpload) {
|
||||
throw new Error(
|
||||
"Expected to upload a SARIF file for the failed run, but didn't."
|
||||
);
|
||||
} else {
|
||||
return {
|
||||
upload_failed_run_skipped_because: "SARIF file already uploaded",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function run(
|
||||
|
|
@ -87,29 +149,12 @@ export async function run(
|
|||
return;
|
||||
}
|
||||
|
||||
// Environment variable used to integration test uploading a SARIF file for failed runs
|
||||
const expectFailedSarifUpload =
|
||||
process.env["CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF"] === "true";
|
||||
|
||||
if (process.env[CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF] !== "true") {
|
||||
try {
|
||||
await uploadFailedSarif(config, repositoryNwo, featureEnablement, logger);
|
||||
} catch (e) {
|
||||
if (expectFailedSarifUpload) {
|
||||
throw new Error(
|
||||
"Expected to upload a SARIF file for the failed run, but encountered " +
|
||||
`the following error: ${e}`
|
||||
);
|
||||
}
|
||||
logger.info(
|
||||
`Failed to upload a SARIF file for the failed run. Error: ${e}`
|
||||
);
|
||||
}
|
||||
} else if (expectFailedSarifUpload) {
|
||||
throw new Error(
|
||||
"Expected to upload a SARIF file for the failed run, but didn't."
|
||||
);
|
||||
}
|
||||
const uploadFailedSarifResult = await uploadSarifIfRunFailed(
|
||||
config,
|
||||
repositoryNwo,
|
||||
featureEnablement,
|
||||
logger
|
||||
);
|
||||
|
||||
// Upload appropriate Actions artifacts for debugging
|
||||
if (config.debugMode) {
|
||||
|
|
@ -121,4 +166,6 @@ export async function run(
|
|||
|
||||
await printDebugLogs(config);
|
||||
}
|
||||
|
||||
return uploadFailedSarifResult;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,14 @@
|
|||
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import {
|
||||
createStatusReportBase,
|
||||
getActionsStatus,
|
||||
getTemporaryDirectory,
|
||||
printDebugLogs,
|
||||
sendStatusReport,
|
||||
StatusReportBase,
|
||||
} from "./actions-util";
|
||||
import { getGitHubVersion } from "./api-client";
|
||||
import * as debugArtifacts from "./debug-artifacts";
|
||||
import { Features } from "./feature-flags";
|
||||
|
|
@ -15,7 +22,15 @@ import { getActionsLogger } from "./logging";
|
|||
import { parseRepositoryNwo } from "./repository";
|
||||
import { checkGitHubVersionInRange, getRequiredEnvParam } from "./util";
|
||||
|
||||
interface InitPostStatusReport
|
||||
extends StatusReportBase,
|
||||
initActionPostHelper.UploadFailedSarifResult {}
|
||||
|
||||
async function runWrapper() {
|
||||
const startedAt = new Date();
|
||||
let uploadFailedSarifResult:
|
||||
| initActionPostHelper.UploadFailedSarifResult
|
||||
| undefined;
|
||||
try {
|
||||
const logger = getActionsLogger();
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
|
|
@ -27,22 +42,43 @@ async function runWrapper() {
|
|||
const features = new Features(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
actionsUtil.getTemporaryDirectory(),
|
||||
getTemporaryDirectory(),
|
||||
logger
|
||||
);
|
||||
|
||||
await initActionPostHelper.run(
|
||||
uploadFailedSarifResult = await initActionPostHelper.run(
|
||||
debugArtifacts.uploadDatabaseBundleDebugArtifact,
|
||||
debugArtifacts.uploadLogsDebugArtifact,
|
||||
actionsUtil.printDebugLogs,
|
||||
printDebugLogs,
|
||||
repositoryNwo,
|
||||
features,
|
||||
logger
|
||||
);
|
||||
} catch (error) {
|
||||
core.setFailed(`init post-action step failed: ${error}`);
|
||||
console.log(error);
|
||||
} catch (e) {
|
||||
core.setFailed(e instanceof Error ? e.message : String(e));
|
||||
|
||||
console.log(e);
|
||||
await sendStatusReport(
|
||||
await createStatusReportBase(
|
||||
"init-post",
|
||||
getActionsStatus(e),
|
||||
startedAt,
|
||||
String(e),
|
||||
e instanceof Error ? e.stack : undefined
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
"init-post",
|
||||
"success",
|
||||
startedAt
|
||||
);
|
||||
const statusReport: InitPostStatusReport = {
|
||||
...statusReportBase,
|
||||
...uploadFailedSarifResult,
|
||||
};
|
||||
await sendStatusReport(statusReport);
|
||||
}
|
||||
|
||||
void runWrapper();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export interface WorkflowJobStep {
|
|||
name?: string;
|
||||
run?: any;
|
||||
uses?: string;
|
||||
with?: { [key: string]: string };
|
||||
with?: { [key: string]: boolean | number | string };
|
||||
}
|
||||
|
||||
interface WorkflowJob {
|
||||
|
|
@ -350,12 +350,12 @@ function getInputOrThrow(
|
|||
);
|
||||
}
|
||||
|
||||
let input = stepsCallingAction[0].with?.[inputName];
|
||||
let input = stepsCallingAction[0].with?.[inputName]?.toString();
|
||||
|
||||
if (input !== undefined && matrixVars !== undefined) {
|
||||
// Make a basic attempt to substitute matrix variables
|
||||
// First normalize by removing whitespace
|
||||
// Normalize by removing whitespace
|
||||
input = input.replace(/\${{\s+/, "${{").replace(/\s+}}/, "}}");
|
||||
// Make a basic attempt to substitute matrix variables
|
||||
for (const [key, value] of Object.entries(matrixVars)) {
|
||||
input = input.replace(`\${{matrix.${key}}}`, value);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue