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

chore: add test coverage and coverage report to the README #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
55 changes: 55 additions & 0 deletions .github/workflows/coverage_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Coverage Report

on:
workflow_run:
workflows: ["Test lint and build"]
branches: [main]
types:
- completed

jobs:

workflow:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- uses: extractions/setup-just@v1

- name: Test
run: |
just test-ci
go tool cover -func=coverage.out -o=coverage.out

- name: Go Coverage Badge
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
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 }}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go
name: Test lint and build

on:
push:
Expand All @@ -10,7 +7,6 @@ on:
branches: [ "main" ]

jobs:

workflow:
runs-on: ubuntu-latest
steps:
Expand All @@ -24,14 +20,14 @@ jobs:

- uses: extractions/setup-just@v1

- name: Test
run: just test

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.57.2
args: --out-format=colored-line-number -v ./...

- name: Test
run: just test-ci

- name: Build
run: go build -v ./...
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
coverage.out

playground/
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ test:
test-all:
go test -tags=integration ./...

# run test generating coverage
test-ci:
go test -v ./... -covermode=count -coverprofile=coverage.out

# lint the code
lint:
golangci-lint run -v ./...
Expand Down