-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
398 lines (394 loc) · 15 KB
/
Copy pathTaskfile.yml
File metadata and controls
398 lines (394 loc) · 15 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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
version: '1'
name: nfo
description: Minimal Taskfile
variables:
APP_NAME: nfo
environments:
local:
container_runtime: docker
compose_command: docker compose
pipeline:
python_version: "3.12"
runner_image: ubuntu-latest
branches: [main]
cache: [~/.cache/pip]
artifacts: [dist/]
stages:
- name: lint
tasks: [lint]
- name: test
tasks: [test]
- name: build
tasks: [build]
when: "branch:main"
tasks:
install:
desc: Install Python dependencies (editable)
cmds:
- pip install -e .[dev]
test:
desc: Run pytest suite
cmds:
- pytest -q
build:
desc: Build wheel + sdist
cmds:
- python -m build
clean:
desc: Remove build artefacts
cmds:
- rm -rf build/ dist/ *.egg-info
up:
desc: Start services via docker compose
cmds:
- docker compose up -d
down:
desc: Stop services
cmds:
- docker compose down
logs:
desc: Tail compose logs
cmds:
- docker compose logs -f
ps:
desc: Show running compose services
cmds:
- docker compose ps
docker-build:
desc: Build docker image
cmds:
- docker build -t nfo:latest .
help:
desc: Show available tasks
cmds:
- echo "nfo — available tasks:"
- echo ""
- taskfile list
dev:
desc: '[imported from Makefile] dev'
cmds:
- $(PYTHON) -m pip install -e ".[dev]"
test-cov:
desc: '[imported from Makefile] test-cov'
cmds:
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src $(PYTHON) -m pytest -p pytest_asyncio.plugin
tests/ -v --cov=src/pactown --cov-report=term-missing
lint:
desc: '[imported from Makefile] lint'
cmds:
- if $(PYTHON) -c "import ruff" >/dev/null 2>&1; then \
- $(PYTHON) -m ruff check src/ tests/; \
- elif command -v ruff >/dev/null 2>&1; then \
- ruff check src/ tests/; \
- elif command -v pipx >/dev/null 2>&1; then \
- pipx run ruff check src/ tests/; \
- else \
- 'echo "Missing dependency: ruff. Run: make dev (or install via pipx)."; \'
- exit 1; \
- fi
format:
desc: '[imported from Makefile] format'
cmds:
- if $(PYTHON) -c "import ruff" >/dev/null 2>&1; then \
- $(PYTHON) -m ruff format src/ tests/; \
- elif command -v ruff >/dev/null 2>&1; then \
- ruff format src/ tests/; \
- elif command -v pipx >/dev/null 2>&1; then \
- pipx run ruff format src/ tests/; \
- else \
- 'echo "Missing dependency: ruff. Run: make dev (or install via pipx)."; \'
- exit 1; \
- fi
registry:
desc: '[imported from Makefile] registry'
cmds:
- pactown-registry --host 0.0.0.0 --port 8800
registry-bg:
desc: '[imported from Makefile] registry-bg'
cmds:
- pactown-registry --host 0.0.0.0 --port 8800 &
status:
desc: '[imported from Makefile] status'
cmds:
- pactown status $(CONFIG)
validate:
desc: '[imported from Makefile] validate'
cmds:
- pactown validate $(CONFIG)
graph:
desc: '[imported from Makefile] graph'
cmds:
- pactown graph $(CONFIG)
examples:
desc: '[imported from Makefile] examples'
cmds:
- pactown up examples/saas.pactown.yaml --dry-run
init:
desc: '[imported from Makefile] init'
cmds:
- pactown init
publish-registry:
desc: '[imported from Makefile] publish-registry'
cmds:
- pactown publish $(CONFIG) --registry http://localhost:8800
pull:
desc: '[imported from Makefile] pull'
cmds:
- pactown pull $(CONFIG) --registry http://localhost:8800
check-pypi-deps:
desc: '[imported from Makefile] check-pypi-deps'
cmds:
- '$(PYTHON) -c "import build" >/dev/null 2>&1 || (echo "Missing dependency: build.
Run: $(PYTHON) -m pip install -e \".[dev]\" (or: $(PYTHON) -m pip install build)"
&& exit 1)'
- '$(PYTHON) -c "import twine" >/dev/null 2>&1 || (echo "Missing dependency: twine.
Run: $(PYTHON) -m pip install -e \".[dev]\" (or: $(PYTHON) -m pip install twine)"
&& exit 1)'
- '$(BUMP2VERSION) --help >/dev/null 2>&1 || (echo "Missing dependency: bump2version.
Run: $(PYTHON) -m pip install -e \".[dev]\" (or: $(PYTHON) -m pip install bump2version)"
&& exit 1)'
publish-pypi:
desc: '[imported from Makefile] publish-pypi'
cmds:
- $(MAKE) check-pypi-deps
- $(MAKE) bump-patch
- $(MAKE) sync-pactown-com
- $(MAKE) build
- $(PYTHON) -m twine upload dist/*
version:
desc: '[imported from Makefile] version'
cmds:
- grep -m1 'version = ' pyproject.toml | cut -d'"' -f2
bump-patch:
desc: '[imported from Makefile] bump-patch'
cmds:
- $(BUMP2VERSION) patch --config-file .bumpversion.cfg --allow-dirty
- echo "Bumped to $$(grep -m1 'version = ' pyproject.toml | cut -d'"' -f2)"
bump-minor:
desc: '[imported from Makefile] bump-minor'
cmds:
- $(BUMP2VERSION) minor --config-file .bumpversion.cfg --allow-dirty
- echo "Bumped to $$(grep -m1 'version = ' pyproject.toml | cut -d'"' -f2)"
bump-major:
desc: '[imported from Makefile] bump-major'
cmds:
- $(BUMP2VERSION) major --config-file .bumpversion.cfg --allow-dirty
- echo "Bumped to $$(grep -m1 'version = ' pyproject.toml | cut -d'"' -f2)"
publish:
desc: '[imported from Makefile] publish'
sync-pactown-com:
desc: '[imported from Makefile] sync-pactown-com'
cmds:
- $(PYTHON) tools/sync_pactown_com_dependency.py
security:
desc: '[imported from Makefile] security'
security-sast:
desc: '[imported from Makefile] security-sast'
cmds:
- echo "Running SAST analysis..."
- if $(PYTHON) -c "import bandit" >/dev/null 2>&1; then \
- $(PYTHON) -m bandit -r src/ -ll -ii --skip B101 || true; \
- elif command -v bandit >/dev/null 2>&1; then \
- bandit -r src/ -ll -ii --skip B101 || true; \
- else \
- 'echo "[SKIP] bandit not installed. Run: $(PYTHON) -m pip install bandit"; \'
- fi
- if command -v semgrep >/dev/null 2>&1; then \
- semgrep scan --config=p/python --config=p/owasp-top-ten src/ --error 2>/dev/null
|| \
- semgrep scan --config=auto src/ --error 2>/dev/null || \
- echo "[WARN] semgrep scan completed with findings"; \
- else \
- 'echo "[SKIP] semgrep not installed. Run: pip install semgrep (or pipx install
semgrep)"; \'
- fi
security-deps:
desc: '[imported from Makefile] security-deps'
cmds:
- echo "Scanning dependencies for vulnerabilities..."
- if $(PYTHON) -c "import pip_audit" >/dev/null 2>&1; then \
- $(PYTHON) -m pip_audit --desc on || true; \
- elif command -v pip-audit >/dev/null 2>&1; then \
- pip-audit --desc on || true; \
- else \
- 'echo "[SKIP] pip-audit not installed. Run: $(PYTHON) -m pip install pip-audit";
\'
- fi
security-secrets:
desc: '[imported from Makefile] security-secrets'
cmds:
- echo "Scanning for secrets..."
- if command -v gitleaks >/dev/null 2>&1; then \
- gitleaks detect --source . --verbose 2>/dev/null || echo "[WARN] Potential secrets
found"; \
- else \
- 'echo "[SKIP] gitleaks not installed. Install: https://github.com/gitleaks/gitleaks#installing";
\'
- fi
security-all:
desc: '[imported from Makefile] security-all'
artifacts-docker:
desc: '[imported from Makefile] artifacts-docker'
cmds:
- if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then \
- $(PYTHON) tools/validate_artifacts_docker.py \
- --root $(ARTIFACT_ROOT) --strict -v; \
- else \
- 'echo "ERROR: Docker not available"; exit 1; \'
- fi
artifacts-clean:
desc: '[imported from Makefile] artifacts-clean'
cmds:
- echo "Cleaning $(ARTIFACT_ROOT)/ and bytecode caches..."
- if [ -d "$(ARTIFACT_ROOT)" ] && command -v docker >/dev/null 2>&1 && docker
info >/dev/null 2>&1; then \
- docker run --rm -v "$$(cd $(ARTIFACT_ROOT) && pwd):/clean" ubuntu:22.04 \
- sh -c 'chmod -R 777 /clean/test-* 2>/dev/null; rm -rf /clean/test-*' 2>/dev/null;
\
- fi
- rm -rf $(ARTIFACT_ROOT)/test-* 2>/dev/null || true
- find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
- "echo \"Done \u2013 artifact directory cleaned.\""
artifacts-quick:
desc: '[imported from Makefile] artifacts-quick'
cmds:
- echo ""
- echo "============================================================"
- 'echo " STEP 1/3: Generating scaffold artifacts (18 frameworks)"'
- echo "============================================================"
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src \
- $(PYTHON) -m pytest -p pytest_asyncio.plugin \
- $(ARTIFACT_TESTS)::TestRealScaffoldInPactown -v --tb=short
- echo ""
- echo "============================================================"
- 'echo " STEP 2/3: Validating artifact sizes (strict, no stubs)"'
- echo "============================================================"
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src \
- $(PYTHON) -m pytest -p pytest_asyncio.plugin \
- $(ARTIFACT_TESTS)::TestArtifactSizeValidation -v --tb=short -s
- echo ""
- echo "============================================================"
- 'echo " STEP 3/3: Validating file correctness"'
- echo "============================================================"
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src \
- $(PYTHON) -m pytest -p pytest_asyncio.plugin \
- $(ARTIFACT_TESTS)::TestGeneratedFileCorrectness -v --tb=short -s
- echo ""
- echo "============================================================"
- "echo \" DONE \u2013 quick validation passed\""
- echo "============================================================"
artifacts:
desc: '[imported from Makefile] artifacts'
cmds:
- echo ""
- echo "============================================================"
- 'echo " STEP 1/9: Generating scaffold artifacts (18 frameworks)"'
- echo "============================================================"
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src \
- $(PYTHON) -m pytest -p pytest_asyncio.plugin \
- $(ARTIFACT_TESTS)::TestRealScaffoldInPactown -v --tb=short
- echo ""
- echo "============================================================"
- 'echo " STEP 2/9: Generating IaC artifacts (Docker)"'
- echo "============================================================"
- if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then \
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src \
- $(PYTHON) -m pytest -p pytest_asyncio.plugin \
- $(ARTIFACT_TESTS)::TestDockerIaCValidation::test_docker_iac_all_files_present_and_consistent
\
- -v --tb=short; \
- else \
- "echo \"[SKIP] Docker not available \u2013 IaC scaffolds not generated\"; \\"
- fi
- echo ""
- echo "============================================================"
- 'echo " STEP 3/9: Validating artifact sizes (strict, no stubs)"'
- echo "============================================================"
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src \
- $(PYTHON) -m pytest -p pytest_asyncio.plugin \
- $(ARTIFACT_TESTS)::TestArtifactSizeValidation -v --tb=short -s
- echo ""
- echo "============================================================"
- 'echo " STEP 4/9: Validating file correctness (magic bytes,"'
- echo " configs, syntax, schemas)"
- echo "============================================================"
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src \
- $(PYTHON) -m pytest -p pytest_asyncio.plugin \
- $(ARTIFACT_TESTS)::TestGeneratedFileCorrectness -v --tb=short -s
- echo ""
- echo "============================================================"
- 'echo " STEP 5/9: Docker native validation (every artifact in"'
- echo " its native Docker container)"
- echo "============================================================"
- if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then \
- $(PYTHON) tools/validate_artifacts_docker.py \
- --root $(ARTIFACT_ROOT) --strict -v; \
- else \
- "echo \"[SKIP] Docker not available \u2013 native validation skipped\"; \\"
- fi
- echo ""
- echo "============================================================"
- 'echo " STEP 6/9: Docker platform tests (binary format,"'
- echo " artifact execution, syntax checks)"
- echo "============================================================"
- if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then \
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src \
- $(PYTHON) -m pytest -p pytest_asyncio.plugin \
- $(ARTIFACT_TESTS)::TestDockerArtifactSizeValidation \
- $(ARTIFACT_TESTS)::TestDockerBinaryFormatVerification \
- $(ARTIFACT_TESTS)::TestDockerArtifactExecution \
- $(ARTIFACT_TESTS)::TestDockerAutomatedExecution \
- $(ARTIFACT_TESTS)::TestDockerDockerfileValidation \
- -v --tb=short; \
- else \
- "echo \"[SKIP] Docker not available \u2013 platform validation skipped\"; \\"
- fi
- echo ""
- echo "============================================================"
- "echo \" STEP 7/9: E2E build \u2192 deploy via Ansible\""
- echo "============================================================"
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src \
- $(PYTHON) -m pytest -p pytest_asyncio.plugin \
- $(ARTIFACT_TESTS)::TestE2EBuildAndAnsibleDeploy \
- $(ARTIFACT_TESTS)::TestMultiPlatformArtifactsWithAnsible \
- -v --tb=short
- echo ""
- echo "============================================================"
- 'echo " STEP 8/9: Desktop + mobile artifact generation per OS"'
- echo "============================================================"
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src \
- $(PYTHON) -m pytest -p pytest_asyncio.plugin \
- $(ARTIFACT_TESTS)::TestDesktopArtifactGeneration \
- $(ARTIFACT_TESTS)::TestMobileArtifactGeneration \
- $(ARTIFACT_TESTS)::TestAnsibleArtifactDistribution \
- -v --tb=short
- echo ""
- echo "============================================================"
- "echo \" STEP 9/9: Cross-platform matrix (framework \xD7 OS)\""
- echo "============================================================"
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src \
- $(PYTHON) -m pytest -p pytest_asyncio.plugin \
- $(CROSS_PLATFORM_TESTS) -v --tb=short
- echo ""
- echo "============================================================"
- "echo \" ALL DONE \u2013 full artifact pipeline completed (9 steps)\""
- echo "============================================================"
health:
desc: '[from doql] workflow: health'
cmds:
- docker compose ps
- docker compose exec app echo "Health check passed"
import-makefile-hint:
desc: '[from doql] workflow: import-makefile-hint'
cmds:
- 'echo ''Run: taskfile import Makefile to import existing targets.'''
all:
desc: Run install, lint, test
cmds:
- taskfile run install
- taskfile run lint
- taskfile run test
fmt:
desc: Auto-format with ruff
cmds:
- ruff format .