Repository navigation
Expand file tree
/
Copy pathtaskfile.yaml
More file actions
218 lines (194 loc) · 5.59 KB
/
Copy pathtaskfile.yaml
File metadata and controls
218 lines (194 loc) · 5.59 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Requires
# - go
# - grep
# - pcre2grep
# - protoc
# - protoc-gen-go
# - protoc-gen-go-grpc
# - protoc-gen-grpc-gateway
# - misspell
# - gocyclo
# - mktemp
# - which
# - ineffassign
# - staticcheck
# - gofmt
# - curl
# - addlicense (github.com/google/addlicense)
version: 3
tasks:
# App tasks
protoc:
desc: "Build language protobuf files"
sources:
- ldlm.proto
generates:
- protos/ldlm_grpc.pb.go
- protos/ldlm.pb.go
- protos/ldlm.pb.gw.go
cmds:
- >
protoc -I.
--go_out=./ --go_opt=Mldlm.proto=./protos
--go-grpc_out=./ --go-grpc_opt=Mldlm.proto=./protos
--grpc-gateway_opt=Mldlm.proto=./protos
--grpc-gateway_opt grpc_api_configuration=./.api_config.yaml
--grpc-gateway_out=./
ldlm.proto
- for: ['protos/ldlm_grpc.pb.go', 'protos/ldlm.pb.go', 'protos/ldlm.pb.gw.go']
cmd: addlicense {{.ITEM}}
dist:
internal: true
cmds:
- test -d dist || mkdir dist
build:
desc: "Build artifacts"
sources:
- "**/*.go"
generates:
- dist/ldlm-server{{exeExt}}
- dist/ldlm-lock{{exeExt}}
- dist/ldlm-stress{{exeExt}}
deps: [dist, protoc]
cmds:
- for: ['server', 'lock', 'stress']
cmd: go build -o dist/ldlm-{{.ITEM}}{{exeExt}} ./cmd/{{.ITEM}}/
run:
desc: "Run server"
cmds:
- cmd: go run ./cmd/server/main.go {{.CLI_ARGS}}
test:
desc: "Run unit tests"
aliases: ["t"]
sources:
- "**/*.go"
cmds:
- go test -race -timeout 50s {{.CLI_ARGS}} ./...
clean:
desc: "Clean up build artifacts and cache"
cmds:
# Cache
- go clean -cache -testcache
# Build artifacts
- rm -rf ./dist
# Nonsense added by vscode c# extension
- rm -rf ldlm.sln examples/c#/bin examples/c#/obj
# Common tasks
check:
desc: "Run pre-build checks on files"
aliases: ["c", "checks"]
cmds:
- task: clean
- task: googlify
- go mod tidy
- task: fmt
- task: lint
- misspell ./...
- task: test
- task: clean
- find . -path "./.venv" -prune -o -type f -not -name "*.sh" -exec chmod a-x {} \;
test-clean:
desc: "Clean test cache and run tests"
aliases: ["tc"]
cmds:
- task: clean
- task: test
lint:
desc: "Run linters"
sources:
- "**/*.go"
cmds:
- go vet ./...
- ineffassign ./...
- staticcheck ./...
- gocyclo -over 14 -ignore "\\.pb\\.go$" ./.
fmt:
desc: "Format the code"
sources:
- "**/*.go"
cmds:
- gofmt -s -w ./
license:
internal: true
status:
- test -f LICENSE
cmds:
- curl -o LICENSE https://raw.githubusercontent.com/google/new-project/master/LICENSE
contributing:
internal: true
status:
- test -f CONTRIBUTING.md
cmds:
- curl -o CONTRIBUTING.md https://raw.githubusercontent.com/google/new-project/master/docs/contributing.md
readme:
internal: true
status:
- test -f README.md
cmds:
- printf '# {{.APP_NAME}}\n\n{{.LICENSE}}\n{{.CONTRIBUTING}}\n{{.DISCLAIMER}}' >>README.md
vars:
APP_NAME:
sh: "basename $PWD"
LICENSE: >
## License\n\nApache 2.0; see [`LICENSE`](LICENSE) for details.
CONTRIBUTING: >
## Contributing\n\nSee [`CONTRIBUTING.md`](CONTRIBUTING.md) for details.
DISCLAIMER: >
## Disclaimer\n\nThis project is not an official Google project. It is not supported by
Google and Google specifically disclaims all warranties as to its quality,
merchantability, or fitness for a particular purpose.\n
required_files:
desc: "Make sure required files exist"
aliases: ["rf"]
cmds:
- task: license
- task: contributing
- task: gitignore
- task: readme
license_headers:
desc: "Make sure source files have headers"
cmds:
- addlicense -check -ignore '**/.*' -ignore '.*/**' -ignore '**/.venv/**' -ignore 'docs/**' ./
add_license_headers:
desc: "Make sure source files have headers"
aliases: ["alh"]
preconditions:
- test "{{.CLI_ARGS}}" != ""
cmds:
- addlicense -ignore '**/.*' -ignore '.*/**' {{.CLI_ARGS}}
check_readme_google:
desc: "Make sure README.md has common items"
sources:
- "README.md"
cmds:
- pcre2grep -M -q '# Contributing\s*See \[`CONTRIBUTING.md`\].' README.md
- pcre2grep -M -q "# Disclaimer\s*This project is not an official Google project." README.md
- pcre2grep -M -q '# License\s*Apache 2.0.' README.md
googlify:
desc: "Make sure google checks pass"
cmds:
- task: required_files
- task: check_readme_google
- task: license_headers
gitignore:
desc: "Make sure .gitignore contains common items"
status:
- test -f ./.gitignore
- grep -E -q '^\.\*$' .gitignore
- grep -E -q '^\!/\.gitignore$' .gitignore
cmds:
- grep -E -q '^\.\*$' .gitignore || printf '.*\n' >>.gitignore
- grep -E -q '^\!/\.gitignore$' .gitignore || printf '!/.gitignore\n' >>.gitignore