-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathTaskfile.yml
More file actions
151 lines (132 loc) · 2.91 KB
/
Taskfile.yml
File metadata and controls
151 lines (132 loc) · 2.91 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
version: "3"
vars:
COVERAGE_FILE: coverage.out
tasks:
default:
desc: Show available tasks
cmds:
- task --list-all
# Testing
test:
desc: Run all tests (root + gen)
cmds:
- task: test:main
- task: test:gen
test:main:
desc: Run root module tests
sources:
- "**/*.go"
- go.mod
- go.sum
- exclude: gen/**
- exclude: _examples/**
cmds:
- go test -race ./...
test:gen:
desc: Run gen module tests
dir: gen
sources:
- "**/*.go"
- go.mod
- go.sum
cmds:
- go test -race ./...
# Linting (always with --fix)
lint:
desc: Lint all modules
cmds:
- task: lint:main
- task: lint:gen
- task: lint:examples
lint:main:
desc: Lint root module
sources:
- "**/*.go"
- go.mod
- go.sum
- .golangci.yml
- exclude: gen/**
- exclude: _examples/**
cmds:
- golangci-lint run --fix ./...
lint:gen:
desc: Lint gen module
dir: gen
sources:
- "**/*.go"
- go.mod
- go.sum
- .golangci.yml
cmds:
- golangci-lint run --fix ./...
# Tidy
tidy:
desc: Run go mod tidy on all modules
cmds:
- task: tidy:main
- task: tidy:gen
tidy:main:
desc: Run go mod tidy on root module
cmds:
- go mod tidy
tidy:gen:
desc: Run go mod tidy on gen module
dir: gen
cmds:
- go mod tidy
tidy:check:
desc: Check if go.mod files are tidy
cmds:
- task: tidy
- git diff --exit-code go.mod go.sum gen/go.mod gen/go.sum
# Coverage
coverage:
desc: Run tests with coverage
cmds:
- go test -v -race -coverprofile={{.COVERAGE_FILE}} -covermode=atomic ./...
coverage:html:
desc: Generate HTML coverage report
cmds:
- task: coverage
- go tool cover -html={{.COVERAGE_FILE}} -o coverage.html
- open coverage.html || xdg-open coverage.html || echo "Open coverage.html manually"
# Examples
lint:examples:
desc: Lint examples
sources:
- "**/*.go"
- exclude: gen/**
cmds:
- golangci-lint run --fix ./_examples/*/
# CI
ci:
desc: Run all CI checks locally
cmds:
- task: lint
- task: tidy:check
- task: test
# Generation
gen:
desc: Download spec and generate all code
cmds:
- task: gen:fetch
- task: gen:run
gen:fetch:
desc: Download Telegram Bot API spec
cmds:
- mkdir -p _spec
- curl -sL https://core.telegram.org/bots/api -o _spec/api.html
- sed -i.bak '$d' _spec/api.html && rm _spec/api.html.bak
gen:run:
desc: Run code generator
dir: gen
cmd: >-
go run ./cmd/go-tg-gen
-input ../_spec/api.html
-config config.yaml
-pkg tg
-types-output ../types_gen.go
-methods-output ../methods_gen.go
-tgb-output ../tgb
-spec-output ../_spec/api.yaml
-readme ../README.md