Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
chrabyrd committed Apr 3, 2024
1 parent 0103f3e commit 25d267a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ jobs:
- name: Report coverage
run: |
coverage report -m > coverage_report.txt
coverage report
coverage json
- name: Upload coverage report as artifact
uses: actions/upload-artifact@v2
with:
name: coverage-report
path: coverage_report.txt
path: coverage.json

update-coverage:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -95,24 +96,23 @@ jobs:
- name: Compare coverage with baseline
if: github.event_name == 'pull_request'
run: |
cat coverage_report.txt
current_coverage=$(cat coverage.json | grep -o '"totals": {[^}]*' | grep -o '"percent_covered": [0-9.]*' | awk -F ': ' '{print $2}')
echo "$current_coverage"
current_coverage=$(cat coverage_report.txt | grep TOTAL | awk '{print int($4)}' | sed 's/%//')
baseline_coverage=$(cat .coverage_baseline)
baseline_coverage=$(printf "%.0f" "$baseline_coverage")
if [[ "$current_coverage" -lt "$baseline_coverage" ]]; then
echo "Coverage decreased from $baseline_coverage% to $current_coverage%"
exit 1
else
echo "Coverage didn't decrease. Committing new coverage.json."
coverage json
echo "$baseline_coverage% = $current_coverage%, Coverage didn't decrease. Committing new .coverage and coverage.json."
git config user.name github-actions
git config user.email [email protected]
git add coverage.json
git add .coverage
git commit -m "automatically update .coverage and coverage.json"
Expand Down

0 comments on commit 25d267a

Please sign in to comment.