Skip to content

Commit c8e017d

Browse files
committed
Move isDirectory check into findAndUpload
1 parent a6161a8 commit c8e017d

File tree

2 files changed

+50
-46
lines changed

2 files changed

+50
-46
lines changed

lib/upload-sarif-action.js

Lines changed: 24 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/upload-sarif-action.ts

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ interface UploadSarifStatusReport
3939
* @param logger The logger to use.
4040
* @param features Information about FFs.
4141
* @param sarifPath The path to a directory containing SARIF files.
42+
* @param pathStats Information about `sarifPath`.
4243
* @param checkoutPath The checkout path.
4344
* @param analysis The configuration of the analysis we should upload SARIF files for.
4445
* @param category The SARIF category to use for the upload.
@@ -48,24 +49,27 @@ async function findAndUpload(
4849
logger: Logger,
4950
features: Features,
5051
sarifPath: string,
52+
pathStats: fs.Stats,
5153
checkoutPath: string,
5254
analysis: analyses.AnalysisConfig,
5355
category?: string,
5456
): Promise<upload_lib.UploadResult | undefined> {
55-
const sarifFiles = upload_lib.findSarifFilesInDir(
56-
sarifPath,
57-
analysis.sarifPredicate,
58-
);
59-
60-
if (sarifFiles.length !== 0) {
61-
return await upload_lib.uploadSpecifiedFiles(
62-
sarifFiles,
63-
checkoutPath,
64-
category,
65-
features,
66-
logger,
67-
analysis,
57+
if (pathStats.isDirectory()) {
58+
const sarifFiles = upload_lib.findSarifFilesInDir(
59+
sarifPath,
60+
analysis.sarifPredicate,
6861
);
62+
63+
if (sarifFiles.length !== 0) {
64+
return await upload_lib.uploadSpecifiedFiles(
65+
sarifFiles,
66+
checkoutPath,
67+
category,
68+
features,
69+
logger,
70+
analysis,
71+
);
72+
}
6973
}
7074

7175
return undefined;
@@ -148,16 +152,15 @@ async function run() {
148152
// If there are `.quality.sarif` files in `sarifPath`, then upload those to the code quality service.
149153
// Code quality can currently only be enabled on top of security, so we'd currently always expect to
150154
// have a directory for the results here.
151-
if (pathStats.isDirectory()) {
152-
await findAndUpload(
153-
logger,
154-
features,
155-
sarifPath,
156-
checkoutPath,
157-
analyses.CodeQuality,
158-
actionsUtil.fixCodeQualityCategory(logger, category),
159-
);
160-
}
155+
await findAndUpload(
156+
logger,
157+
features,
158+
sarifPath,
159+
pathStats,
160+
checkoutPath,
161+
analyses.CodeQuality,
162+
actionsUtil.fixCodeQualityCategory(logger, category),
163+
);
161164

162165
// We don't upload results in test mode, so don't wait for processing
163166
if (isInTestMode()) {

0 commit comments

Comments
 (0)