Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ tasks:
- uv sync --frozen

init-pre-commit:
desc: Install the pre-commit hooks
desc: Setup pre-commit
internal: true
sources:
- .pre-commit-config.yaml
status:
# Don't install the pre-commit hooks if you aren't in a git repository; quote to avoid yaml intrepretering the ! as a node tag
# Don't do any of this if you aren't in a git repository; quote to avoid yaml intrepretering the ! as a node tag
# https://yaml.org/spec/1.2.2/#691-node-tags
- '! test -d .git'
cmds:
- uv tool install pre-commit
# Don't run this in pipelines
- '{{if ne .GITHUB_ACTIONS "true"}}{{.RUN_SCRIPT}} pre-commit install{{else}}echo "Detected a github actions pipeline; skipping the pre-commit install"{{end}}'

Expand Down Expand Up @@ -88,6 +89,7 @@ tasks:
cmds:
# This currently assumes uv was installed via uv (locally); we will want to make it more flexible in the future
- '{{if ne .GITHUB_ACTIONS "true"}}brew upgrade uv{{end}}'
- uv tool upgrade --all
- pre-commit autoupdate --freeze --jobs 4
# Copy the newly updated config into the project template, excluding the exclude line
- cat .pre-commit-config.yaml | grep -v ^exclude > '{{`{{cookiecutter.project_name|replace(" ", "")}}`}}/.pre-commit-config.yaml'
Expand Down
45 changes: 41 additions & 4 deletions tests/test_cookiecutter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Test cookiecutter-python
Test ai-native-python
"""

import copy
Expand Down Expand Up @@ -109,7 +109,7 @@ def check_files(files):
)
def test_supported_options(cookies, context_override):
"""
Test all supported cookiecutter-python answer combinations
Test all supported answer combinations
"""
# Turn off the post generation hooks
os.environ["RUN_POST_HOOK"] = "false"
Expand All @@ -126,10 +126,47 @@ def test_supported_options(cookies, context_override):
check_files(files)


@pytest.mark.integration
def test_update(cookies):
"""
Test task update
"""
# Turn on the post generation hooks but skip git push
os.environ["RUN_POST_HOOK"] = "true"
os.environ["SKIP_GIT_PUSH"] = "true"
Comment thread
JonZeolla marked this conversation as resolved.

result = cookies.bake()
project = result.project_path

try:
# First init the project just in case
# Clean environment to avoid VIRTUAL_ENV conflicts
env = os.environ.copy()
env.pop("VIRTUAL_ENV", None)
subprocess.run(
["task", "init"],
capture_output=True,
check=True,
cwd=project,
env=env,
)

# And then run a task update
subprocess.run(
["task", "update"],
capture_output=True,
check=True,
cwd=project,
env=env,
)
except subprocess.CalledProcessError as error:
pytest.fail(f"stdout: {error.stdout.decode('utf-8')}, stderr: {error.stderr.decode('utf-8')}")
Comment thread
JonZeolla marked this conversation as resolved.


@pytest.mark.integration
def test_autofix_hook(cookies, context):
"""
Test the post-generation pre-commit autofix hook of cookiecutter-python
Test the post-generation pre-commit autofix hook
"""
# Turn on the post generation hooks but skip git push
os.environ["RUN_POST_HOOK"] = "true"
Expand Down Expand Up @@ -177,7 +214,7 @@ def test_autofix_hook(cookies, context):
@pytest.mark.integration
def test_default_project(cookies):
"""
Test a default cookiecutter-python project thoroughly
Test a default project thoroughly
"""
# Turn on the post generation hooks but skip git push
os.environ["RUN_POST_HOOK"] = "true"
Expand Down
2 changes: 2 additions & 0 deletions {{cookiecutter.project_name|replace(" ", "")}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ Both tools are pre-configured and will start working once the repository is push
## FAQs

For frequently asked questions including release workflow troubleshooting, see our [FAQ documentation](./FAQ.md).

_This project was generated with 🤟 by [Zenable](https://zenable.io)_
6 changes: 4 additions & 2 deletions {{cookiecutter.project_name|replace(" ", "")}}/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ tasks:
sources:
- .pre-commit-config.yaml
status:
# Only install the pre-commit hooks if you are in a git repository; quote to avoid yaml intrepretering the ! as a node tag
# Don't do any of this if you aren't in a git repository; quote to avoid yaml intrepretering the ! as a node tag
# https://yaml.org/spec/1.2.2/#691-node-tags
- '! test -d .git'
cmds:
- uv tool install pre-commit
# Don't run this in pipelines
- '{{ "{{" }}if ne .GITHUB_ACTIONS "true"{{ "}}{{.RUN_SCRIPT}} pre-commit install{{else}}echo \"Detected a github actions pipeline; skipping the pre-commit install\"{{end}}" }}'

Expand Down Expand Up @@ -169,10 +170,11 @@ tasks:
cmds:
# This currently assumes uv was installed via uv (locally); we will want to make it more flexible in the future
- '{{ "{{" }}if ne .GITHUB_ACTIONS "true"{{ "}}" }}brew upgrade uv{{ "{{" }}end{{ "}}" }}'
- uv tool upgrade --all
- pre-commit autoupdate --freeze --jobs 4
- uv lock --upgrade
# This can take a while but it's required for the following step to update BuildKit in the docker driver
- '{{ "{{" }}if eq .CLI_ARGS "all"{{ "}}" }}docker buildx rm multiplatform || true{{ "}}" }}end {{ "}}" }}'
- '{{ "{{" }}if eq .CLI_ARGS "all"{{ "}}" }}docker buildx rm multiplatform || true{{ "{{" }}end{{ "}}" }}'
Comment thread
JonZeolla marked this conversation as resolved.
# 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
# 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
- task: init-docker-multiplatform
Expand Down
Loading