Repository navigation
Add copier template #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # 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 a blank new repository, `my_project`, is checked out: | ||
| - Run `uv tool install copier` | ||
| - Run `copier copy https://github.com/ISISComputingGroup/copier_template.git ./my_project` | ||
|
|
||
| Or, clone and use the template locally: | ||
| - 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 pointed at the locally-checked out copy, but use the `--vcs-ref=HEAD` flag to force copier to use the most recent local commit. | ||
| rather than a tagged version. | ||
|
|
||
| CI runs in *this* repository to check that copier can successfully instantiate the template in this repo. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| - "*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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') | ||
| {{ '}}' }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.