diff --git a/.github/workflows/stryker.yaml b/.github/workflows/stryker.yaml index 0911376d..9c632b82 100644 --- a/.github/workflows/stryker.yaml +++ b/.github/workflows/stryker.yaml @@ -7,10 +7,10 @@ on: branches: - main -permissions: - contents: read - pull-requests: write - repository-projects: write +# permissions: +# contents: read +# pull-requests: write +# repository-projects: write jobs: stryker-js: diff --git a/script/generate_md_report.py b/script/generate_md_report.py index 5e82c6b5..43ae9b20 100644 --- a/script/generate_md_report.py +++ b/script/generate_md_report.py @@ -1,10 +1,10 @@ +"""Generate MD report based on a json report""" import json import os import sys from collections import defaultdict from urllib.parse import quote - def load_json_file(file_path: str) -> dict: """Load JSON data from a file.""" with open(file_path, "r", encoding="utf-8") as file: @@ -12,6 +12,7 @@ def load_json_file(file_path: str) -> dict: def count_mutation_statuses(report: dict) -> dict: + """Count the mutation statuses""" status_counts = {} total_counts: int = defaultdict(int) @@ -43,18 +44,16 @@ def count_mutation_statuses(report: dict) -> dict: } # Calculate overall totals - total_killed = total_counts["Killed"] - total_survived = total_counts["Survived"] - total_timeout = total_counts["Timeout"] - total_relevant = total_killed + total_survived + total_timeout + total_counts["Timeout"] = total_counts["Timeout"] + total_relevant = total_counts["Killed"] + total_counts["Survived"] + total_counts["Timeout"] - total_score = (total_killed / total_relevant * 100) if total_relevant > 0 else 0 + total_score = (total_counts["Killed"] / total_relevant * 100) if total_relevant > 0 else 0 status_counts["All"] = { "score": total_score, - "killed": total_killed, - "timeout": total_timeout, - "survived": total_survived, + "killed": total_counts["Killed"], + "timeout": total_counts["Timeout"], + "survived": total_counts["Survived"], "no_cov": total_counts["NoCoverage"], "errors": total_counts["CompileError"], "file_name": None, # No link for the total row @@ -63,7 +62,7 @@ def count_mutation_statuses(report: dict) -> dict: return status_counts -def generate_markdown_report(status_counts: dict, base_url: str) -> str: +def generate_markdown_report(status_counts: dict, url: str) -> str: """Generate a Markdown report summarizing mutation status counts per file.""" markdown = "# Stryker report for changed files\n\n" @@ -77,7 +76,7 @@ def generate_markdown_report(status_counts: dict, base_url: str) -> str: # Remove 'src/' from the file path and create # a URL link to the mutation report relative_path = counts["file_name"].replace("src/", "") - link = f"{base_url}#mutant/{quote(relative_path)}" + link = f"{url}#mutant/{quote(relative_path)}" file_link = f"[{file_name}]({link})" else: file_link = file_name @@ -97,19 +96,19 @@ def save_markdown_file(markdown: str, output_path: str) -> None: print(f"Markdown report generated at {output_path}") -def main(input_file: str, output_file: str, base_url: str): +def main(file: str, out_file: str, url: str): """Main function to process the mutation report and generate a summary.""" # Load the JSON data - mutation_report = load_json_file(input_file) + mutation_report = load_json_file(file) # Count the mutation statuses per file and calculate scores status_counts = count_mutation_statuses(mutation_report) # Generate the Markdown report - markdown_report = generate_markdown_report(status_counts, base_url) + markdown_report = generate_markdown_report(status_counts, url) # Save the Markdown report to a file - save_markdown_file(markdown_report, output_file) + save_markdown_file(markdown_report, out_file) if __name__ == "__main__":