forked from reviewpad/reviewpad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
137 lines (116 loc) · 3.42 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Copyright (C) 2022 Explore.dev, Unipessoal Lda - All Rights Reserved
# Use of this source code is governed by a license that can be
# found in the LICENSE file
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:
deps:
- build-cli
- build-aladino-parser
summary: |
Builds Go files.
Run with --watch or -w to watch for changes on Go files.
cmds:
- go build
sources:
- ./**/*.go
build-aladino-parser:
summary: |
Generates Aladino parser written in Go.
Run with --watch or -w to watch for changes on yacc file.
cmds:
# For debug purposes, remove the -l argument enabling the line directives in parser.go.
- goyacc -l -o lang/aladino/parser.go -p Aladino lang/aladino/parser.y
sources:
- lang/aladino/parser.y
generates:
- lang/aladino/parser.go
build-cli:
summary: |
Builds commands.
Run with --watch or -w to watch for changes on Go files.
cmds:
- go build -o reviewpad-cli ./cli/main.go
sources:
- ./cli/**/*.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 ./...
- . scripts/exclude-from-code-coverage.sh
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 ./...