Skip to content

feat: renders record their answers, so copier update can reach them - #21

Merged
AlexeyShalaev merged 1 commit into
masterfrom
fix/14-copier-answers
Oct 16, 2026
Merged

AlexeyShalaev merged 1 commit into
masterfrom
fix/14-copier-answers

Conversation

@AlexeyShalaev

Copy link
Copy Markdown
Member

The problem

There was no answers-file template under template/, so Copier wrote no .copier-answers.yml. A render recorded neither its answers nor the template commit it came from, copier update refused to run, and every template fix (#8, #9, and the open ones now) had to be copied into each library by hand.

The decision

  • template/{{_copier_conf.answers_file}}.jinja, as proposed. Copier reads the answers file and nothing else, so there was no alternative to weigh.
  • The post-generation message runs on a copy only (when: "{{ _copier_operation == 'copy' }}"). copier update runs tasks too, and it printed "Template generated. Next steps…" into libraries that were set up long ago.
  • A CI job for update. It renders master, commits the render, runs copier update to the commit under test, and diffs the result against a fresh render of that commit. They have to be identical. A template change that fails or diverges when it travels through copier update therefore fails its own PR instead of the next library's update. Until master itself renders an answers file, the job says so and exits 0. That applies only to this PR's own run.
  • The README gets a "Pulling template changes into a library" section, which also says how to backfill the file in a library rendered before it existed.

Evidence

Before (a render of origin/master 8ebf45d, committed):

ls: .copier-answers.yml: No such file or directory
Cannot update because cannot obtain old template references from `.copier-answers.yml`.

After (a render of this branch):

# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: f747c93
_src_path: …/python-library-template-14
author_email: maintainers@example.com
…
python_min_version: '3.11'

The new CI step, run locally with master set to this branch and a later commit on top that raises the pytest floor. It exits 0, and the updated render changed exactly:

 .copier-answers.yml | 2 +-     -_commit: f747c93  +_commit: a81e438
 pyproject.toml      | 2 +-     -    "pytest>=9.0.2",  +    "pytest>=9.0.3",

No task output on the update. The task does run on copy. I also checked, with Copier 9.19.1, that a file the library deleted stays deleted through an update, even after the template changes it. That matters for #15, which renders the checklist again.

The generated gate on the render: ruff/mypy clean, 1 test passed, uv build OK. actionlint is clean on the template CI.

For the existing libraries

None of them has the file, so each one needs it written by hand before its first copier update, as the README now describes: the answers it was rendered with, _src_path: gh:bedrock-python/python-library-template, and as _commit the template commit it is closest to. The template has no tags, so Copier versions it as 0.0.0.postN.devN+sha. Tagging template releases would make those jumps readable, but that is a separate decision.

Closes #14

There was no answers file template under template/, so Copier wrote none:
a render recorded neither its answers nor the template commit it came from,
copier update refused to run, and every template fix had to be copied into
each library by hand.

template/{{_copier_conf.answers_file}}.jinja makes every render carry
_src_path, _commit and the answers. The post-generation message now runs on
a copy only, since copier update runs tasks too. CI gets an update job: a
render of master, updated to the commit under test, has to come out exactly
as a fresh render of it, so a change that does not travel through
copier update fails its own pull request.

The README says how to update a library and how to backfill the file in one
rendered before it existed.

Closes #14
@AlexeyShalaev
AlexeyShalaev merged commit df3262d into master Oct 16, 2026
3 checks passed
@AlexeyShalaev
AlexeyShalaev deleted the fix/14-copier-answers branch October 16, 2026 15:00
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.

Generated projects have no .copier-answers.yml, so copier update cannot bring template fixes into them

1 participant