@@ -18,6 +18,7 @@ import {
1818 isThirdPartyAnalysis ,
1919} from "./status-report" ;
2020import * as upload_lib from "./upload-lib" ;
21+ import { findAndUpload } from "./upload-sarif" ;
2122import {
2223 ConfigurationError ,
2324 checkActionVersion ,
@@ -32,60 +33,6 @@ interface UploadSarifStatusReport
3233 extends StatusReportBase ,
3334 upload_lib . UploadStatusReport { }
3435
35- /**
36- * Searches for SARIF files for the given `analysis` in the given `sarifPath`.
37- * If any are found, then they are uploaded to the appropriate endpoint for the given `analysis`.
38- *
39- * @param logger The logger to use.
40- * @param features Information about FFs.
41- * @param sarifPath The path to a SARIF file or directory containing SARIF files.
42- * @param pathStats Information about `sarifPath`.
43- * @param checkoutPath The checkout path.
44- * @param analysis The configuration of the analysis we should upload SARIF files for.
45- * @param category The SARIF category to use for the upload.
46- * @returns The result of uploading the SARIF file(s) or `undefined` if there are none.
47- */
48- async function findAndUpload (
49- logger : Logger ,
50- features : Features ,
51- sarifPath : string ,
52- pathStats : fs . Stats ,
53- checkoutPath : string ,
54- analysis : analyses . AnalysisConfig ,
55- category ?: string ,
56- ) : Promise < upload_lib . UploadResult | undefined > {
57- let sarifFiles : string [ ] | undefined ;
58-
59- if ( pathStats . isDirectory ( ) ) {
60- sarifFiles = upload_lib . findSarifFilesInDir (
61- sarifPath ,
62- analysis . sarifPredicate ,
63- ) ;
64- } else if (
65- pathStats . isFile ( ) &&
66- ( analysis . sarifPredicate ( sarifPath ) ||
67- ( analysis . kind === analyses . AnalysisKind . CodeScanning &&
68- ! analyses . CodeQuality . sarifPredicate ( sarifPath ) ) )
69- ) {
70- sarifFiles = [ sarifPath ] ;
71- } else {
72- return undefined ;
73- }
74-
75- if ( sarifFiles . length !== 0 ) {
76- return await upload_lib . uploadSpecifiedFiles (
77- sarifFiles ,
78- checkoutPath ,
79- category ,
80- features ,
81- logger ,
82- analysis ,
83- ) ;
84- }
85-
86- return undefined ;
87- }
88-
8936async function sendSuccessStatusReport (
9037 startedAt : Date ,
9138 uploadStats : upload_lib . UploadStatusReport ,
0 commit comments