Upload .quality.sarif files to CQ service in upload-sarif action
This commit is contained in:
parent
86f47e8b74
commit
2c76207fa4
6 changed files with 66 additions and 7 deletions
|
|
@ -405,7 +405,7 @@ export function findSarifFilesInDir(
|
|||
return sarifFiles;
|
||||
}
|
||||
|
||||
function getSarifFilePaths(
|
||||
export function getSarifFilePaths(
|
||||
sarifPath: string,
|
||||
isSarif: (name: string) => boolean = defaultIsSarif,
|
||||
) {
|
||||
|
|
@ -622,6 +622,27 @@ export async function uploadFiles(
|
|||
uploadTarget.sarifFilter,
|
||||
);
|
||||
|
||||
return uploadSpecifiedFiles(
|
||||
sarifPaths,
|
||||
checkoutPath,
|
||||
category,
|
||||
features,
|
||||
logger,
|
||||
uploadTarget,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads the given array of SARIF files.
|
||||
*/
|
||||
export async function uploadSpecifiedFiles(
|
||||
sarifPaths: string[],
|
||||
checkoutPath: string,
|
||||
category: string | undefined,
|
||||
features: FeatureEnablement,
|
||||
logger: Logger,
|
||||
uploadTarget: UploadTarget = CodeScanningTarget,
|
||||
): Promise<UploadResult> {
|
||||
logger.startGroup(`Uploading ${uploadTarget.name} results`);
|
||||
logger.info(`Processing sarif files: ${JSON.stringify(sarifPaths)}`);
|
||||
|
||||
|
|
|
|||
|
|
@ -83,15 +83,33 @@ async function run() {
|
|||
}
|
||||
|
||||
try {
|
||||
const sarifPath = actionsUtil.getRequiredInput("sarif_file");
|
||||
const checkoutPath = actionsUtil.getRequiredInput("checkout_path");
|
||||
const category = actionsUtil.getOptionalInput("category");
|
||||
|
||||
const uploadResult = await upload_lib.uploadFiles(
|
||||
actionsUtil.getRequiredInput("sarif_file"),
|
||||
actionsUtil.getRequiredInput("checkout_path"),
|
||||
actionsUtil.getOptionalInput("category"),
|
||||
sarifPath,
|
||||
checkoutPath,
|
||||
category,
|
||||
features,
|
||||
logger,
|
||||
);
|
||||
core.setOutput("sarif-id", uploadResult.sarifID);
|
||||
|
||||
// If there are `.quality.sarif` files in `sarifPath`, then upload those to the code quality service.
|
||||
const qualitySarifFiles = upload_lib.getSarifFilePaths(sarifPath);
|
||||
|
||||
if (qualitySarifFiles.length !== 0) {
|
||||
await upload_lib.uploadSpecifiedFiles(
|
||||
qualitySarifFiles,
|
||||
checkoutPath,
|
||||
category,
|
||||
features,
|
||||
logger,
|
||||
upload_lib.CodeQualityTarget,
|
||||
);
|
||||
}
|
||||
|
||||
// We don't upload results in test mode, so don't wait for processing
|
||||
if (isInTestMode()) {
|
||||
core.debug("In test mode. Waiting for processing is disabled.");
|
||||
|
|
@ -101,6 +119,8 @@ async function run() {
|
|||
uploadResult.sarifID,
|
||||
logger,
|
||||
);
|
||||
// The code quality service does not currently have an endpoint to wait for SARIF processing,
|
||||
// so we can't wait for that here.
|
||||
}
|
||||
await sendSuccessStatusReport(startedAt, uploadResult.statusReport, logger);
|
||||
} catch (unwrappedError) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue