-
Notifications
You must be signed in to change notification settings - Fork 134
60 lines (53 loc) · 1.85 KB
/
coverage.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
name: coverage
on:
push:
branches:
- "main"
pull_request:
jobs:
coverage:
strategy:
matrix:
os: [ubuntu-latest] # TODO: add macos & windows
services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ^1
- name: Test
run: |
# We collect coverage data from two sources,
# 1) unit tests 2) integration tests
#
# https://go.dev/testing/coverage/
# https://dustinspecker.com/posts/go-combined-unit-integration-code-coverage/
# https://github.com/golang/go/issues/51430#issuecomment-1344711300
mkdir -p coverage/unit
mkdir -p coverage/int
mkdir -p coverage/int2
# Collect unit tests coverage
go test -failfast -race -timeout 5m -skip=^TestScript -cover ./... -args -test.gocoverdir=$PWD/coverage/unit
# Collect integration tests coverage
GOCOVERDIR=$PWD/coverage/int go test -failfast -race -timeout 5m -run=^TestScript ./...
SOFT_SERVE_DB_DRIVER=postgres \
SOFT_SERVE_DB_DATA_SOURCE=postgres://postgres:postgres@localhost/postgres?sslmode=disable \
GOCOVERDIR=$PWD/coverage/int2 go test -failfast -race -timeout 5m -run=^TestScript ./...
# Convert coverage data to legacy textfmt format to upload
go tool covdata textfmt -i=coverage/unit,coverage/int,coverage/int2 -o=coverage.txt
- uses: codecov/codecov-action@v4
with:
file: ./coverage.txt