Skip to content

test: add more test coverage #2

test: add more test coverage

test: add more test coverage #2

Workflow file for this run

name: Test Coverage
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:
jobs:
test:
name: Run Tests and Upload Coverage
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '^1.22'
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download dependencies
run: go mod download
- name: Run tests with coverage
run: |
go test ./... -v -coverprofile=coverage.out -coverpkg=./... -covermode=atomic
continue-on-error: false
- name: Verify coverage file exists
run: |
if [ ! -f coverage.out ]; then
echo "Error: coverage.out file not found"
exit 1
fi
echo "Coverage file size: $(wc -c < coverage.out) bytes"
- name: Generate coverage report
run: |
echo "=== Coverage Report ==="
go tool cover -func=coverage.out
echo ""
echo "=== Coverage Summary ==="
go tool cover -func=coverage.out | tail -1
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: coverage.out
format: golang
flag-name: unit-tests
parallel: false
fail-on-error: false
debug: false
allow-empty: false