-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
admin
authored and
admin
committed
Oct 8, 2023
1 parent
bd68ad2
commit c1c3406
Showing
2 changed files
with
18 additions
and
28 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,30 +1,20 @@ | ||
import glob | ||
import json | ||
import os | ||
import re | ||
|
||
# Search for mutation-report.json in directories under a specific path | ||
report_files = glob.glob('/home/runner/work/SO/SO/SO/Tests/UnitTests/StrykerOutput/*/reports/mutation-report.json') | ||
# Retrieve mutation score from environment variable | ||
mutation_score = os.environ.get("MUTATION_SCORE", "N/A") | ||
|
||
if report_files: | ||
# Take the first (or latest, depending on your criteria) report found | ||
report_file = report_files[0] | ||
|
||
with open(report_file, 'r') as f: | ||
data = json.load(f) | ||
|
||
mutation_score = data.get('mutationScore', None) | ||
|
||
# Read README file | ||
with open('/home/runner/work/SO/SO/README.md', 'r') as readme_file: | ||
readme_content = readme_file.read() | ||
|
||
# Update badge using a regular expression to match the old badge | ||
updated_readme_content = re.sub( | ||
r'!\[Mutation Score\]\(https://img\.shields\.io/badge/Mutation%20Score-[0-9.]+%-blue\)', | ||
f'![Mutation Score](https://img.shields.io/badge/Mutation%20Score-{mutation_score}%25-blue)', | ||
readme_content | ||
) | ||
|
||
# Write back updated content to README | ||
with open('/home/runner/work/SO/SO/README.md', 'w') as readme_file: | ||
readme_file.write(updated_readme_content) | ||
# Read README file | ||
with open('/path/to/README.md', 'r') as readme_file: | ||
readme_content = readme_file.read() | ||
|
||
# Update badge using a regular expression to match the old badge | ||
updated_readme_content = re.sub( | ||
r'!\[Mutation Score\]\(https://img\.shields\.io/badge/Mutation%20Score-[0-9.]+%-blue\)', | ||
f'![Mutation Score](https://img.shields.io/badge/Mutation%20Score-{mutation_score}%25-blue)', | ||
readme_content | ||
) | ||
|
||
# Write back updated content to README | ||
with open('/path/to/README.md', 'w') as readme_file: | ||
readme_file.write(updated_readme_content) |
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