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
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
19 changes: 19 additions & 0 deletions .github/workflows/dependabot-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Add dependabot PRs to flash reviews
on:
pull_request:
types:
- opened
- reopened
- labeled

jobs:
add_flash_review:
name: Add dependabot PRs to flash reviews
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@v2.0.0
with:
project-url: https://github.com/orgs/ISISComputingGroup/projects/17
github-token: ${{ secrets.PROJECT_TOKEN }}
labeled: dependencies
label-operator: OR
36 changes: 36 additions & 0 deletions .github/workflows/test-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test copier template
on: [push, workflow_call]

jobs:
test-copier-template:
runs-on: ubuntu-latest
steps:
- uses: astral-sh/setup-uv@v7
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: install copier
run: uv tool install copier
- name: expand template
run: copier copy --defaults --data-file test_project.yml --vcs-ref=HEAD . /tmp/expanded_template
- name: Git init in generated project
run: git init .
working-directory: /tmp/expanded_template
- name: Make venv in generated project
run: uv sync --extra dev
working-directory: /tmp/expanded_template
- name: Run pytest in generated project
run: uv run pytest
working-directory: /tmp/expanded_template
- name: Run ruff format check in generated project
run: uv run ruff format --check
working-directory: /tmp/expanded_template
- name: Run ruff check in generated project
run: uv run ruff check
working-directory: /tmp/expanded_template
- name: Run pyright in generated project
run: uv run pyright
working-directory: /tmp/expanded_template
- name: Build docs in generated project
run: uv run sphinx-build doc _build
working-directory: /tmp/expanded_template
6 changes: 5 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BSD 2-Clause License
BSD 3-Clause License

Copyright (c) 2026, ISIS Experiment Controls Computing

Expand All @@ -12,6 +12,10 @@ modification, are permitted provided that the following conditions are met:
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Python Copier template

This is a template, for use by [copier](https://copier.readthedocs.io/en/stable/), which creates or updates python
repositories to our standard layout.

See the [copier documentation](https://copier.readthedocs.io/en/stable/) for details of how to use this template.

## Creating a repository

Assume that `copier_template` and a blank new repository, `my_project`, are checked out into the same parent directory:
- Run `uv tool install copier`
- Run `copier copy ./copier_template ./my_project`
- Answer the prompts
- `git commit` the resulting structure into `my_project`

## Updating a generated repository

- Run `copier update ./my_project`

## Developing the template itself

Run copier as normal, but use the `--vcs-ref=HEAD` flag to force copier to use the locally-checked-out template
rather than a tagged version.

CI runs in *this* repository to check that copier can successfully instantiate the template in this repo.
58 changes: 58 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
_subdirectory: template

project_name:
type: str
help: What is your project name (user-friendly string)?
project_short_description:
type: str
help: A short one-sentence description of this project
validator: >-
{% if not project_short_description.strip() %}
Description must not be empty.
{% elif '\n' in project_short_description %}
Description must be a single line.
{% elif not project_short_description[0].isupper() %}
Description must start with a capital letter.
{% elif not project_short_description.endswith('.') %}
Description must end with a full stop.
{% endif %}
module_name:
type: str
help: What is your Python module name?
validator: >-
{% if not module_name | regex_search('^[a-z][a-z0-9_]+$') %}
Must be a valid Python module name
{% endif %}
github_org_name:
type: str
help: GitHub organisation name
default: ISISComputingGroup
github_repo_name:
type: str
help: GitHub repository name
publish_to_pypi:
type: bool
help: Should this project be set up to publish to (public) pypi?
doc_theme_colour:
type: str
help: Theme colour for documentation
validator: >-
{% if not doc_theme_colour | regex_search('^#[0-9A-Fa-f]{6}$') %}
Must be a 6-digit hex colour including the leading '#', e.g. #7D7D7D.
{% endif %}
ci_os_platforms:
type: yaml
help: Operating systems to test in CI
default: ["ubuntu-latest", "windows-latest"]
ci_python_versions:
type: yaml
help: Python versions to test in CI
default: ["3.12", "3.13", "3.14"]

_message_after_copy: |
Your project "{{ project_name }}" has been created successfully!

Remember to:
- git init .
- git push
- Create a new branch for your next feature
10 changes: 10 additions & 0 deletions template/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
18 changes: 18 additions & 0 deletions template/.github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
changelog:
exclude:
labels:
- Semver-Ignore
categories:
- title: Breaking Changes
labels:
- Semver-Major
- title: New Features
labels:
- Semver-Minor
- title: Bug Fixes
labels:
- Semver-Patch
- title: Other Changes
labels:
- Semver-Docs
- "*"
40 changes: 40 additions & 0 deletions template/.github/workflows/Lint-and-test.yml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Lint-and-test
on: [push, workflow_call]
jobs:
tests:
runs-on: ${{ '{{' }} matrix.os {{ '}}' }}
strategy:
matrix:
os: {{ ci_os_platforms | tojson }}
version: {{ ci_python_versions | tojson }}
fail-fast: false
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ '{{' }} matrix.version {{ '}}' }}
- name: install requirements
run: uv sync --extra lint --extra test
- name: run ruff check
run: uv run ruff check
- name: run ruff format --check
run: uv run ruff format --check
- name: run pyright
run: uv run pyright
- name: run pytest
run: uv run pytest
results:
if: ${{ '{{' }} always() {{ '}}' }}
runs-on: ubuntu-latest
name: Final Results
needs: [tests]
steps:
- run: exit 1
# see https://stackoverflow.com/a/67532120/4907315
if: >-
${{ '{{' }}
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
{{ '}}' }}
24 changes: 24 additions & 0 deletions template/.github/workflows/check_pr_has_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Check PR has release labels
on:
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
- unlabeled

jobs:
has_label:
name: Check PR has release labels
runs-on: ubuntu-latest
steps:
- run: |
echo "PR does not have a release label."
exit 1
if: |
!contains(github.event.pull_request.labels.*.name, 'Semver-Patch') &&
!contains(github.event.pull_request.labels.*.name, 'Semver-Major') &&
!contains(github.event.pull_request.labels.*.name, 'Semver-Minor') &&
!contains(github.event.pull_request.labels.*.name, 'Semver-Docs') &&
!contains(github.event.pull_request.labels.*.name, 'Semver-Ignore')
19 changes: 19 additions & 0 deletions template/.github/workflows/dependabot-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Add dependabot PRs to flash reviews
on:
pull_request:
types:
- opened
- reopened
- labeled

jobs:
add_flash_review:
name: Add dependabot PRs to flash reviews
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@v2.0.0
with:
project-url: https://github.com/orgs/ISISComputingGroup/projects/17
github-token: ${{ secrets.PROJECT_TOKEN }}
labeled: dependencies
label-operator: OR
38 changes: 38 additions & 0 deletions template/.github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: sphinx

on: [push, workflow_call]

jobs:
docs:
permissions:
contents: write
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v7
with:
python-version: "3.14"
- name: install requirements
run: uv sync --extra doc
- name: Sphinx build
run: uv run sphinx-build -E -a -W --keep-going doc _build
- name: run spellcheck
run: uv run sphinx-build -E -a -W --keep-going -b spelling doc _build
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: documentation
path: |
_build
if-no-files-found: error
retention-days: 7
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/
force_orphan: true
9 changes: 9 additions & 0 deletions template/.github/workflows/lint-and-test-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: lint-and-test-nightly
on:
schedule:
- cron: "18 23 * * *"
workflow_dispatch:

jobs:
lint-and-test-nightly:
uses: ./.github/workflows/Lint-and-test.yml
Loading
Loading