mirror of
https://github.com/github/codeql-action.git
synced 2026-10-29 17:17:15 +00:00
Improve logging in uploadSarifArtifact and when it is called in tests
This commit is contained in:
31
lib/entry-points.js
generated
31
lib/entry-points.js
generated
@@ -187079,7 +187079,7 @@ async function maybeUploadFailedSarif(config, repositoryNwo, features, logger2)
|
||||
logger2,
|
||||
{ isUnsuccessfulExecution: true }
|
||||
);
|
||||
if (uploadResult.sarifID && isInTestMode()) {
|
||||
if (uploadResult.sarifID && shouldSkipSarifUpload()) {
|
||||
await uploadSarifArtifact(logger2, "test-mode-sarif", {
|
||||
// We defaulted to CodeScanning in the `uploadFiles` call above.
|
||||
sarifFile: getSavedPayloadPath(CodeScanning.kind),
|
||||
@@ -187098,19 +187098,22 @@ async function maybeUploadFailedSarifArtifact(config, features, logger2) {
|
||||
return uploadSarifArtifact(logger2, "sarif-artifact", failedSarif);
|
||||
}
|
||||
async function uploadSarifArtifact(logger2, prefix, failedSarif) {
|
||||
logger2.info(
|
||||
`Uploading failed SARIF file ${failedSarif.sarifFile} as artifact`
|
||||
);
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
const client = await getArtifactUploaderClient(logger2, gitHubVersion.type);
|
||||
const suffix = getArtifactSuffix(getOptionalInput("matrix"));
|
||||
const name = sanitizeArtifactName(`${prefix}-${suffix}`);
|
||||
await client.uploadArtifact(
|
||||
name,
|
||||
[import_path8.default.normalize(failedSarif.sarifFile)],
|
||||
import_path8.default.normalize("..")
|
||||
);
|
||||
return { sarifID: name };
|
||||
logger2.startGroup(`Uploading failed SARIF file as artifact`);
|
||||
logger2.info(`Uploading '${failedSarif.sarifFile}' as artifact`);
|
||||
try {
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
const client = await getArtifactUploaderClient(logger2, gitHubVersion.type);
|
||||
const suffix = getArtifactSuffix(getOptionalInput("matrix"));
|
||||
const name = sanitizeArtifactName(`${prefix}-${suffix}`);
|
||||
await client.uploadArtifact(
|
||||
name,
|
||||
[import_path8.default.normalize(failedSarif.sarifFile)],
|
||||
import_path8.default.normalize("..")
|
||||
);
|
||||
return { sarifID: name };
|
||||
} finally {
|
||||
logger2.endGroup();
|
||||
}
|
||||
}
|
||||
async function tryUploadSarifIfRunFailed(config, repositoryNwo, features, logger2) {
|
||||
if (process.env["CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */] === "true") {
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
} from "./debug-artifacts";
|
||||
import * as dependencyCaching from "./dependency-caching";
|
||||
import { getTempDiagnosticPath } from "./diagnostics";
|
||||
import { EnvVar, isInTestMode, ReadOnlyEnv } from "./environment";
|
||||
import { EnvVar, ReadOnlyEnv } from "./environment";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { Logger } from "./logging";
|
||||
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
||||
@@ -46,6 +46,7 @@ import {
|
||||
parseMatrixInput,
|
||||
Result,
|
||||
shouldSkipGenerateFailedSarif,
|
||||
shouldSkipSarifUpload,
|
||||
Success,
|
||||
wrapError,
|
||||
} from "./util";
|
||||
@@ -263,10 +264,10 @@ async function maybeUploadFailedSarif(
|
||||
{ isUnsuccessfulExecution: true },
|
||||
);
|
||||
|
||||
// If we are in test mode, `uploadFiles` will not have uploaded the failed SARIF file
|
||||
// and instead will have written it to disk. Upload it as a workflow artifact so that
|
||||
// If SARIF upload is disabled for testing, `uploadFiles` will not have uploaded the failed
|
||||
// SARIF file and instead will have written it to disk. Upload it as a workflow artifact so that
|
||||
// we can inspect it in validation jobs.
|
||||
if (uploadResult.sarifID && isInTestMode()) {
|
||||
if (uploadResult.sarifID && shouldSkipSarifUpload()) {
|
||||
await uploadSarifArtifact(logger, "test-mode-sarif", {
|
||||
// We defaulted to CodeScanning in the `uploadFiles` call above.
|
||||
sarifFile: uploadLib.getSavedPayloadPath(CodeScanning.kind),
|
||||
@@ -302,22 +303,25 @@ async function uploadSarifArtifact(
|
||||
prefix: string,
|
||||
failedSarif: FailedSarifInfo,
|
||||
): Promise<UploadFailedSarifResult> {
|
||||
logger.info(
|
||||
`Uploading failed SARIF file ${failedSarif.sarifFile} as artifact`,
|
||||
);
|
||||
logger.startGroup(`Uploading failed SARIF file as artifact`);
|
||||
logger.info(`Uploading '${failedSarif.sarifFile}' as artifact`);
|
||||
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
const client = await getArtifactUploaderClient(logger, gitHubVersion.type);
|
||||
try {
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
const client = await getArtifactUploaderClient(logger, gitHubVersion.type);
|
||||
|
||||
const suffix = getArtifactSuffix(actionsUtil.getOptionalInput("matrix"));
|
||||
const name = sanitizeArtifactName(`${prefix}-${suffix}`);
|
||||
await client.uploadArtifact(
|
||||
name,
|
||||
[path.normalize(failedSarif.sarifFile)],
|
||||
path.normalize(".."),
|
||||
);
|
||||
const suffix = getArtifactSuffix(actionsUtil.getOptionalInput("matrix"));
|
||||
const name = sanitizeArtifactName(`${prefix}-${suffix}`);
|
||||
await client.uploadArtifact(
|
||||
name,
|
||||
[path.normalize(failedSarif.sarifFile)],
|
||||
path.normalize(".."),
|
||||
);
|
||||
|
||||
return { sarifID: name };
|
||||
return { sarifID: name };
|
||||
} finally {
|
||||
logger.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user