Skip to content

Commit bcc955d

Browse files
committed
fix(template): auto update task rendering
1 parent e39a9a7 commit bcc955d

3 files changed

Lines changed: 44 additions & 5 deletions

File tree

tests/test_cookiecutter.py

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
"""
3-
Test cookiecutter-python
3+
Test ai-native-python
44
"""
55

66
import copy
@@ -109,7 +109,7 @@ def check_files(files):
109109
)
110110
def test_supported_options(cookies, context_override):
111111
"""
112-
Test all supported cookiecutter-python answer combinations
112+
Test all supported answer combinations
113113
"""
114114
# Turn off the post generation hooks
115115
os.environ["RUN_POST_HOOK"] = "false"
@@ -126,10 +126,47 @@ def test_supported_options(cookies, context_override):
126126
check_files(files)
127127

128128

129+
@pytest.mark.integration
130+
def test_update(cookies):
131+
"""
132+
Test task update
133+
"""
134+
# Turn on the post generation hooks but skip git push
135+
os.environ["RUN_POST_HOOK"] = "true"
136+
os.environ["SKIP_GIT_PUSH"] = "true"
137+
138+
result = cookies.bake()
139+
project = result.project_path
140+
141+
try:
142+
# First init the project just in case
143+
# Clean environment to avoid VIRTUAL_ENV conflicts
144+
env = os.environ.copy()
145+
env.pop("VIRTUAL_ENV", None)
146+
subprocess.run(
147+
["task", "init"],
148+
capture_output=True,
149+
check=True,
150+
cwd=project,
151+
env=env,
152+
)
153+
154+
# And then run a task update
155+
subprocess.run(
156+
["task", "update"],
157+
capture_output=True,
158+
check=True,
159+
cwd=project,
160+
env=env,
161+
)
162+
except subprocess.CalledProcessError as error:
163+
pytest.fail(f"stdout: {error.stdout.decode('utf-8')}, stderr: {error.stderr.decode('utf-8')}")
164+
165+
129166
@pytest.mark.integration
130167
def test_autofix_hook(cookies, context):
131168
"""
132-
Test the post-generation pre-commit autofix hook of cookiecutter-python
169+
Test the post-generation pre-commit autofix hook
133170
"""
134171
# Turn on the post generation hooks but skip git push
135172
os.environ["RUN_POST_HOOK"] = "true"
@@ -177,7 +214,7 @@ def test_autofix_hook(cookies, context):
177214
@pytest.mark.integration
178215
def test_default_project(cookies):
179216
"""
180-
Test a default cookiecutter-python project thoroughly
217+
Test a default project thoroughly
181218
"""
182219
# Turn on the post generation hooks but skip git push
183220
os.environ["RUN_POST_HOOK"] = "true"

{{cookiecutter.project_name|replace(" ", "")}}/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ Both tools are pre-configured and will start working once the repository is push
4949
## FAQs
5050

5151
For frequently asked questions including release workflow troubleshooting, see our [FAQ documentation](./FAQ.md).
52+
53+
_This project was generated with 🤟 by [Zenable](https://zenable.io)_

{{cookiecutter.project_name|replace(" ", "")}}/Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ tasks:
172172
- pre-commit autoupdate --freeze --jobs 4
173173
- uv lock --upgrade
174174
# This can take a while but it's required for the following step to update BuildKit in the docker driver
175-
- '{{ "{{" }}if eq .CLI_ARGS "all"{{ "}}" }}docker buildx rm multiplatform || true{{ "}}" }}end {{ "}}" }}'
175+
- '{{ "{{" }}if eq .CLI_ARGS "all"{{ "}}" }}docker buildx rm multiplatform || true{{ "{{" }}end{{ "}}" }}'
176176
# If we just destroyed the "multiplatform" builder instance, this will configure a new one. The next time the host runs a `docker buildx build` it will
177177
# rebuild the builder instance, updating its BuildKit. There's no harm in running this even if we didn't do the `docker buildx rm` previously
178178
- task: init-docker-multiplatform

0 commit comments

Comments
 (0)