ci: add python script to summarize github actions failure logs#10776
ci: add python script to summarize github actions failure logs#10776Vaibhav-m-patil wants to merge 1 commit into
Conversation
Signed-off-by: Vaibhav-m-patil <vaibhav.mutthe17@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a new Python script, ci_summarizer.py, to parse CI log files and generate a Markdown summary of errors and failed tests. The review feedback identifies critical improvements for robustness and pipeline integration, including handling potential UnicodeDecodeError exceptions by using errors='replace' when opening log files, and properly directing error messages to stderr with non-zero exit codes during file-not-found or incorrect usage scenarios.
| errors_found = [] | ||
|
|
||
| try: | ||
| with open(log_file_path, 'r', encoding='utf-8') as file: |
There was a problem hiding this comment.
CI logs can sometimes contain invalid UTF-8 byte sequences (e.g., from compiler warnings, binary outputs, or localized tools). Opening the file with strict UTF-8 decoding can cause the script to crash with a UnicodeDecodeError, preventing the summary from being generated.
Using errors='replace' or errors='ignore' ensures the script remains robust and processes the entire log file successfully.
| with open(log_file_path, 'r', encoding='utf-8') as file: | |
| with open(log_file_path, 'r', encoding='utf-8', errors='replace') as file: |
| except FileNotFoundError: | ||
| print(f"Error: Could not find log file at {log_file_path}") | ||
| return |
There was a problem hiding this comment.
If the log file is not found, the script prints an error message to standard output (stdout) and exits with a successful status code (0). In CI/CD environments, execution failures should be printed to standard error (stderr) and exit with a non-zero status code (e.g., 1) to properly signal the failure to the calling pipeline.
| except FileNotFoundError: | |
| print(f"Error: Could not find log file at {log_file_path}") | |
| return | |
| except FileNotFoundError: | |
| print(f"Error: Could not find log file at {log_file_path}", file=sys.stderr) | |
| sys.exit(1) |
| if len(sys.argv) < 2: | ||
| print("Usage: python3 ci_summarizer.py <path_to_log_file>") | ||
| else: | ||
| parse_ci_log(sys.argv[1]) No newline at end of file |
There was a problem hiding this comment.
When the script is invoked with incorrect arguments, it prints the usage message to standard output (stdout) and exits with a successful status code (0). CLI usage errors should be printed to standard error (stderr) and exit with a non-zero status code (e.g., 1) to prevent silent failures in pipelines.
| if len(sys.argv) < 2: | |
| print("Usage: python3 ci_summarizer.py <path_to_log_file>") | |
| else: | |
| parse_ci_log(sys.argv[1]) | |
| if len(sys.argv) < 2: | |
| print("Usage: python3 ci_summarizer.py <path_to_log_file>", file=sys.stderr) | |
| sys.exit(1) | |
| else: | |
| parse_ci_log(sys.argv[1]) |
There was a problem hiding this comment.
Welcome to OpenROAD! Thanks for opening your first PR.
Before we review:
- Contribution Guide: https://openroad.readthedocs.io/en/latest/contrib/contributing.html
- Build Instructions: https://openroad.readthedocs.io/en/latest/contrib/BuildWithCMake.html
Please ensure:
- CI passes
- Code is properly formatted
- Tests are included where applicable
A maintainer will review shortly!
Summary
Added a foundational Python script (
.github/scripts/ci_summarizer.py) to parse GitHub Actions CI logs and output a clean Markdown summary of critical errors and test failures.Type of Change
Impact
Improves the developer experience by automatically extracting
ERRORandFAIL:flags from massive raw CI logs, making it much faster to identify why a build failed.Verification
./etc/Build.sh).Related Issues
Fixes #10335