-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
119 lines (101 loc) · 2.46 KB
/
Taskfile.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# https://taskfile.dev/
version: "3"
env:
TEST_COVERAGE_THRESHOLD: 91
tasks:
clean:
desc: Clean
cmds:
- go clean
build:
desc: Build
cmds:
- go build
lint:install:
desc: Install linters
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- go install honnef.co/go/tools/cmd/staticcheck@latest
lint:
desc: Lint the project
deps:
- lint:install
cmds:
- golangci-lint run
- staticcheck ./...
test:clean:
desc: Clean test cache
cmds:
- go clean -testcache
- rm -f coverage.out
test:
desc: Run tests with verbose flag
deps:
- test:clean
cmds:
- go test ./...
test:codecov:
desc: Run tests for codecov reporting
cmds:
- go test -v ./... -coverprofile=coverage.txt
test:verbose:
desc: Run tests
deps:
- test:clean
cmds:
- go test -v ./... -coverprofile=coverage.out
test:race:
desc: Run tests with race flag
deps:
- test:clean
cmds:
- go test -race ./...
test:cover:
desc: Run tests with coverage
cmds:
- go test ./... -cover
test:coverprofile:
desc: Run tests with coverage profile
cmds:
- go test ./... -coverprofile=coverage.out
- go tool cover -func coverage.out
test:cover:check:
desc: Check test coverage
deps:
- test:coverprofile
cmds:
- |
echo "Checking test coverage is above threshold ..."
echo "Threshold : $TEST_COVERAGE_THRESHOLD %"
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "Current test coverage : $totalCoverage %"
if (( $(echo "$totalCoverage $TEST_COVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
echo "OK"
else
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
echo "Failed"
exit 1
fi
test:cover:report:
desc: Show coverage
deps:
- test:coverprofile
cmds:
- go tool cover -html=coverage.out
docs:install:
desc: Install godoc
cmds:
- go install golang.org/x/tools/cmd/godoc@latest
docs:start:
desc: Start docs server
deps:
- docs:install
cmds:
- godoc -http :8080
ci:
desc: Run CI
cmds:
- task: build
- task: lint
- task: test:race
- task: test:cover:check