Add coverage (goveralls) github action #3
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
| name: Coveralls | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| jobs: | |
| coveralls: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24.x' | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Coveralls needs full git history | |
| - name: Install goveralls | |
| run: go install github.com/mattn/goveralls@latest | |
| - name: Generate coverage | |
| run: | | |
| chmod +x scripts/project-code-coverage.sh | |
| # Generate coverage files | |
| 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 | |
| else | |
| exit 1 | |
| fi | |
| # Merge coverage files | |
| cat acc.out integration-acc.out | go run scripts/merge-coverprofile.go > merged.out | |
| rm -rf ./profile.out ./acc.out ./integration-acc.out | |
| - name: Upload to Coveralls | |
| run: | | |
| goveralls -service github -coverprofile=merged.out -repotoken ${{ secrets.COVERALLS_REPO_TOKEN }} | |
| env: | |
| GIT_BRANCH: ${{ github.head_ref || github.ref_name }} | |
| if: always() | |
| continue-on-error: true | |