ci: move coverage to separate pipeline

This commit is contained in:
Aleksandr Razumov
2020-11-01 19:06:41 +03:00
parent 65dbf4967c
commit 43cbb1ba55
4 changed files with 37 additions and 11 deletions

View File

@@ -78,6 +78,27 @@ jobs:
${{ runner.os }}-go-${{ matrix.golang }}-
- name: Run tests
run: make test
coverage:
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
runs-on: ubuntu-latest
strategy:
matrix:
golang:
- 1.15
steps:
- uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.golang }}
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: coverage-${{ runner.os }}-go-${{ matrix.golang }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
coverage-${{ runner.os }}-go-${{ matrix.golang }}-
- name: Run tests with coverage
run: make coverage
- name: Convert coverage.out to coverage.lcov
uses: jandelgado/gcov2lcov-action@v1.0.6
- name: Coveralls

View File

@@ -54,3 +54,5 @@ check-api:
@cd api && bash ./check.sh
test:
@./go.test.sh
coverage:
@./go.coverage.sh

12
go.coverage.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e
touch coverage.out
for d in $(go list ./... | grep -v vendor); do
go test -coverprofile=profile.out -covermode=atomic "$d"
if [[ -f profile.out ]]; then
cat profile.out >> coverage.out
rm profile.out
fi
done

View File

@@ -1,24 +1,15 @@
#!/usr/bin/env bash
set -e
touch coverage.txt
# test fuzz inputs
go test -tags gofuzz -run TestFuzz -v .
# quick-test without -race
go test ./...
# test with "debug" tag
go test -tags debug ./...
# test concurrency
go test -race -cpu=1,2,4 -run TestClient_DoConcurrent
for d in $(go list ./... | grep -v vendor); do
go test -race -coverprofile=profile.out -covermode=atomic "$d"
if [[ -f profile.out ]]; then
cat profile.out >> coverage.out
rm profile.out
fi
done
# test with -race
go test -race ./...