File tree Expand file tree Collapse file tree 2 files changed +35
-6
lines changed
Expand file tree Collapse file tree 2 files changed +35
-6
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ import { setupCppAutobuild } from "./autobuild";
1212import { CodeQL , getCodeQL } from "./codeql" ;
1313import * as configUtils from "./config-utils" ;
1414import { addDiagnostic , makeDiagnostic } from "./diagnostics" ;
15+ import {
16+ DiffThunkRange ,
17+ writeDiffRangesJsonFile ,
18+ } from "./diff-filtering-utils" ;
1519import { EnvVar } from "./environment" ;
1620import { FeatureEnablement , Feature } from "./feature-flags" ;
1721import { isScannedLanguage , Language } from "./languages" ;
@@ -284,12 +288,6 @@ export async function setupDiffInformedQueryRun(
284288 ) ;
285289}
286290
287- interface DiffThunkRange {
288- path : string ;
289- startLine : number ;
290- endLine : number ;
291- }
292-
293291/**
294292 * Return the file line ranges that were added or modified in the pull request.
295293 *
@@ -537,6 +535,10 @@ extensions:
537535 `Wrote pr-diff-range extension pack to ${ extensionFilePath } :\n${ extensionContents } ` ,
538536 ) ;
539537
538+ // Write the diff ranges to a JSON file, for action-side alert filtering by the
539+ // upload-lib module.
540+ writeDiffRangesJsonFile ( logger , ranges ) ;
541+
540542 return diffRangeDir ;
541543}
542544
Original file line number Diff line number Diff line change 1+ import * as fs from "fs" ;
2+ import * as path from "path" ;
3+
4+ import * as actionsUtil from "./actions-util" ;
5+ import { Logger } from "./logging" ;
6+
7+ export interface DiffThunkRange {
8+ path : string ;
9+ startLine : number ;
10+ endLine : number ;
11+ }
12+
13+ function getDiffRangesJsonFilePath ( ) : string {
14+ return path . join ( actionsUtil . getTemporaryDirectory ( ) , "pr-diff-range.json" ) ;
15+ }
16+
17+ export function writeDiffRangesJsonFile (
18+ logger : Logger ,
19+ ranges : DiffThunkRange [ ] ,
20+ ) : void {
21+ const jsonContents = JSON . stringify ( ranges , null , 2 ) ;
22+ const jsonFilePath = getDiffRangesJsonFilePath ( ) ;
23+ fs . writeFileSync ( jsonFilePath , jsonContents ) ;
24+ logger . debug (
25+ `Wrote pr-diff-range JSON file to ${ jsonFilePath } :\n${ jsonContents } ` ,
26+ ) ;
27+ }
You can’t perform that action at this time.
0 commit comments