Skip to content
Open
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
80 changes: 18 additions & 62 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,91 +9,47 @@ on:

jobs:
test-project-creation:
name: Test project creation with ${{ matrix.typing }} typing
name: Test project creation (min_python=${{ matrix.min_python }}, docs=${{ matrix.docs }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
typing: [no_typing, loose, strict]
min_python: ["3.11", "3.12", "3.13"]
docs: [true, false]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install Dependencies
run: |
pip install copier pre-commit
- uses: astral-sh/setup-uv@v5
- name: Install copier
run: pip install copier
- name: Create new project
run: |
mkdir my-project
copier copy \
-d project_name=test \
-d project_name=test-project \
-d project_short_description="A great package." \
-d python_name=test \
-d url=https://github.com/gh_actions/test \
-d min_python_version=3.10 \
-d org=gh_actions \
-d python_name=test_project \
-d full_name=gh_actions \
-d email=foo@example.com \
-d license=BSD \
-d backend=setuptools \
-d typing=${{ matrix.typing }} \
-d coc=our_coc \
-d license=MIT \
-d min_python_version=${{ matrix.min_python }} \
-d include_docs=${{ matrix.docs }} \
-d org=gh_actions \
-d url=https://github.com/gh_actions/test-project \
--vcs-ref HEAD \
. my-project
- name: Check generated project installs with pip
- name: Verify project
run: |
cd my-project
git config --global user.email "foo@example.com"
git config --global user.name "gh_actions"
git init
git add .
git commit -m "Initial commit"
pip install -e .

format-created-project:
name: Try formatting the created project with ${{ matrix.typing }} typing
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
typing: [no_typing, loose, strict]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install Dependencies
run: |
pip install copier pre-commit
- name: Create new project
run: |
mkdir my-project
copier copy \
-d project_name=test \
-d project_short_description="A great package." \
-d python_name=test \
-d url=https://github.com/gh_actions/test \
-d min_python_version=3.10 \
-d org=gh_actions \
-d full_name=gh_actions \
-d email=foo@example.com \
-d license=BSD \
-d backend=setuptools \
-d typing=${{ matrix.typing }} \
-d coc=our_coc \
--vcs-ref HEAD \
. my-project
- name: Run formatting checks
run: |
cd my-project
git init
git config --global user.email "foo@example.com"
git config --global user.name "gh_actions"
git add --all
git commit -m "Initial commit"
pre-commit run --all-files
uv sync
uv run pytest || true
uv run ruff check .
uv run ruff format --check .
92 changes: 44 additions & 48 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,83 +4,79 @@ _templates_suffix: ""
_skip_if_exists:
- CHANGELOG.md

_tasks:
- "git init"
- "uv sync"
- "uv run pre-commit install"

# PROMPT --------------------------------
project_name:
type: str
help: Please provide the name of your project.
validator: >-
{% if not project_name %} You must provide a name for the project. {% endif
%}

org:
type: str
help: What GitHub user is this project under?
help: The name of your project (used for the directory, package name, and repo).
validator: >-
{% if not org %} You must provide a org for the project. It might just be
your user name on the site (like GitHub) you are targeting. {% endif %}
{% if not project_name %} You must provide a name for the project. {% endif %}

url:
project_short_description:
type: str
help: Provide/modify the url to your GitHub repository if needed.
default: "https://github.com/{{org}}/{{project_name}}"
help: A short description of your project.
default: A Python project

python_name:
type: str
help: The Python package import name (for `import NAME` in Python code)
help: The Python package import name (for `import NAME` in Python code).
default: "{{ project_name|lower|replace('-', '_')|replace(' ', '_') }}"
validator: >-
{% if not (python_name | regex_search('^[a-zA-Z_][a-zA-Z0-9_]*$')) %}
Must be a valid Python identifier (letters, digits, underscores; cannot start with a digit).
{% endif %}

full_name:
type: str
help: Who's the main responsible for this code?
help: Author name.
placeholder: My Name
validator: >-
{% if not full_name %} You must provide a name (possibly yours) to place in
your config files. {% endif %}
{% if not full_name %} You must provide an author name. {% endif %}

email:
type: str
help: What's their email?
help: Author email.
placeholder: me@email.com
validator: >-
{% if not (email | regex_search('^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$')) %}
You must provide a valid email to place in
your config files.
{% if not (email | regex_search('^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$')) %}
You must provide a valid email address.
{% endif %}

project_short_description:
type: str
help: Write a short description of your project.
default: A great package.

license:
type: str
help: Select a license
help: Select a license.
choices:
- BSD
- Apache
- MIT
- GPL
MIT: MIT
BSD-3-Clause: BSD
Apache-2.0: Apache
GPL-3.0-or-later: GPL

min_python_version:
type: str
help: What is the minimum version of Python your project will support? (Defaults to minimum supported by NumPy)
default: "3.10"
validator: >-
{% if not (min_python_version | regex_search('[3][.][0-9]+')) %}
Please supply a valid Python 3 version (e.g. 3.11).
{% endif %}
help: Minimum Python version to support.
default: "3.11"
choices:
"3.11": "3.11"
"3.12": "3.12"
"3.13": "3.13"

include_docs:
type: bool
help: Include MkDocs Material documentation scaffolding?
default: true

typing:
org:
type: str
help: Would you like to use static type checking? (This configures mypy.)
choices:
"No/I'll configure it myself.": no_typing
"Basic type checking (type annotations not required).": loose
"Full type checking (type annotations required).": strict
help: GitHub organisation or username.
default: alan-turing-institute
validator: >-
{% if not org %} You must provide a GitHub org or username. {% endif %}

coc:
url:
type: str
help: We provide a basic Code of Conduct that can be modified to suit the needs of your project. Would you like to use this, or write your own?
choices:
"I'll use/modify the basic Code of Conduct.": our_coc
"I'll write my own Code of Conduct.": their_coc
help: Repository URL.
default: "https://github.com/{{org}}/{{project_name}}"
Loading