Add coverage (goveralls) github action #7
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | |
| echo ${returnval} | |
| if [[ ${returnval} != *FAIL* ]]; then | |
| if [ -f profile.out ]; then | |
| cat profile.out | grep -v "mode: count" >> acc.out | |
| fi | |
| else | |
| exit 1 | |
| 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) | |
| 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 |