Skip to content

Commit fb5b2d5

Browse files
colyerdengShawnDen-coder
authored andcommitted
feat: update task file
1 parent ff2abad commit fb5b2d5

File tree

1 file changed

+66
-22
lines changed
  • repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}

1 file changed

+66
-22
lines changed
Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,130 @@
11
# https://taskfile.dev
22
version: '3'
3+
34
vars:
4-
package_name: homelab_airflow_dags
5-
python_min_version: '3.10'
6-
python_max_version: &dev_version '3.12'
5+
package_name: {{ cookiecutter.project_slug }}
6+
python_min_version: '{{ cookiecutter.min_python_version }}'
7+
python_max_version: &dev_version '{{ cookiecutter.max_python_version }}'
78
# 默认的开发版本
8-
99
python_dev_version: *dev_version
10+
1011
tasks:
1112
init:
1213
desc: Initialize the project
1314
cmds:
1415
- uv sync
1516
- uvx pre-commit install
17+
1618
lint:
1719
desc: Run linters
1820
cmds:
19-
- uvx ruff check --fix . # 先修复可以自动修复的问题
20-
- uvx ruff format . # 然后格式化
21-
- uvx ruff check . # 最后再检查一次确保没有遗留问题
21+
- uvx ruff check --fix . # 先修复可以自动修复的问题
22+
- uvx ruff format . # 然后格式化
23+
- uvx ruff check . # 最后再检查一次确保没有遗留问题
24+
2225
lint:add-noqa:
2326
desc: Add noqa comments to files
2427
cmds:
25-
- uvx ruff check --fix --add-noqa . # 添加 noqa 注释以忽略特定行的检查
26-
- task: lint:pre-commit # 运行 pre-commit 钩子以确保代码风格一致
27-
- task: lint # 重新运行 ruff 检查以确保没有遗漏的错误
28+
- uvx ruff check --fix --add-noqa . # 添加 noqa 注释以忽略特定行的检查
29+
- task: lint:pre-commit # 运行 pre-commit 钩子以确保代码风格一致
30+
- task: lint # 重新运行 ruff 检查以确保没有遗漏的错误
31+
2832
lint:pre-commit:
2933
desc: Run pre-commit hooks
3034
cmds:
3135
- uvx pre-commit run --all-files
36+
3237
lint:watch:
3338
desc: Watch files and run linters
3439
cmds:
35-
- uvx ruff check --watch . # 监视文件变化并运行检查
40+
- uvx ruff check --watch . # 监视文件变化并运行检查
41+
3642
test:
3743
desc: Run tests with dev version
3844
cmds:
3945
- task: test:version
4046
vars:
41-
version: '{{.python_dev_version}}'
47+
version: {% raw %}'{{.python_dev_version}}'{% endraw %}
48+
4249
test:all:
4350
desc: Run tests with all Python versions
4451
vars:
4552
python_versions:
4653
sh: |
4754
python3 -c "
48-
min_ver = '{{.python_min_version}}'.split('.')
49-
max_ver = '{{.python_max_version}}'.split('.')
55+
min_ver = {% raw %}'{{.python_min_version}}'{% endraw %}.split('.')
56+
max_ver = {% raw %}'{{.python_max_version}}'{% endraw %}.split('.')
5057
for minor in range(int(min_ver[1]), int(max_ver[1]) + 1):
5158
print(f'{min_ver[0]}.{minor}')
5259
"
5360
cmds:
54-
- for: {var: python_versions, split: "\n", as: version}
61+
- for: {% raw %}{var: python_versions, split: "\n", as: version}{% endraw %}
5562
task: test:version
5663
vars:
57-
version: '{{.version}}'
64+
version: {% raw %}'{{.version}}'{% endraw %}
65+
5866
test:version:
5967
desc: Run tests with specific Python version
6068
cmds:
61-
- echo "Testing with Python {{.version}}..."
62-
- uvx --python {{.version}} --with ".[dev]" pytest --cov={{.package_name}} --cov-report=xml --cov-report=term-missing -v tests/
69+
- echo "Testing with Python {% raw %}{{.version}}{% endraw %}..."
70+
- uvx --python {% raw %}{{.version}}{% endraw %} --with ".[dev]" pytest --cov={% raw %}{{.package_name}}{% endraw %} --cov-report=xml --cov-report=term-missing -v tests/
71+
72+
test:watch:
73+
desc: Watch files and run tests
74+
cmds:
75+
- uvx --with ".[dev]" ptw --runner "pytest -vx"
76+
6377
docs:
6478
desc: Build and view documentation
6579
cmds:
6680
- uvx --with ".[docs]" mkdocs serve
67-
export:deps:
81+
82+
docs:build:
83+
desc: Build documentation
6884
cmds:
69-
- uv pip compile pyproject.toml --no-deps --output-file requirements.txt
85+
- uvx --with ".[docs]" mkdocs build
86+
87+
{%- if cookiecutter.use_github_actions == 'yes' %}
7088
deploy:gh-pages:
7189
desc: Deploy documentation to GitHub Pages
7290
cmds:
7391
- uvx --with ".[docs]" mkdocs gh-deploy --force
92+
{%- endif %}
93+
7494
deploy:pypi:
7595
desc: Deploy package to PyPI
7696
cmds:
7797
- uv build
7898
- uv publish
99+
100+
export:deps:
101+
desc: Export dependencies to requirements.txt
102+
cmds:
103+
- uv pip compile pyproject.toml --no-deps --output-file requirements.txt
104+
105+
{%- if cookiecutter.use_docker == 'yes' %}
106+
docker:build:
107+
desc: Build Docker image
108+
cmds:
109+
- docker build -t {{ cookiecutter.repo_name }}:latest .
110+
111+
docker:run:
112+
desc: Run Docker container
113+
cmds:
114+
- docker run --rm -it {{ cookiecutter.repo_name }}:latest
115+
79116
docker-compose:up:
80-
desc: pre view docker Service
117+
desc: Start services with docker-compose
81118
cmds:
82119
- docker-compose -f docker/docker-compose.yaml up
120+
83121
docker-compose:down:
84-
desc: pre view docker Service
122+
desc: Stop services with docker-compose
85123
cmds:
86124
- docker-compose -f docker/docker-compose.yaml down
125+
126+
docker-compose:logs:
127+
desc: View docker-compose logs
128+
cmds:
129+
- docker-compose -f docker/docker-compose.yaml logs -f
130+
{%- endif %}

0 commit comments

Comments
 (0)