-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (51 loc) · 1.96 KB
/
go-test-report.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: GoTestReport
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions: read-all
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:latest
env:
MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_TEST_DB_PASSWORD }}
MYSQL_DATABASE: ${{ secrets.MYSQL_TEST_DB_NAME }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_TEST_DB_PASSWORD }}
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Wait for MySQL to start
run: |
echo "Waiting for MySQL to start..."
until mysql -h${{ secrets.MYSQL_TEST_DB_HOST }} -uroot -p${{ secrets.MYSQL_TEST_DB_PASSWORD }} -e 'SHOW DATABASES'; do
sleep 1
done
- name: Create coverage directory
run: mkdir -p coverage
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Install gocov and gocover-cobertura
run: |
go install github.com/axw/gocov/gocov@latest
go install github.com/t-yuki/gocover-cobertura@latest
- name: Run tests
run: |
go get -v -t -d ./...
go test -race ./app/src/tests/... -count=1 -p 1 -covermode=atomic -coverprofile=coverage/coverage.out
- name: Convert coverage
run: gocov convert coverage/coverage.out | gocov report 2>&1
- name: Generate coverage report
run: |
go tool cover -html coverage/coverage.out -o coverage/coverage.html
gocover-cobertura < coverage/coverage.out > coverage/coverage.xml