-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
135 lines (119 loc) · 3.5 KB
/
Taskfile.yml
File metadata and controls
135 lines (119 loc) · 3.5 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
version: "3"
tasks:
setup_env:
desc: Set up the env vars
cmds:
- cp .env.example .env
sources:
- .env.example
setup_git:
desc: Remove existing .git directory to start a new git history
cmds:
- rm -rf .git
- git init
- git add *
- git add .dockerignore .env.example .gitignore .pre-commit-config.yaml .python-version
- git commit -m "First commit 🚀"
sources:
- .git/**
install:
desc: Install all dependencies including development tools
cmds:
- uv sync --all-groups
sources:
- pyproject.toml
- uv.lock
generates:
- .venv/**/*
setup_precommit:
desc: Set up pre-commit hooks
deps: [install]
cmds:
- uv run pre-commit install
setup:
desc: Set up the project (install dependencies, remove .git)
deps: [setup_env, setup_git, install, setup_precommit]
format:
desc: Format code using ruff
deps: [install]
cmds:
- uv run ruff format .
lint:
desc: Run all linting tools
deps: [install]
cmds:
- uv run ruff check --fix .
type_check:
desc: Run type checking using mypy
deps: [install]
cmds:
- uv run mypy src/ tests/
test:
desc: Run all tests with coverage
deps: [install]
cmds:
- uv run pytest --cov=src tests/
qa:
desc: Run all quality assurance tasks (format, lint, type_check) in order
deps: [install]
cmds:
- task: format
- task: lint
- task: type_check
- task: test
clean:
desc: Clean up generated files
cmds:
- rm -rf .mypy_cache/
- rm -rf .pytest_cache/
- rm -rf .ruff_cache/
- rm -rf .task/
- rm -rf .coverage
- find ./* -type d -name "__pycache__" -exec rm -r {} +
- find . -type d -name "*.egg-info" -exec rm -rf {} +
- find . -type f -name "*.pyc" -delete
build:
desc: Build Docker image
deps: [clean]
summary: |
Build a Docker image for the project.
Usage:
task build # Build with default tag
task build TAG=my-app:v1.0.0 # Build with custom tag
Examples:
task build TAG=myproject:latest
task build TAG=myproject:dev
vars:
TAG: '{{.TAG | default "python-repo-template:latest"}}'
cmds:
- docker build -t {{.TAG}} .
sources:
- Dockerfile
- pyproject.toml
- uv.lock
- src/**/*
rename:
desc: Rename template package to your project name
summary: |
Rename the template package and module to your project name.
This updates all imports and file references automatically.
Usage:
task rename # Use default name (my_package)
task rename NAME=your_package # Use custom package name
deps: [clean]
vars:
NAME: '{{.NAME | default "my_package"}}'
preconditions:
- sh: 'test "{{.NAME}}" != "template_package"'
msg: "❌ Please provide a different name than 'template_package'. Usage: task rename NAME=your_package"
- sh: 'test -d "src/template_package"'
msg: "🤔 Project already renamed. 'src/template_package' not found."
cmds:
- echo "🚀 Renaming template_package to {{.NAME}}"
- |
find src tests pyproject.toml -type f -print0 | \
xargs -0 sed -i.bak 's/template_package/{{.NAME}}/g'
- mv src/template_package src/{{.NAME}}
- mv tests/template_package tests/{{.NAME}}
- find . -name "*.bak" -type f -delete
- echo "✅ Renamed to {{.NAME}}!"