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
75 changes: 59 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ SHELL := bash

test-template-render: test-template-render-github test-template-render-gitlab

# Validate GitHub-scaffolded output and task-runner pruning.
# Validate generated template repository structure.
test-template-render-github:
@set -euo pipefail; \
out_dir="$$(mktemp -d /tmp/scaf-template-github-XXXXXX)"; \
copier copy . "$$out_dir" --trust --defaults \
copier copy . "$$out_dir" --vcs-ref=HEAD --trust --defaults \
-d copier__project_name_raw="Sample GitHub Template" \
-d copier__project_slug="sample_github_template" \
-d copier__description="Sample github generated project" \
Expand All @@ -20,22 +20,44 @@ test-template-render-github:
-d copier__github_semantic_release_auth="github_token" \
-d copier__enable_secret_scanning=true \
-d copier__task_runner="task"; \
test -f "$$out_dir/copier.yml"; \
test -f "$$out_dir/README.md"; \
test -f "$$out_dir/.copier-answers.yml"; \
test -f "$$out_dir/Taskfile.yml"; \
test ! -f "$$out_dir/Makefile"; \
test ! -f "$$out_dir/justfile"; \
test -f "$$out_dir/.github/workflows/template-correctness.yaml"; \
test -f "$$out_dir/.github/workflows/secret-scan.yaml"; \
test ! -f "$$out_dir/.github/workflows/semantic-release.yaml"; \
test ! -f "$$out_dir/.gitlab-ci.yml"; \
test -f "$$out_dir/.copier-answers.yml"; \
test -f "$$out_dir/template/README.md"; \
test -f "$$out_dir/template/.scaf/post-copy.py"; \
test -f "$$out_dir/template/Taskfile.yml"; \
test ! -f "$$out_dir/template/Makefile"; \
test ! -f "$$out_dir/template/justfile"; \
test -f "$$out_dir/template/.github/workflows/template-correctness.yaml"; \
test -f "$$out_dir/template/.github/workflows/secret-scan.yaml"; \
test ! -f "$$out_dir/template/.github/workflows/semantic-release.yaml"; \
test ! -f "$$out_dir/template/.github/workflows/semantic-pull-request.yaml"; \
test ! -f "$$out_dir/template/.gitlab-ci.yml"; \
test ! -f "$$out_dir/template/package.json"; \
test ! -f "$$out_dir/template/dependencies-init.txt"; \
test ! -f "$$out_dir/template/dependencies-dev-init.txt"; \
test -f "$$out_dir/template/{{_copier_conf.answers_file}}"; \
grep -Fq '{{ copier__project_name }}' "$$out_dir/template/README.md"; \
grep -Fq 'copier copy . /path/to/new-project --trust' "$$out_dir/README.md"; \
grep -Eq '^copier__project_name_raw:' "$$out_dir/copier.yml"; \
render_dir="$$(mktemp -d /tmp/scaf-template-rendered-gh-XXXXXX)"; \
copier copy "$$out_dir" "$$render_dir" --trust --defaults \
-d copier__configure_repo=false \
-d copier__enable_semantic_release=false \
-d copier__enable_secret_scanning=false \
-d copier__ci_provider="github" \
-d copier__task_runner="task"; \
test -f "$$render_dir/.copier-answers.yml"; \
test ! -f "$$render_dir/{{_copier_conf.answers_file}}"; \
rm -rf "$$render_dir"; \
rm -rf "$$out_dir"

