@@ -19,12 +19,7 @@ import { getApiDetails, getGitHubVersion } from "./api-client";
1919import { runAutobuild } from "./autobuild" ;
2020import { getTotalCacheSize , shouldStoreCache } from "./caching-utils" ;
2121import { getCodeQL } from "./codeql" ;
22- import {
23- Config ,
24- getConfig ,
25- isCodeQualityEnabled ,
26- isCodeScanningEnabled ,
27- } from "./config-utils" ;
22+ import { Config , getConfig } from "./config-utils" ;
2823import { uploadDatabases } from "./database-upload" ;
2924import {
3025 DependencyCacheUploadStatusReport ,
@@ -52,6 +47,7 @@ import {
5247} from "./trap-caching" ;
5348import * as uploadLib from "./upload-lib" ;
5449import { UploadResult } from "./upload-lib" ;
50+ import { uploadSarif } from "./upload-sarif" ;
5551import * as util from "./util" ;
5652
5753interface AnalysisStatusReport
@@ -211,7 +207,9 @@ async function runAutobuildIfLegacyGoWorkflow(config: Config, logger: Logger) {
211207
212208async function run ( ) {
213209 const startedAt = new Date ( ) ;
214- let uploadResult : UploadResult | undefined = undefined ;
210+ let uploadResults :
211+ | Partial < Record < analyses . AnalysisKind , UploadResult > >
212+ | undefined = undefined ;
215213 let runStats : QueriesStatusReport | undefined = undefined ;
216214 let config : Config | undefined = undefined ;
217215 let trapCacheCleanupTelemetry : TrapCacheCleanupStatusReport | undefined =
@@ -343,30 +341,25 @@ async function run() {
343341 core . setOutput ( "sarif-output" , path . resolve ( outputDir ) ) ;
344342 const uploadInput = actionsUtil . getOptionalInput ( "upload" ) ;
345343 if ( runStats && actionsUtil . getUploadValue ( uploadInput ) === "always" ) {
346- if ( isCodeScanningEnabled ( config ) ) {
347- uploadResult = await uploadLib . uploadFiles (
348- outputDir ,
349- actionsUtil . getRequiredInput ( "checkout_path" ) ,
350- actionsUtil . getOptionalInput ( "category" ) ,
351- features ,
352- logger ,
353- analyses . CodeScanning ,
354- ) ;
355- core . setOutput ( "sarif-id" , uploadResult . sarifID ) ;
356- }
357-
358- if ( isCodeQualityEnabled ( config ) ) {
359- const analysis = analyses . CodeQuality ;
360- const qualityUploadResult = await uploadLib . uploadFiles (
361- outputDir ,
362- actionsUtil . getRequiredInput ( "checkout_path" ) ,
363- actionsUtil . getOptionalInput ( "category" ) ,
364- features ,
365- logger ,
366- analysis ,
367- ) ;
368- core . setOutput ( "quality-sarif-id" , qualityUploadResult . sarifID ) ;
369- }
344+ const checkoutPath = actionsUtil . getRequiredInput ( "checkout_path" ) ;
345+ const category = actionsUtil . getOptionalInput ( "category" ) ;
346+
347+ uploadResults = await uploadSarif (
348+ logger ,
349+ features ,
350+ checkoutPath ,
351+ outputDir ,
352+ category ,
353+ ) ;
354+
355+ core . setOutput (
356+ "sarif-id" ,
357+ uploadResults [ analyses . AnalysisKind . CodeScanning ] ?. sarifID ,
358+ ) ;
359+ core . setOutput (
360+ "quality-sarif-id" ,
361+ uploadResults [ analyses . AnalysisKind . CodeQuality ] ?. sarifID ,
362+ ) ;
370363 } else {
371364 logger . info ( "Not uploading results" ) ;
372365 }
@@ -408,12 +401,13 @@ async function run() {
408401 if ( util . isInTestMode ( ) ) {
409402 logger . debug ( "In test mode. Waiting for processing is disabled." ) ;
410403 } else if (
411- uploadResult !== undefined &&
404+ uploadResults !== undefined &&
405+ uploadResults [ analyses . AnalysisKind . CodeScanning ] !== undefined &&
412406 actionsUtil . getRequiredInput ( "wait-for-processing" ) === "true"
413407 ) {
414408 await uploadLib . waitForProcessing (
415409 getRepositoryNwo ( ) ,
416- uploadResult . sarifID ,
410+ uploadResults [ analyses . AnalysisKind . CodeScanning ] . sarifID ,
417411 getActionsLogger ( ) ,
418412 ) ;
419413 }
@@ -450,13 +444,17 @@ async function run() {
450444 return ;
451445 }
452446
453- if ( runStats && uploadResult ) {
447+ if (
448+ runStats &&
449+ uploadResults &&
450+ uploadResults [ analyses . AnalysisKind . CodeScanning ]
451+ ) {
454452 await sendStatusReport (
455453 startedAt ,
456454 config ,
457455 {
458456 ...runStats ,
459- ...uploadResult . statusReport ,
457+ ...uploadResults [ analyses . AnalysisKind . CodeScanning ] . statusReport ,
460458 } ,
461459 undefined ,
462460 trapCacheUploadTime ,
0 commit comments