-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2765 from github/cklin/alert-diff-filtering
Perform consistent diff-informed alert filtering in the action
- Loading branch information
Showing
11 changed files
with
218 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
|
||
import * as actionsUtil from "./actions-util"; | ||
import { Logger } from "./logging"; | ||
|
||
export interface DiffThunkRange { | ||
path: string; | ||
startLine: number; | ||
endLine: number; | ||
} | ||
|
||
function getDiffRangesJsonFilePath(): string { | ||
return path.join(actionsUtil.getTemporaryDirectory(), "pr-diff-range.json"); | ||
} | ||
|
||
export function writeDiffRangesJsonFile( | ||
logger: Logger, | ||
ranges: DiffThunkRange[], | ||
): void { | ||
const jsonContents = JSON.stringify(ranges, null, 2); | ||
const jsonFilePath = getDiffRangesJsonFilePath(); | ||
fs.writeFileSync(jsonFilePath, jsonContents); | ||
logger.debug( | ||
`Wrote pr-diff-range JSON file to ${jsonFilePath}:\n${jsonContents}`, | ||
); | ||
} | ||
|
||
export function readDiffRangesJsonFile( | ||
logger: Logger, | ||
): DiffThunkRange[] | undefined { | ||
const jsonFilePath = getDiffRangesJsonFilePath(); | ||
if (!fs.existsSync(jsonFilePath)) { | ||
logger.debug(`Diff ranges JSON file does not exist at ${jsonFilePath}`); | ||
return undefined; | ||
} | ||
const jsonContents = fs.readFileSync(jsonFilePath, "utf8"); | ||
logger.debug( | ||
`Read pr-diff-range JSON file from ${jsonFilePath}:\n${jsonContents}`, | ||
); | ||
return JSON.parse(jsonContents) as DiffThunkRange[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters