Move isDirectory check into findAndUpload

This commit is contained in:
Michael B. Gale
2025-09-18 14:10:54 +01:00
parent a6161a8092
commit c8e017d3e7
2 changed files with 50 additions and 46 deletions
+26 -23
View File
@@ -39,6 +39,7 @@ interface UploadSarifStatusReport
* @param logger The logger to use.
* @param features Information about FFs.
* @param sarifPath The path to a directory containing SARIF files.
* @param pathStats Information about `sarifPath`.
* @param checkoutPath The checkout path.
* @param analysis The configuration of the analysis we should upload SARIF files for.
* @param category The SARIF category to use for the upload.
@@ -48,24 +49,27 @@ async function findAndUpload(
logger: Logger,
features: Features,
sarifPath: string,
pathStats: fs.Stats,
checkoutPath: string,
analysis: analyses.AnalysisConfig,
category?: string,
): Promise<upload_lib.UploadResult | undefined> {
const sarifFiles = upload_lib.findSarifFilesInDir(
sarifPath,
analysis.sarifPredicate,
);
if (sarifFiles.length !== 0) {
return await upload_lib.uploadSpecifiedFiles(
sarifFiles,
checkoutPath,
category,
features,
logger,
analysis,
if (pathStats.isDirectory()) {
const sarifFiles = upload_lib.findSarifFilesInDir(
sarifPath,
analysis.sarifPredicate,
);
if (sarifFiles.length !== 0) {
return await upload_lib.uploadSpecifiedFiles(
sarifFiles,
checkoutPath,
category,
features,
logger,
analysis,
);
}
}
return undefined;
@@ -148,16 +152,15 @@ async function run() {
// If there are `.quality.sarif` files in `sarifPath`, then upload those to the code quality service.
// Code quality can currently only be enabled on top of security, so we'd currently always expect to
// have a directory for the results here.
if (pathStats.isDirectory()) {
await findAndUpload(
logger,
features,
sarifPath,
checkoutPath,
analyses.CodeQuality,
actionsUtil.fixCodeQualityCategory(logger, category),
);
}
await findAndUpload(
logger,
features,
sarifPath,
pathStats,
checkoutPath,
analyses.CodeQuality,
actionsUtil.fixCodeQualityCategory(logger, category),
);
// We don't upload results in test mode, so don't wait for processing
if (isInTestMode()) {