1- import * as fs from "fs" ;
2-
31import * as core from "@actions/core" ;
42
53import * as actionsUtil from "./actions-util" ;
@@ -18,7 +16,7 @@ import {
1816 isThirdPartyAnalysis ,
1917} from "./status-report" ;
2018import * as upload_lib from "./upload-lib" ;
21- import { findAndUpload } from "./upload-sarif" ;
19+ import { uploadSarif } from "./upload-sarif" ;
2220import {
2321 ConfigurationError ,
2422 checkActionVersion ,
@@ -91,56 +89,29 @@ async function run() {
9189 const sarifPath = actionsUtil . getRequiredInput ( "sarif_file" ) ;
9290 const checkoutPath = actionsUtil . getRequiredInput ( "checkout_path" ) ;
9391 const category = actionsUtil . getOptionalInput ( "category" ) ;
94- const pathStats = fs . lstatSync ( sarifPath , { throwIfNoEntry : false } ) ;
95-
96- if ( pathStats === undefined ) {
97- throw new ConfigurationError ( `Path does not exist: ${ sarifPath } .` ) ;
98- }
9992
100- const sarifIds : Array < { analysis : string ; id : string } > = [ ] ;
101- const uploadResult = await findAndUpload (
93+ const uploadResults = await uploadSarif (
10294 logger ,
10395 features ,
104- sarifPath ,
105- pathStats ,
10696 checkoutPath ,
107- analyses . CodeScanning ,
108- category ,
109- ) ;
110- if ( uploadResult !== undefined ) {
111- core . setOutput ( "sarif-id" , uploadResult . sarifID ) ;
112- sarifIds . push ( {
113- analysis : analyses . AnalysisKind . CodeScanning ,
114- id : uploadResult . sarifID ,
115- } ) ;
116- }
117-
118- // If there are `.quality.sarif` files in `sarifPath`, then upload those to the code quality service.
119- const qualityUploadResult = await findAndUpload (
120- logger ,
121- features ,
12297 sarifPath ,
123- pathStats ,
124- checkoutPath ,
125- analyses . CodeQuality ,
126- actionsUtil . fixCodeQualityCategory ( logger , category ) ,
98+ category ,
12799 ) ;
128- if ( qualityUploadResult !== undefined ) {
129- sarifIds . push ( {
130- analysis : analyses . AnalysisKind . CodeQuality ,
131- id : qualityUploadResult . sarifID ,
132- } ) ;
100+ const codeScanningResult =
101+ uploadResults [ analyses . AnalysisKind . CodeScanning ] ;
102+ if ( codeScanningResult !== undefined ) {
103+ core . setOutput ( "sarif-id" , codeScanningResult . sarifID ) ;
133104 }
134- core . setOutput ( "sarif-ids" , JSON . stringify ( sarifIds ) ) ;
105+ core . setOutput ( "sarif-ids" , JSON . stringify ( uploadResults ) ) ;
135106
136107 // We don't upload results in test mode, so don't wait for processing
137108 if ( isInTestMode ( ) ) {
138109 core . debug ( "In test mode. Waiting for processing is disabled." ) ;
139110 } else if ( actionsUtil . getRequiredInput ( "wait-for-processing" ) === "true" ) {
140- if ( uploadResult !== undefined ) {
111+ if ( codeScanningResult !== undefined ) {
141112 await upload_lib . waitForProcessing (
142113 getRepositoryNwo ( ) ,
143- uploadResult . sarifID ,
114+ codeScanningResult . sarifID ,
144115 logger ,
145116 ) ;
146117 }
@@ -149,7 +120,7 @@ async function run() {
149120 }
150121 await sendSuccessStatusReport (
151122 startedAt ,
152- uploadResult ?. statusReport || { } ,
123+ codeScanningResult ?. statusReport || { } ,
153124 logger ,
154125 ) ;
155126 } catch ( unwrappedError ) {
0 commit comments