-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
106 lines (90 loc) · 2.54 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
version: "3"
tasks:
deps:
summary: Install dependencies
cmds:
- go mod download
- go mod tidy
format:
summary: |
Formats Go files.
Run with --watch or -w to watch for changes on Go files.
cmds:
- gofmt -s -w .
sources:
- ./**/*.go
build:
summary: |
Builds Go files.
Run with --watch or -w to watch for changes on Go files.
cmds:
- go build
sources:
- ./**/*.go
test:
summary: |
Runs unit tests with coverage
Run with --watch or -w to watch for changes on _test.go files.
cmds:
- gotestsum -- -coverprofile=coverage.out ./...
sources:
- ./**/*_test.go
coverage:
summary: Generates coverage report and opens it
deps:
- test
cmds:
- go tool cover -html=coverage.out
coverage-diff:
summary: Show coverage difference between current branch and master
cmds:
- |
gotestsum -- -coverprofile=coverage.out ./...
. scripts/exclude-from-code-coverage.sh
current_branch=$(git rev-parse --abbrev-ref HEAD)
current_line_total=$(go tool cover -func coverage.out | grep -e 'total:')
current_total_int=$(echo "$current_line_total" | grep -o '[0-9.]*')
git checkout main
gotestsum -- -coverprofile=coverage.out ./...
. scripts/exclude-from-code-coverage.sh
main_line_total=$(go tool cover -func coverage.out | grep -e 'total:')
main_total_int=$(echo "$main_line_total" | grep -o '[0-9.]*')
git checkout $current_branch
echo "branch $current_branch coverage: $current_total_int%"
echo "branch main coverage: $main_total_int%"
if ((current_total_int > main_total_int))
then
diff=$(echo "$current_total_int $main_total_int" | awk '{print $1 - $2}')
echo "difference: + $diff%"
else
diff=$(echo "$main_total_int $current_total_int" | awk '{print $1 - $2}')
echo "difference: - $diff%"
fi
silent: true
lint:
summary: |
Runs the linter
If error try `brew install golangci-lint`
cmds:
- golangci-lint run
shadow:
summary: |
Detect shadowed variables
If error try `go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest`
cmds:
- shadow ./...
check:
deps:
- format
- shadow
- lint
- build
- test
default:
deps:
- build
integration-test:
summary: |
Runs integration tests
cmds:
- go test --tags=integration ./...