Skip to content
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

Ci logging improvement #374

Merged
merged 12 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions .github/workflows/check_compilable_percentage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,31 +98,46 @@ jobs:
$(pwd)/CI_repository_list.csv \
$(pwd)/ASHE/CI_REPO_CLONE_SPACE \
$(pwd)/ASHE/src/main/resources/config.properties

- name: Translate results
run: |
python3 ashe_scripts/specimin_get_run_results.py ASHE/logs/app.log
cat ASHE/logs/app.log
- name: Show only successful minimizations
run: |
grep 'full_success' ASHE/logs/specimin_run_results.txt
- name: Show only failed minimizations
run: |
grep 'failed_minimization' ASHE/logs/specimin_run_results.txt
- name: Show only failed compilations
run: |
grep 'failed_compilation' ASHE/logs/specimin_run_results.txt
- name: Parse accuracy percentage
id: parse_accuracy_percentage
run: |
current_accuracy=$(grep 'Fully successful from minimization to compilation' "$(pwd)/ASHE/logs/specimin_statistics.txt" | awk '{print $NF}' | tr -d '()%')
echo "Current accuracy: $current_accuracy"
echo "current_accuracy=$current_accuracy" >> $GITHUB_OUTPUT
current_run_accuracy=$(grep 'Fully successful from minimization to compilation' "$(pwd)/ASHE/logs/specimin_statistics.txt" | awk '{print $NF}' | tr -d '()%')
echo "Current run accuracy: $current_run_accuracy"
echo "current_run_accuracy=$current_run_accuracy" >> "$GITHUB_OUTPUT"

- name: Read latest run percentage from file
id: read_latest_run_percentage
id: constant_saved_run_percentage
run: |
if [ -f "$(pwd)/CI_Latest_run_percentage.txt" ]; then
latest_run_accuracy=$(cat "$(pwd)/CI_Latest_run_percentage.txt" | tr -d '()%')
echo "Latest run accuracy: $latest_run_accuracy"
echo "latest_run_accuracy=$latest_run_accuracy" >> $GITHUB_OUTPUT
if [ -f "$(pwd)/CI_constant_saved_run_percentage.txt" ]; then
constant_saved_run_percentage=$(cat "$(pwd)/CI_constant_saved_run_percentage.txt" | tr -d '()%')
echo "Constant saved run accuracy: $constant_saved_run_percentage"
echo "constant_saved_run_percentage=$constant_saved_run_percentage" >> "$GITHUB_OUTPUT"
else
echo "File CI_Latest_run_percentage.txt does not exist"
echo "File CI_constant_saved_run_percentage.txt does not exist"
exit 1
fi

- name: Validate accuracy
id: validate_accuracy
run: |
if [ "$current_accuracy" != "$latest_run_accuracy" ]; then
echo "Current accuracy ($current_accuracy) does not match latest run accuracy ($latest_run_accuracy)."
run: |
current_run_accuracy="${{ steps.parse_accuracy_percentage.outputs.current_run_accuracy }}"
constant_saved_run_percentage="${{ steps.constant_saved_run_percentage.outputs.constant_saved_run_percentage }}"

if [ "$current_run_accuracy" != "$constant_saved_run_percentage" ]; then
echo "Current accuracy ($current_run_accuracy) does not match latest run accuracy ($constant_saved_run_percentage)."
exit 1
else
echo "Accuracy validation passed."
Expand Down
1 change: 0 additions & 1 deletion CI_Latest_run_percentage.txt

This file was deleted.

1 change: 1 addition & 0 deletions CI_constant_saved_run_percentage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
89.49
64 changes: 64 additions & 0 deletions ashe_scripts/specimin_get_run_results.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import sys
import os
import re

def print_repo_specifics(file_path: str):
directory: str = os.path.dirname(file_path)
output_file_path: str = os.path.join(directory, 'specimin_run_results.txt')
with open(output_file_path, 'a') as output_file:
with open(file_path, 'r') as file:
lines: list[str] = file.readlines()

repo_name: str = ""
branch_name: str = ""
repo_branch_holder = "", ""
for line in lines:
line: str = line.strip()

repo_branch_holder = "",""
repo_branch_holder = __extract_case(line)
if repo_branch_holder != ("", ""):
repo_name = repo_branch_holder[0]
branch_name = repo_branch_holder[1]

if "Minimizing source file..." in line:
output_file.write("'new minimization attempt'\n")
if "BUILD SUCCESSFUL" in line:
output_file.write("'successful_minimization' "+repo_name + " " + branch_name + "\n")
if "BUILD FAILED" in line:
output_file.write("'failed_minimization' "+repo_name + " " + branch_name + "\n")
if "Compiling Java files" in line:
output_file.write("'compilation_attempts' "+repo_name + " " + branch_name + "\n")
if "Minimized files compiled successfully." in line:
output_file.write("'successful_compilation' "+repo_name + " " + branch_name + "\n")
output_file.write("'full_success' "+repo_name + " " + branch_name + "\n")
if "Minimized files failed to compile." in line:
output_file.write("'failed_compilation' "+repo_name + " " + branch_name + "\n")

def __extract_case(log_line: str):
"""
Extracts the java source file name and method name from a log line.

Parameters:
- log_line (str): A string from the log file containing repository and branch information.

Returns:
- tuple: A tuple containing the repository path and the branch name.
"""
# regex pattern to find the repository path and branch name
pattern = r'--targetFile "(.+?\.java)" --targetMethod "(.+?)"'
match = re.search(pattern, log_line)

if match:
targetFile = match.group(1).strip()
targetMethod = match.group(2).strip()
return targetFile, targetMethod
else:
return "", ""

if __name__ == '__main__':
if len(sys.argv) < 2:
print("Usage: python3 specimin_repo_specifics.py <path_to_log_file.log>")
sys.exit(1)
log_file_path = sys.argv[1]
print_repo_specifics(log_file_path)
Loading