Skip to content

Migrate from Cookiecutter to Copier#29

Open
fbidu wants to merge 3 commits intomainfrom
feat/copier-migration
Open

Migrate from Cookiecutter to Copier#29
fbidu wants to merge 3 commits intomainfrom
feat/copier-migration

Conversation

@fbidu
Copy link
Copy Markdown
Owner

@fbidu fbidu commented Apr 6, 2026

Summary

  • Migrate templating engine from Cookiecutter to Copier, gaining copier update support (keep generated projects in sync with template changes) and conditional file generation
  • Add modular CD pipeline with three options: none, GitHub Actions (GHCR Docker push), or Homelab (GitLab CI + Portainer webhook)
  • Fix bugs identified in code review: missing [build-system], dead Python 2 code, broken _copy_without_render, stale .pylintrc, dead PIP env vars, unpinned uv in Dockerfile

What changed

Area Before After
Template engine Cookiecutter Copier 9.x
Config cookiecutter.json copier.yml with types & validation
Template dir {{cookiecutter.directory_name}}/ template/ subdirectory
Hooks hooks/pre_gen_project.py + hooks/post_gen_project.py tasks/post_generate.py
CD pipeline None GitHub Actions or Homelab (GitLab + Portainer)
Template updates Not supported copier update
GH Actions ${{ }} Relied on broken _copy_without_render Proper {% raw %} blocks
VS Code settings Template file (broken by .gitignore exclusion) Generated by post-gen task

Usage after merge

# New project
copier copy gh:fbidu/cookie-py my-project

# Update existing project when template changes
copier update

Test plan

  • uv run pytest — 10/10 integration tests pass
  • uv run ruff check . && ruff format --check . — clean
  • uv run pyright — 0 errors
  • Manual test: generate project with cd_pipeline=none — no deploy files
  • Manual test: generate project with cd_pipeline=github-actionsdeploy.yml present
  • Manual test: generate project with cd_pipeline=homelab-gitlab.gitlab-ci.yml present
  • Manual test: full post-gen task (git init, uv sync, pre-commit, initial commit) succeeds
  • CI pipeline passes

🤖 Generated with Claude Code

fbidu and others added 3 commits April 6, 2026 10:55
Replace Cookiecutter with Copier for template generation, gaining support
for template updates (`copier update`) and conditional file generation.

Key changes:
- cookiecutter.json → copier.yml with typed variables and validation
- Template directory restructured to template/ subdirectory
- Hooks replaced with Copier tasks (tasks/post_generate.py)
- Add modular CD pipeline: GitHub Actions or Homelab (GitLab + Portainer)
- VS Code settings (incl. Copilot toggle) generated by post-gen task

Bugs fixed:
- Add [build-system] to template pyproject.toml
- Add __init__.py to template package directory
- Fix GitHub Actions ${{ }} syntax with {% raw %} blocks
- Remove dead Python 2 code, stale .pylintrc, commented prettier block
- Remove dead PIP env vars from Dockerfile, pin uv version
- Remove redundant PLR ruff rule

Test improvements:
- Session-scoped fixture (7s vs regenerating per test)
- New tests for variable rendering, workflow content, CD pipeline variants

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Change [project.optional-dependencies] to [dependency-groups] so
  `uv sync --dev` actually installs dev dependencies
- Add libatomic1 to root Dockerfile for pyright's Node.js binary

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Root CI: test against 3.12, 3.13, 3.14, and 3.x with fail-fast: false
- Template CI: test chosen version + 3.x with allow-prereleases
- Add 3.14 to copier.yml python_version choices

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant