-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskfile.yaml
More file actions
209 lines (184 loc) · 5.23 KB
/
taskfile.yaml
File metadata and controls
209 lines (184 loc) · 5.23 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
# 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
# - grep
# - pcre2grep
# - which
# - curl
# - addlicense (github.com/google/addlicense)
version: 3
dotenv: ['.env']
tasks:
# App tasks
build:
desc: "Build packages"
sources:
- '**/*.py'
- '*py'
generates:
- 'dist/py_ldlm-*.whl'
- 'dist/py_ldlm-*.tar.gz'
cmds:
- rm -rf dist
- python -m build
publish:
desc: "Publish packages to PyPI"
preconditions:
- test "${TWINE_PASSWORD}" != ""
cmds:
- task: build
- python3 -m twine upload dist/*
protoc:
desc: "Build language protobuf files"
sources:
- ldlm.proto
generates:
- ldlm/protos/ldlm_pb2_grpc.py
- ldlm/protos/ldlm_pb2.py
cmds:
- python3 -m grpc_tools.protoc -I. --python_out=ldlm/protos --pyi_out=ldlm/protos --grpc_python_out=ldlm/protos ldlm.proto
- 2to3 -w -n ldlm/protos/*py
- addlicense ldlm/protos/*
test:
desc: "Run unit tests"
aliases: ["t"]
sources:
- "**/*.py"
cmds:
- pytest tests
coverage:
desc: "Generate coverage"
aliases: ["cov"]
sources:
- "**/*.py"
generates:
- "coverage.lcov"
cmds:
- coverage run -m pytest tests
- coverage lcov
- coverage report
clean:
desc: "Clean up build artifacts and cache"
cmds:
# Cache
- find . -name "*pyc" -delete
- rm -rf .pytest_cache
# build artifacts
- rm -rf dist
# Common tasks
check:
desc: "Run pre-build checks on files"
aliases: ["c", "checks"]
cmds:
- task: clean
- task: googlify
- task: fmt
- task: lint
- task: test
- task: clean
- find . -type f -not -name "*.sh" -not -path "./.venv/*" -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:
- '**/*py'
- '*py'
cmds:
- pylint --prefer-stubs=true ldlm
- mypy ldlm
fmt:
desc: "Format the code"
sources:
- "**/*.py"
cmds:
- find . -name "*py" -not -path "./.venv/*" -not -path "./ldlm/protos/*" -exec yapf -i --style google {} \;
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"
internal: true
cmds:
- task: license
- task: contributing
- task: gitignore
- task: readme
license_headers:
desc: "Make sure source files have headers"
cmds:
- addlicense -check -ignore '**/.*' -ignore '.*/**' -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"
internal: true
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"
internal: true
cmds:
- task: required_files
- task: check_readme_google
- task: license_headers
gitignore:
desc: "Make sure .gitignore contains common items"
internal: true
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