-
Notifications
You must be signed in to change notification settings - Fork 43
60 lines (53 loc) · 1.7 KB
/
test.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: Unit Tests
on:
pull_request:
paths-ignore:
- "*.md"
push:
paths-ignore:
- '*.md'
branches:
- main
- develop
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Run unit tests
run: |
go test -v -coverprofile=coverage.txt -covermode=atomic -coverpkg=./... $(go list ./...)
- name: filter non-testable files
run: |
excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
excludelist+=" $(find ./ -type f -name '*.pb.go')"
excludelist+=" $(find ./ -type f -name '*.pb.gw.go')"
excludelist+=" $(find ./app -type d)"
excludelist+=" $(find ./cmd -type d)"
excludelist+=" $(find ./docs -type d)"
excludelist+=" $(find ./localnet -type d)"
excludelist+=" $(find ./proto -type d)"
excludelist+=" $(find ./scripts -type d)"
for filename in ${excludelist}; do
filename=${filename#".//"}
echo "Excluding ${filename} from coverage report..."
filename=$(echo "$filename" | sed 's/\//\\\//g')
sed -i.bak "/""$filename""/d" coverage.txt
done
- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
file: ./coverage.txt
fail_ci_if_error: true
verbose: true