-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTaskfile.dist.yml
More file actions
173 lines (173 loc) · 4.42 KB
/
Copy pathTaskfile.dist.yml
File metadata and controls
173 lines (173 loc) · 4.42 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
version: '3'
tasks:
default:
cmds:
- task -l
#### INSTALL #####
install:
desc: "Install tools and setup environment for development"
cmds:
- task: install:macos
install:macos:
internal: true
platforms: [darwin]
preconditions:
- sh: command -v brew
msg: |
We use brew to install dependencies.
Check out how to install it on a page https://brew.sh/
cmds:
- task: install:brew:go
- task: install:brew:golint
- task: install:go:swag
install:brew:go:
label: "Install Go"
internal: true
preconditions:
- sh: command -v brew
msg: "Command 'brew' not found"
status:
- command -v go
cmds:
- brew install go
install:brew:golint:
label: "Install golangci-lint"
internal: true
preconditions:
- sh: command -v brew
msg: "Command 'brew' not found"
status:
- command -v golangci-lint
cmds:
- brew install golangci-lint
install:go:swag:
label: "Install swaggo/swag"
internal: true
preconditions:
- sh: command -v go
msg: "Command 'go' not found"
status:
- command -v swag
cmds:
- go install github.com/swaggo/swag/cmd/swag@latest
#### INSTALL LINUX #####
install-linux:
desc: "Install tools and setup environment for development on Linux (WSL)"
cmds:
- task: install:linux
install:linux:
internal: true
platforms: [linux]
preconditions:
- sh: command -v snap
msg: |
We use snap to install dependencies.
cmds:
- task: install:snap:go
- task: install:snap:golint
- task: install:go:swag
install:snap:go:
label: "Install Go"
internal: true
preconditions:
- sh: command -v snap
msg: "Command 'snap' not found"
status:
- command -v go
cmds:
- sudu snap install go --classic
- export PATH=$(go env GOPATH)/bin:$PATH
install:snap:golint:
label: "Install golangci-lint"
internal: true
preconditions:
- sh: command -v snap
msg: "Command 'snap' not found"
status:
- command -v golangci-lint
cmds:
- sudo snap install golangci-lint
### GIT HOOKS ###
git-hooks:install:
status:
- test -f .git/hooks/pre-push
- test -x .git/hooks/pre-push
cmds:
- cmd: echo "{{.PRE_PUSH_HOOK}}" > .git/hooks/pre-push
silent: true
- cmd: chmod u+x .git/hooks/pre-push
silent: true
- cmd: 'echo "task: [{{.TASK}}] Hooks installed successfully"'
silent: true
vars:
PRE_PUSH_HOOK: |
export PATH=$(go env GOPATH)/bin:\$PATH
task git-hooks:pre-push
git-hooks:uninstall:
status:
- test ! -f .git/hooks/pre-push
cmds:
- cmd: rm .git/hooks/pre-push
silent: true
- cmd: 'echo "task: [{{.TASK}}] Hooks uninstalled successfully"'
silent: true
git-hooks:pre-push:
desc: "task to run before push"
deps: ['gen:swag', 'lint:check', 'build:compiler', test]
cmds:
- cmd: |
(git status --porcelain | grep -e docs/swagger.json -e docs/swagger.yaml -e docs/docs.go) \
&& { echo "Uncommitted swagger files. Aborting push."; exit 1; } \
|| { exit 0; }
### Standard ###
start:
cmds:
- task: verify
- task: run
verify:
desc: "Run all verifications (check & test)"
cmds:
- task: verify:check
- task: test
test:
desc: "Run tests"
deps: ['gen:swag']
cmds:
- go test -v ./... -race
### Fine grained tasks ###
verify:check:
desc: "Run static checks (lint & build:compiler)"
deps: ['gen:swag']
cmds:
- task: lint:fix
- task: build:compiler
test:clean:
desc: "Run tests with clean cache"
cmds:
- go clean -testcache
- task: test
run:
desc: "Run application locally without performing any checks"
deps: ['gen:swag']
cmds:
- go run ./cmd/main.go
build:compiler:
desc: "Build application"
deps: ['gen:swag']
cmds:
- go build -v ./...
lint:check:
desc: "Run linter"
cmds:
- golangci-lint run -c .golangci-lint.yml {{.CLI_ARGS}}
- golangci-lint run -c .golangci-style.yml {{.CLI_ARGS}}
lint:fix:
desc: "Run linter (with --fix)"
cmds:
- task: lint:check
vars: {CLI_ARGS: '--fix'}
gen:swag:
desc: "Update swagger definitions"
run: once
cmds:
- swag init -g ./cmd/main.go -pd true