@@ -3,10 +3,11 @@ import * as path from "path";
3
3
4
4
import test from "ava" ;
5
5
6
+ import { Feature } from "./feature-flags" ;
6
7
import { getRunnerLogger , Logger } from "./logging" ;
7
- import { setupTests } from "./testing-utils" ;
8
+ import { createFeatures , setupTests } from "./testing-utils" ;
8
9
import * as uploadLib from "./upload-lib" ;
9
- import { initializeEnvironment , withTmpDir } from "./util" ;
10
+ import { GitHubVariant , initializeEnvironment , withTmpDir } from "./util" ;
10
11
11
12
setupTests ( test ) ;
12
13
@@ -324,6 +325,106 @@ test("accept results with invalid artifactLocation.uri value", (t) => {
324
325
) ;
325
326
} ) ;
326
327
328
+ test ( "shouldShowCombineSarifFilesDeprecationWarning when on dotcom with feature flag" , async ( t ) => {
329
+ t . true (
330
+ await uploadLib . shouldShowCombineSarifFilesDeprecationWarning (
331
+ [ createMockSarif ( "abc" , "def" ) , createMockSarif ( "abc" , "def" ) ] ,
332
+ createFeatures ( [ Feature . CombineSarifFilesDeprecationWarning ] ) ,
333
+ {
334
+ type : GitHubVariant . DOTCOM ,
335
+ } ,
336
+ ) ,
337
+ ) ;
338
+ } ) ;
339
+
340
+ test ( "shouldShowCombineSarifFilesDeprecationWarning without feature flag" , async ( t ) => {
341
+ t . false (
342
+ await uploadLib . shouldShowCombineSarifFilesDeprecationWarning (
343
+ [ createMockSarif ( "abc" , "def" ) , createMockSarif ( "abc" , "def" ) ] ,
344
+ createFeatures ( [ ] ) ,
345
+ {
346
+ type : GitHubVariant . DOTCOM ,
347
+ } ,
348
+ ) ,
349
+ ) ;
350
+ } ) ;
351
+
352
+ test ( "shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.13" , async ( t ) => {
353
+ t . false (
354
+ await uploadLib . shouldShowCombineSarifFilesDeprecationWarning (
355
+ [ createMockSarif ( "abc" , "def" ) , createMockSarif ( "abc" , "def" ) ] ,
356
+ createFeatures ( [ Feature . CombineSarifFilesDeprecationWarning ] ) ,
357
+ {
358
+ type : GitHubVariant . GHES ,
359
+ version : "3.13.2" ,
360
+ } ,
361
+ ) ,
362
+ ) ;
363
+ } ) ;
364
+
365
+ test ( "shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.14" , async ( t ) => {
366
+ t . true (
367
+ await uploadLib . shouldShowCombineSarifFilesDeprecationWarning (
368
+ [ createMockSarif ( "abc" , "def" ) , createMockSarif ( "abc" , "def" ) ] ,
369
+ createFeatures ( [ Feature . CombineSarifFilesDeprecationWarning ] ) ,
370
+ {
371
+ type : GitHubVariant . GHES ,
372
+ version : "3.14.0" ,
373
+ } ,
374
+ ) ,
375
+ ) ;
376
+ } ) ;
377
+
378
+ test ( "shouldShowCombineSarifFilesDeprecationWarning with only 1 run" , async ( t ) => {
379
+ t . false (
380
+ await uploadLib . shouldShowCombineSarifFilesDeprecationWarning (
381
+ [ createMockSarif ( "abc" , "def" ) ] ,
382
+ createFeatures ( [ Feature . CombineSarifFilesDeprecationWarning ] ) ,
383
+ {
384
+ type : GitHubVariant . DOTCOM ,
385
+ } ,
386
+ ) ,
387
+ ) ;
388
+ } ) ;
389
+
390
+ test ( "shouldShowCombineSarifFilesDeprecationWarning with distinct categories" , async ( t ) => {
391
+ t . false (
392
+ await uploadLib . shouldShowCombineSarifFilesDeprecationWarning (
393
+ [ createMockSarif ( "abc" , "def" ) , createMockSarif ( "def" , "def" ) ] ,
394
+ createFeatures ( [ Feature . CombineSarifFilesDeprecationWarning ] ) ,
395
+ {
396
+ type : GitHubVariant . DOTCOM ,
397
+ } ,
398
+ ) ,
399
+ ) ;
400
+ } ) ;
401
+
402
+ test ( "shouldShowCombineSarifFilesDeprecationWarning with distinct tools" , async ( t ) => {
403
+ t . false (
404
+ await uploadLib . shouldShowCombineSarifFilesDeprecationWarning (
405
+ [ createMockSarif ( "abc" , "abc" ) , createMockSarif ( "abc" , "def" ) ] ,
406
+ createFeatures ( [ Feature . CombineSarifFilesDeprecationWarning ] ) ,
407
+ {
408
+ type : GitHubVariant . DOTCOM ,
409
+ } ,
410
+ ) ,
411
+ ) ;
412
+ } ) ;
413
+
414
+ test ( "shouldShowCombineSarifFilesDeprecationWarning when environment variable is already set" , async ( t ) => {
415
+ process . env [ "CODEQL_MERGE_SARIF_DEPRECATION_WARNING" ] = "true" ;
416
+
417
+ t . false (
418
+ await uploadLib . shouldShowCombineSarifFilesDeprecationWarning (
419
+ [ createMockSarif ( "abc" , "def" ) , createMockSarif ( "abc" , "def" ) ] ,
420
+ createFeatures ( [ Feature . CombineSarifFilesDeprecationWarning ] ) ,
421
+ {
422
+ type : GitHubVariant . DOTCOM ,
423
+ } ,
424
+ ) ,
425
+ ) ;
426
+ } ) ;
427
+
327
428
function createMockSarif ( id ?: string , tool ?: string ) {
328
429
return {
329
430
runs : [
0 commit comments