Skip to content

Commit

Permalink
Merge 53b4bd9 into c3605f9
Browse files Browse the repository at this point in the history
  • Loading branch information
sergerad authored Nov 22, 2023
2 parents c3605f9 + 53b4bd9 commit 4193f5e
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Generate code coverage badge

on:
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
name: Update coverage badge
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.

- name: Setup go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'

- name: Run Test
run: |
go test -v ./... -covermode=count -coverprofile=coverage.out
go tool cover -func=coverage.out -o=coverage.out
- name: Go Coverage Badge # Pass the `coverage.out` output to this action
uses: tj-actions/coverage-badge-go@v2
with:
filename: coverage.out

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v16
id: verify-changed-files
with:
files: README.md

- name: Commit changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "chore: Updated coverage badge."
- name: Push changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ github.token }}
branch: ${{ github.head_ref }}

0 comments on commit 4193f5e

Please sign in to comment.