Skip to content

Commit

Permalink
Script change
Browse files Browse the repository at this point in the history
  • Loading branch information
admin authored and admin committed Oct 8, 2023
1 parent bd68ad2 commit c1c3406
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 28 deletions.
44 changes: 17 additions & 27 deletions .github/scripts/update_badge.py
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)
2 changes: 1 addition & 1 deletion .github/workflows/mutation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install dotnet-stryker
run: dotnet tool install dotnet-stryker --tool-path /usr/local/bin
- name: Run dotnet-stryker
run: /usr/local/bin/dotnet-stryker --project "Logic.csproj" --reporter "json"
run: /usr/local/bin/dotnet-stryker --project "Logic.csproj" >> stryker_log.txt
working-directory: ./SO/Tests/UnitTests
- name: Install Python Dependencies
run: pip install PyGithub
Expand Down

0 comments on commit c1c3406

Please sign in to comment.