Removed sudo for github actions #2
This file contains hidden or 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
| name: Coverage | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| coverage: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Install dependencies | |
| run: sudo apt-get install -y make gcc gcov | |
| - name: Run coverage and capture percentage | |
| id: runcov | |
| run: | | |
| cd Lab1 | |
| make coverage | |
| PCT=$(grep 'Lines executed' coverage_checksum.txt | head -1 | sed -E 's/.*:([0-9.]+)%.*$/\1/') | |
| echo "coverage=$PCT" >> $GITHUB_OUTPUT | |
| - name: Update README badge | |
| if: success() | |
| run: | | |
| cd Lab1 | |
| PCT=$(grep 'Lines executed' coverage_checksum.txt | head -1 | sed -E 's/.*:([0-9.]+)%.*$/\1/') | |
| cd ../../ | |
| sed -i 's/badge\/coverage-[0-9]\+\.?[0-9]*%25/badge\/coverage-'"$PCT"'%25/' README.md | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add README.md | |
| git commit -m "Update coverage badge to $PCT%" || echo "No changes to commit" | |
| git push |