Repository navigation
Stream pull request diffs to disk, and prune CI's uploaded runs [] #466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
+467
−94
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,58 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # Part of the EDG Compiler Project, under the Apache License v2.0 with LLVM | ||
| # Exceptions. | ||
| # See https://edgcpp.org/LICENSE.txt for license information. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| '''Prune a test run down to what a review of it reads, e.g., before CI | ||
| uploads the run: | ||
|
|
||
| edg-prune-test-run tests/runs/<run timestamp> | ||
|
|
||
| Reviews of a run read only the .rt.tar files its changes.elist files name. | ||
| The replays directory is removed whole. In each configuration, a suite | ||
| with no test named there is removed whole (its directory, and its | ||
| suite-<name> logs), as is every suite of a configuration without a | ||
| changes.elist; of the other suites, the .rt.tar files not named there are | ||
| removed. | ||
| ''' | ||
|
|
||
| import argparse | ||
| import sys | ||
|
|
||
| import edgtest | ||
| import edgutil | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| def _parse_args() -> argparse.Namespace: | ||
| parser = argparse.ArgumentParser( | ||
| description = ( | ||
| "Remove the .rt.tar files of a test run that no configuration's " | ||
| 'changes.elist names.' | ||
| ) | ||
| ) | ||
| parser.add_argument( | ||
| 'run_dir', | ||
| type = Path, | ||
| help = 'the run directory (e.g., tests/runs/<run timestamp>)' | ||
| ) | ||
| return parser.parse_args() | ||
|
|
||
| def main() -> int: | ||
| args = _parse_args() | ||
| if not args.run_dir.is_dir(): | ||
| edgutil.eprint(f"error: {args.run_dir} is not a directory") | ||
| return 1 | ||
|
|
||
| # Counts: of .rt.tar files kept and removed, and of suites removed. | ||
| kept, removed, suites = edgtest.prune_run_archives(args.run_dir) | ||
| print( | ||
| f"Kept {kept} .rt.tar files named by changes.elist files; removed " | ||
| f"{removed} others, and {suites} suites with no changes." | ||
| ) | ||
| return 0 | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit(main()) |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: edgcpp/compiler
Length of output: 27063
Script executed:
Repository: edgcpp/compiler
Length of output: 26648
Script executed:
Repository: edgcpp/compiler
Length of output: 28386
Script executed:
Repository: edgcpp/compiler
Length of output: 3244
Bound diff-line reads before deriving sparse patterns.
Text-mode iteration reads a complete line before it yields it. A diff line near the 512 MiB limit can therefore be held in memory at once, and
changes_patternsmay create another large string withrstrip. With two concurrent pull requests, this can exhaust the service container's memory.Use a bounded iterator that keeps the header or relevant prefix and discards the rest of an overlong line. Apply the same bound in
build_diff_files; that path also reads complete lines before writing them to temporary files.Suggested fix
ast-grep (0.51.1)
[warning] 424-424: File path is request-/variable-derived; validate and normalize to prevent path traversal.
Context: open(diff_file, encoding = 'utf-8')
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
(open-filename-from-request)