# Validate GitLab-scaffolded output and task-runner pruning.
# Validate generated template repository structure.
test-template-render-gitlab:
@set -euo pipefail; \
out_dir="$$(mktemp -d /tmp/scaf-template-gitlab-XXXXXX)"; \
copier copy . "$$out_dir" --trust --defaults \
copier copy . "$$out_dir" --vcs-ref=HEAD --trust --defaults \
-d copier__project_name_raw="Sample GitLab Template" \
-d copier__project_slug="sample_gitlab_template" \
-d copier__description="Sample gitlab generated project" \
Expand All @@ -46,11 +68,32 @@ test-template-render-gitlab:
-d copier__enable_semantic_release=false \
-d copier__enable_secret_scanning=true \
-d copier__task_runner="just"; \
test -f "$$out_dir/copier.yml"; \
test -f "$$out_dir/README.md"; \
test -f "$$out_dir/.github/workflows/template-correctness.yaml"; \
test -f "$$out_dir/.copier-answers.yml"; \
test -f "$$out_dir/justfile"; \
test ! -f "$$out_dir/Makefile"; \
test ! -f "$$out_dir/Taskfile.yml"; \
test -f "$$out_dir/.gitlab-ci.yml"; \
test ! -d "$$out_dir/.github"; \
test -f "$$out_dir/template/README.md"; \
test -f "$$out_dir/template/.scaf/post-copy.py"; \
test -f "$$out_dir/template/justfile"; \
test ! -f "$$out_dir/template/Makefile"; \
test ! -f "$$out_dir/template/Taskfile.yml"; \
test -f "$$out_dir/template/.gitlab-ci.yml"; \
test ! -d "$$out_dir/template/.github"; \
test ! -f "$$out_dir/template/package.json"; \
test ! -f "$$out_dir/template/dependencies-init.txt"; \
test ! -f "$$out_dir/template/dependencies-dev-init.txt"; \
test -f "$$out_dir/template/{{_copier_conf.answers_file}}"; \
grep -Fq '{{ copier__project_name }}' "$$out_dir/template/README.md"; \
grep -Fq 'copier copy . /path/to/new-project --trust' "$$out_dir/README.md"; \
grep -Eq '^copier__project_name_raw:' "$$out_dir/copier.yml"; \
render_dir="$$(mktemp -d /tmp/scaf-template-rendered-gl-XXXXXX)"; \
copier copy "$$out_dir" "$$render_dir" --trust --defaults \
-d copier__configure_repo=false \
-d copier__enable_semantic_release=false \
-d copier__enable_secret_scanning=false \
-d copier__ci_provider="gitlab" \
-d copier__task_runner="just"; \
test -f "$$render_dir/.copier-answers.yml"; \
test ! -f "$$render_dir/{{_copier_conf.answers_file}}"; \
rm -rf "$$render_dir"; \
rm -rf "$$out_dir"
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Use this starter to generate new Scaf templates with validated Copier prompts,
GitHub/GitLab CI templates, optional semantic-release wiring (GitHub token or
GitHub App), optional gitleaks scanning, and generated `make`/`task`/`just`
`init`/`check` commands.
`init`/`check` commands in the emitted `template/` payload.

## Features

Expand All @@ -18,6 +18,7 @@ GitHub App), optional gitleaks scanning, and generated `make`/`task`/`just`
- Optional semantic-release setup and config
- Optional secret scanning in CI
- Template correctness CI (Copier render checks)
- Generated templates are emitted under `template/` in the produced repository
- Choice of local task runner (`make`, `task`, or `just`) with `init`/`check`
- Generated project docs for usage and upgrade flow
- Apache-2.0 license by default (license selection via Copier option planned)
Expand Down Expand Up @@ -60,9 +61,9 @@ CI runs the same command in `.github/workflows/template-render-tests.yaml`.

Each generated project includes:

- `docs/using-template.md`
- `docs/upgrading.md`
- `docs/semantic-release-github.md` (when GitHub + semantic-release is enabled)
- `template/docs/using-template.md`
- `template/docs/upgrading.md`
- `template/docs/semantic-release-github.md` (when GitHub + semantic-release is enabled)

These cover day-to-day usage and copier update workflow for downstream projects.

Expand Down
9 changes: 2 additions & 7 deletions copier.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
_templates_suffix: ""
_templates_suffix: ".jinja"
_subdirectory: template

_tasks:
- python tasks.py
- python .scaf/starter-post-copy.py

copier__project_name_raw:
type: str
Expand Down Expand Up @@ -138,8 +138,3 @@ copier__task_runner:
- make
- task
- just

copier__template_sample_name:
type: str
default: "sample"
help: "Sample project name used by template correctness CI."
20 changes: 11 additions & 9 deletions template/.github/workflows/template-correctness.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,23 @@ jobs:

- name: Render sample project
run: |
copier copy . /tmp/{{ copier__template_sample_name }} --trust --defaults \
copier copy . /tmp/sample-project --trust --defaults \
-d copier__project_name_raw="Sample Project" \
-d copier__project_slug="sample_project" \
-d copier__description="Sample generated project" \
-d copier__author_name="Sample Author" \
-d copier__email="sample@example.com" \
-d copier__version="0.1.0" \
-d copier__ci_provider="{{ copier__ci_provider }}" \
-d copier__enable_semantic_release={{ 'true' if copier__enable_semantic_release else 'false' }} \
-d copier__github_semantic_release_auth="{{ copier__github_semantic_release_auth }}" \
-d copier__enable_secret_scanning={{ 'true' if copier__enable_secret_scanning else 'false' }} \
-d copier__task_runner="{{ copier__task_runner }}"
-d copier__configure_repo=false \
-d copier__ci_provider="github" \
-d copier__enable_semantic_release=false \
-d copier__enable_secret_scanning=false \
-d copier__task_runner="task"

- name: Validate generated project files
run: |
test -f /tmp/{{ copier__template_sample_name }}/README.md
test -f /tmp/{{ copier__template_sample_name }}/copier.yml
test -f /tmp/{{ copier__template_sample_name }}/template/{{'Taskfile.yml' if copier__task_runner == 'task' else ('justfile' if copier__task_runner == 'just' else 'Makefile')}}
test -f /tmp/sample-project/README.md
test -f /tmp/sample-project/.copier-answers.yml
test -f /tmp/sample-project/Taskfile.yml
test ! -f /tmp/sample-project/Makefile
test ! -f /tmp/sample-project/justfile
Loading