-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
378 lines (338 loc) Β· 11.8 KB
/
Taskfile.yml
File metadata and controls
378 lines (338 loc) Β· 11.8 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
version: '3'
vars:
PYTHON: '{{.PYTHON | default "python3"}}'
VENV_PYTHON: '{{.VENV_DIR | default ".venv"}}/bin/python'
VENV_DIR: '{{.VENV_DIR | default ".venv"}}'
SOURCE_DIR: 'src'
TEST_DIR: 'src/test'
tasks:
default:
desc: Show available tasks
cmds:
- task --list
# Environment setup
install:
desc: Install dependencies and setup development environment
deps: [_ensure-venv]
cmds:
- echo "π¦ Installing dependencies..."
- '{{.VENV_DIR}}/bin/pip install -e .[dev]'
- |
# Fix missing google/__init__.py file (common protobuf installation issue)
PYTHON_VERSION=$({{.VENV_DIR}}/bin/python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
GOOGLE_PKG_DIR="{{.VENV_DIR}}/lib/python${PYTHON_VERSION}/site-packages/google"
if [ -d "$GOOGLE_PKG_DIR" ] && [ ! -f "$GOOGLE_PKG_DIR/__init__.py" ]; then
echo "Creating missing google/__init__.py file..."
touch "$GOOGLE_PKG_DIR/__init__.py" 2>/dev/null || true
fi
- echo "β
Dependencies installed successfully"
_ensure-venv:
desc: Ensure virtual environment exists
status:
- test -d {{.VENV_DIR}}
cmds:
- echo "π Creating virtual environment..."
- '{{.PYTHON}} -m venv {{.VENV_DIR}}'
- '{{.VENV_DIR}}/bin/pip install --upgrade pip setuptools wheel'
# Cleanup tasks
clean:
desc: Clean build artifacts, cache, and temporary files
cmds:
- echo "π§Ή Cleaning build artifacts..."
- rm -rf build/ dist/ *.egg-info/
- rm -rf .pytest_cache/ .coverage htmlcov/
- rm -rf {{.SOURCE_DIR}}/**/__pycache__/ {{.TEST_DIR}}/**/__pycache__/
- find . -name "*.pyc" -delete
- find . -name "*.pyo" -delete
- find . -name "*~" -delete
- echo "β
Cleanup completed"
clean-all:
desc: Clean everything including virtual environment
cmds:
- task: clean
- echo "ποΈ Removing virtual environment..."
- rm -rf {{.VENV_DIR}}
- echo "β
Full cleanup completed"
# Testing tasks
test:unit:
desc: Run unit tests (no network required)
deps: [install]
cmds:
- echo "π§ͺ Running unit tests..."
- '{{.VENV_PYTHON}} -m pytest -v -m "not requires_network and not requires_private_key" {{.TEST_DIR}}'
test:integration:
desc: Run integration tests (network required)
deps: [install]
cmds:
- echo "π Running integration tests..."
- '{{.VENV_PYTHON}} -m pytest -v -m "integration and not requires_private_key" {{.TEST_DIR}}'
test:live:
desc: Run live write tests (private key required)
deps: [install]
cmds:
- echo "π₯ Running live write tests..."
- '{{.VENV_PYTHON}} -m pytest -v -m "requires_private_key" {{.TEST_DIR}}'
test:all:
desc: Run all tests
deps: [install]
cmds:
- echo "π Running all tests..."
- '{{.VENV_PYTHON}} -m pytest -v {{.TEST_DIR}}'
# Alternative pytest commands for more control
pytest:
desc: Run pytest with custom args
deps: [install]
cmds:
- '{{.VENV_PYTHON}} -m pytest {{.CLI_ARGS}}'
pytest:verbose:
desc: Run pytest with verbose output
deps: [install]
cmds:
- '{{.VENV_PYTHON}} -m pytest -v {{.CLI_ARGS}}'
# Code quality and linting
check:format:
desc: Check code formatting with black and isort
deps: [install]
cmds:
- echo "π¨ Checking code formatting..."
- '{{.VENV_PYTHON}} -m black --check --diff {{.SOURCE_DIR}}'
- '{{.VENV_PYTHON}} -m isort --check-only --diff {{.SOURCE_DIR}}'
check:lint:
desc: Run linting with flake8
deps: [install]
cmds:
- echo "π Running linter..."
- '{{.VENV_PYTHON}} -m flake8 {{.SOURCE_DIR}}'
check:types:
desc: Run type checking with mypy
deps: [install]
cmds:
- echo "π Running type checker..."
- '{{.VENV_PYTHON}} -m mypy {{.SOURCE_DIR}}/main'
check:
desc: Run all code quality checks
deps: [install]
cmds:
- task: check:format
- task: check:lint
- task: check:types
- echo "β
All checks passed"
# Formatting tasks
format:
desc: Auto-format code with black and isort
deps: [install]
cmds:
- echo "π¨ Formatting code..."
- '{{.VENV_PYTHON}} -m black {{.SOURCE_DIR}}'
- '{{.VENV_PYTHON}} -m isort {{.SOURCE_DIR}}'
- echo "β
Code formatted"
# Packaging tasks
build:
desc: Build distribution packages
deps: [install, clean]
cmds:
- echo "π¦ Building distribution packages..."
- '{{.VENV_PYTHON}} -m build'
- echo "β
Build completed"
- ls -la dist/
package:
desc: Build and verify packages
deps: [build]
cmds:
- echo "π Verifying built packages..."
- '{{.VENV_PYTHON}} -m twine check dist/*'
- echo "β
Package verification completed"
# Development workflow
dev:
desc: Setup development environment and run basic checks
cmds:
- task: install
- task: format
- task: test:unit
- echo "π Development environment ready!"
ci:
desc: Run full CI pipeline (format check, lint, type check, all tests)
cmds:
- task: check
- task: test:all
- echo "β
CI pipeline completed successfully"
# Protocol Buffer generation tasks
install:buf:
desc: Install buf CLI for protobuf generation
cmds:
- echo "π¦ Installing buf CLI..."
- |
if ! command -v buf &> /dev/null; then
curl -sSL https://github.com/bufbuild/buf/releases/latest/download/buf-$(uname -s)-$(uname -m) -o /usr/local/bin/buf
chmod +x /usr/local/bin/buf
else
echo "buf CLI already installed"
fi
generate:proto:
desc: Generate Python protobuf files using buf
deps: [install:buf]
cmds:
- echo "π§ Generating Python protobuf files..."
- mkdir -p logs
- cd src/proto && buf dep update
- cd src/proto && buf lint
- buf generate --template buf.gen.python.yaml --include-imports src/proto
- echo "β
Protobuf files generated successfully"
clean:proto:
desc: Clean generated protobuf files
cmds:
- echo "π§Ή Cleaning generated protobuf files..."
- rm -rf src/main/eas/v1/
- echo "β
Protobuf files cleaned"
proto:
desc: Clean and regenerate all protobuf files
cmds:
- task: clean:proto
- task: generate:proto
# BSR (Buf Schema Registry) tasks
buf:format:
desc: Format protobuf files using buf
deps: [install:buf]
cmds:
- echo "π¨ Formatting protobuf files..."
- buf format --write
- echo "β
Protobuf files formatted"
buf:lint:
desc: Lint protobuf files using buf
deps: [install:buf]
cmds:
- echo "π Linting protobuf files..."
- buf lint
- echo "β
Protobuf files passed lint checks"
buf:build:
desc: Build protobuf files using buf
deps: [install:buf, buf:format, buf:lint]
cmds:
- echo "π¨ Building protobuf files..."
- buf build
- echo "β
Protobuf build successful"
buf:generate:
desc: Generate Python code from protobuf files
deps: [install:buf, buf:build]
cmds:
- echo "π§ Generating Python protobuf files..."
- buf generate
- echo "β
Python protobuf files generated"
buf:breaking:
desc: Check for breaking changes against BSR
deps: [install:buf]
cmds:
- echo "π Checking for breaking changes..."
- buf breaking --against buf.build/cyberstorm/eas
- echo "β
No breaking changes detected"
buf:push:
desc: Push protobuf schemas to Buf Schema Registry
deps: [install:buf, buf:build, buf:breaking]
cmds:
- echo "π€ Pushing to BSR..."
- buf push
- echo "β
Successfully pushed to buf.build/cyberstorm/eas"
buf:push:draft:
desc: Push protobuf schemas to BSR with draft label
deps: [install:buf, buf:build]
cmds:
- echo "π€ Pushing to BSR with draft label..."
- buf push --label draft
- echo "β
Successfully pushed to BSR with draft label"
buf:push:create:
desc: Create and push new module to BSR
deps: [install:buf, buf:build]
cmds:
- echo "π€ Creating and pushing new module to BSR..."
- buf push --create
- echo "β
Successfully created and pushed to buf.build/cyberstorm/eas"
# Utility tasks
deps:
desc: Show installed dependencies
deps: [install]
cmds:
- '{{.VENV_PYTHON}} -m pip list'
deps:outdated:
desc: Show outdated dependencies
deps: [install]
cmds:
- '{{.VENV_PYTHON}} -m pip list --outdated'
env:
desc: Show environment information
deps: [_ensure-venv]
cmds:
- echo "π Environment Information"
- echo "Python - $({{.VENV_PYTHON}} --version)"
- echo "Virtual Environment - {{.VENV_DIR}}"
- echo "Source Directory - {{.SOURCE_DIR}}"
- echo "Test Directory - {{.TEST_DIR}}"
- echo "Pip - $({{.VENV_PYTHON}} -m pip --version)"
# Security and supply chain
audit:
desc: Run security audit on dependencies
deps: [install]
cmds:
- echo "π Running security audit..."
- '{{.VENV_PYTHON}} -m pip_audit || echo "β οΈ pip-audit not installed, run pip install pip-audit"'
# Documentation tasks (if needed)
docs:build:
desc: Build documentation (placeholder)
cmds:
- echo "π Documentation build not yet implemented"
# Release tasks
release:check:
desc: Pre-release checks
deps: [install]
cmds:
- echo "π Running pre-release checks..."
- task: clean
- task: check
- task: test:all
- task: build
- echo "π Verifying built packages..."
- '{{.VENV_PYTHON}} -m twine check dist/*'
- echo "β
Package verification completed"
- echo "π Ready for release!"
# Help task
help:
desc: Show detailed help for common workflows
cmds:
- echo "π Common EAS SDK Development Workflows"
- echo ""
- echo "π Getting Started"
- echo " task dev - Setup development environment"
- echo " task install - Install dependencies"
- echo ""
- echo "π§ͺ Testing"
- echo " task test:unit - Run unit tests (fast, no network)"
- echo " task test:integration - Run integration tests (network required)"
- echo " task test:live - Run live tests (private key required)"
- echo " task test:all - Run all tests"
- echo ""
- echo "π Code Quality"
- echo " task check - Run all checks (format, lint, types)"
- echo " task format - Auto-format code"
- echo " task check:lint - Run linter only"
- echo ""
- echo "π¦ Building & Packaging"
- echo " task build - Build distribution packages"
- echo " task package - Build and verify packages"
- echo " task release:check - Full pre-release validation"
- echo ""
- echo "π§Ή Cleanup"
- echo " task clean - Clean build artifacts"
- echo " task clean-all - Clean everything including venv"
- echo ""
- echo "π§ Protocol Buffers & BSR"
- echo " task buf:format - Format protobuf files"
- echo " task buf:lint - Lint protobuf files"
- echo " task buf:build - Build protobuf files"
- echo " task buf:generate - Generate Python code from protos"
- echo " task buf:push:create - Create and push to buf.build (first time)"
- echo " task buf:push - Push to buf.build (with breaking check)"
- echo " task buf:push:draft - Push draft to buf.build"
- echo ""
- echo "π§ Development"
- echo " task ci - Run full CI pipeline"
- echo " task env - Show environment info"
- echo " task deps - Show installed dependencies"