Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add test coverage #96

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 48 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,61 @@
name: Test
name: test

on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, reopened, synchronize]
push:
branches:
- 'main'

permissions:
contents: write
pull-requests: write

jobs:
test:
runs-on: ubuntu-latest
full_ci:
strategy:
matrix:
go_version: [1.23.x]

runs-on: ubuntu-20.04

steps:
- name: Checkout code
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v2
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21.4

- name: Change to code directory
run: cd ${{ github.workspace }}
- name: Install gocover-cobertura
run: |
go get github.com/boumenot/gocover-cobertura && go install github.com/boumenot/gocover-cobertura

- name: Run tests
run: |
go test -v ./...
run: go test -race -coverprofile=coverage.txt ./internal/...

- name: Convert go coverage to corbetura format
run: gocover-cobertura < coverage.txt > coverage.xml

- name: Generate code coverage report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage.xml
badge: false
fail_below_min: false
format: markdown
hide_branch_rate: true
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
Loading