Skip to content

Add coverage (goveralls) github action #9

Add coverage (goveralls) github action

Add coverage (goveralls) github action #9

Workflow file for this run

on:
push:
branches:
- master
pull_request:
name: Coverage
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.25.x'
- name: Checkout code
uses: actions/checkout@v4
- name: Generate coverage
run: |
# Generate unit test coverage
echo "mode: count" > acc.out
for Dir in . $(find ./* -maxdepth 10 -type d | grep -v vendor); do
if ls $Dir/*.go &> /dev/null; then
returnval=$(go test -coverprofile=profile.out -covermode=count $Dir 2>&1) || true
echo ${returnval}
if [[ ${returnval} != *FAIL* ]] && [[ ${returnval} != *"no test files"* ]]; then
if [ -f profile.out ]; then
cat profile.out | grep -v "mode: count" >> acc.out
fi
fi
fi
done
# Collect integration test coverage
echo "mode: count" > integration-acc.out
INTPACKS=$(go list ./... | grep -v vendor | grep -v utils | grep -v 'store/test' | grep -v docs | xargs | sed 's/ /,/g')
returnval=$(go test -coverpkg=$INTPACKS -coverprofile=profile.out -covermode=count ./test 2>&1) || true
if [[ ${returnval} != *FAIL* ]]; then
if [ -f profile.out ]; then
cat profile.out | grep -v "mode: count" >> integration-acc.out
fi
fi
# Merge coverage files using the project's merge script
cat acc.out integration-acc.out | go run scripts/merge-coverprofile.go > profile.cov
rm -rf ./profile.out ./acc.out ./integration-acc.out
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov