Skip to content

Commit

Permalink
Add coverage badge (#1)
Browse files Browse the repository at this point in the history
* Add coverage badge

* Fix coverage badge action

* Fix coverage badge action

* Fix coverage badge action

* Fix coverage badge action

* Fix coverage badge action

* chore: Updated coverage badge.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
iamelevich and github-actions[bot] authored Jan 18, 2023
1 parent eef900b commit 2133247
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 25 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/coverage-badge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Test

on:
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
name: Update coverage badge
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- 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@v12
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 "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
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:
branch: ${{ github.head_ref }}
25 changes: 0 additions & 25 deletions .github/workflows/go.yml

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

![Coverage](https://img.shields.io/badge/Coverage-58.8%25-yellow)
<!-- TOC -->
* [Overview](#overview)
* [Requirements](#requirements)
Expand Down

0 comments on commit 2133247

Please sign in to comment.