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 GitHub Actions workflow for running unit tests and coverage #2

Merged
merged 4 commits into from
Jan 27, 2025
Merged
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
30 changes: 30 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Unit Tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
name: Run Unit Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Install dependencies
run: go mod download

- name: Run Unit Tests
run: |
mkdir -p .octocov
go test -v -race ./...
12 changes: 12 additions & 0 deletions .octocov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

coverage:
paths:
- coverage.txt
display-style: table
acceptable: 70
badge:
path: docs/coverage.svg

diff:
datastores:
- local://.octocov/coverage.json
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.PHONY: test test-coverage test-race test-all

# Run all tests
test:
go test ./...

# Run tests with coverage
test-coverage:
go test -coverprofile=coverage.txt -covermode=atomic ./...
go tool cover -func=coverage.txt

# Run tests with race detection
test-race:
go test -race ./...

# Run all tests with coverage and race detection
test-all:
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
go tool cover -func=coverage.txt
Loading