Skip to content

Commit

Permalink
update workflow to remove redundant steps
Browse files Browse the repository at this point in the history
  • Loading branch information
DI-Tony-Reed committed Oct 14, 2024
1 parent 03a1df7 commit ac51932
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions .github/workflows/update-tests-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,14 @@ jobs:
- name: Build
run: go build -v ./...

- name: Test with coverage
run: go test -coverprofile=coverage.out -v ./...

- name: Generate coverage percentage
id: coverage
run: |
go tool cover -func=coverage.out | grep total | awk '{print $3}' > coverage.txt
COVERAGE=$(cat coverage.txt | sed 's/%//')
echo "coverage=$COVERAGE" >> $GITHUB_ENV
- name: Generate Coverage Badge
- name: Run tests and generate coverage badge
id: badge
run: |
COVERAGE=$(echo ${{ env.coverage }})
go test -coverprofile=coverage.out ./...
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
echo "Coverage: $COVERAGE"
COLOR="red"
if (( $(echo "$COVERAGE < 50" | bc -l) )); then
COLOR="red"
Expand All @@ -57,7 +50,9 @@ jobs:
fi
BADGE_MARKDOWN="![Coverage](https://img.shields.io/badge/coverage-${COVERAGE}%25-${BADGE_COLOR})"
sed -i "s|^\\[!\\[Coverage\\](.*\\)|$BADGE_MARKDOWN|g" README.md
echo "Updating README.md with the new badge..."
sed -i "s|\\[!\\[Coverage\\](.*\\)|$BADGE_MARKDOWN|g" README.md
- name: Commit coverage badge
continue-on-error: true
Expand Down

0 comments on commit ac51932

Please sign in to comment.