Skip to content

Commit 3c4eba7

Browse files
committed
Refine test workflow
1 parent 13dac45 commit 3c4eba7

File tree

3 files changed

+75
-48
lines changed

3 files changed

+75
-48
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/testing.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Testing
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
paths:
8+
- "**/*.go"
9+
- "go.mod"
10+
- "go.sum"
11+
- ".github/workflows/testing.yml"
12+
pull_request:
13+
branches: [ main ]
14+
types: [ opened, synchronize, reopened ]
15+
paths:
16+
- "**/*.go"
17+
- "go.mod"
18+
- "go.sum"
19+
- ".github/workflows/testing.yml"
20+
21+
jobs:
22+
test:
23+
name: Testing
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
os: [ ubuntu-latest, macos-latest, windows-latest ]
29+
go: [ "1.13", "1.14", "1.15", "1.16" ]
30+
steps:
31+
- name: Set up Go 1.x
32+
uses: actions/setup-go@v2
33+
with:
34+
go-version: ${{ matrix.go }}
35+
36+
- name: Check out code into the Go module directory
37+
uses: actions/checkout@v2
38+
with:
39+
fetch-depth: 0
40+
41+
- name: Get dependencies
42+
run: |
43+
go get -v -t -d ./...
44+
45+
- name: Run test
46+
run: |
47+
make test
48+
make test-cover
49+
50+
- name: Upload coverage
51+
uses: actions/upload-artifact@v2
52+
with:
53+
name: coverage
54+
path: coverage.*
55+
56+
- name: Run integration test
57+
run: make test-integration

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,21 @@ fmt:
181181
test:
182182
@echo "-> Running go test"
183183
@CGO_ENABLED=1 go test -v -race -cover -coverprofile=coverage.out -covermode=atomic ./...
184+
185+
test-integration:
186+
@echo 'mode: atomic' > coverage.out
187+
@go list ./... | xargs -n1 -I{} sh -c 'CGO_ENABLED=1 go test -race -tags=integration -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list ./... | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.out || exit 255'
188+
@rm coverage.tmp
189+
190+
test-cover:
191+
@echo "-> Running go tool cover"
192+
@go tool cover -func=coverage.out
193+
@go tool cover -html=coverage.out -o coverage.html
194+
195+
bench:
196+
@echo "-> Running benchmark"
197+
@go test -v -bench .
198+
199+
profile:
200+
@echo "-> Running profile"
201+
@go test -cpuprofile cpu.prof -memprofile mem.prof -v -bench .

0 commit comments

Comments
 (0)