Skip to content
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

Port to cookiecutter #2

Merged
merged 7 commits into from
May 28, 2024
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
21 changes: 0 additions & 21 deletions .editorconfig

This file was deleted.

1 change: 1 addition & 0 deletions .editorconfig
24 changes: 15 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
name: Test and build

on: [push, pull_request, workflow_call]
on:
push:
branches: [main]
pull_request:
workflow_dispatch:

jobs:
qa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pre-commit/action@v3.0.1

check-links:
runs-on: ubuntu-latest
steps:
Expand All @@ -20,7 +18,6 @@ jobs:
use-verbose-mode: "yes"

test:
needs: qa
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -40,8 +37,17 @@ jobs:
with:
poetry-version: 1.2.2

- name: Install dependencies
- name: Install cookiecutter
run: pip install cookiecutter

- name: Create project from template
# Choose default options
run: cookiecutter --no-input .

- name: Install project dependencies
working-directory: my_project
run: poetry install

- name: Run tests
working-directory: my_project
run: poetry run pytest
3 changes: 0 additions & 3 deletions .markdownlint.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .markdownlint.yaml
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ repos:
rev: v4.6.0
hooks:
- id: check-merge-conflict
- id: debug-statements
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/python-jsonschema/check-jsonschema
Expand All @@ -17,16 +16,6 @@ repos:
# Prettier supports many other file formats (e.g., JavaScript, HTML; see
# https://prettier.io for list). Add other types here.
types_or: [yaml, json]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.4"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.10.0"
hooks:
- id: mypy
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.40.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions .vscode
15 changes: 15 additions & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"project_name": "My Project",
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_') }}",
"project_description": "",
"author": "Jane Doe",
"author_email": "jane_doe@imperial.ac.uk",
"_copy_without_render": [".github"],
"__prompts__": {
"project_name": "Enter a human-readable name for the project",
"project_slug": "Enter a name for the Python package",
"project_description": "Enter a brief description of the project",
"author": "Enter your full name",
"author_email": "Enter your email address"
}
}
1 change: 0 additions & 1 deletion myproject/__main__.py

This file was deleted.

21 changes: 21 additions & 0 deletions {{ cookiecutter.project_slug }}/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
root = true

[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
max_line_length = 88

[*.md]
indent_size = 2

[*.yaml]
indent_size = 2

[*.yml]
indent_size = 2

[Makefile]
indent_style = tab
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Description

_Please include a summary of the change and which issue is fixed (if any). Please also
include relevant motivation and context. List any dependencies that are required for
this change._

Fixes # (issue)

## Type of change

- [ ] Documentation (non-breaking change that adds or improves the documentation)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Optimization (non-breaking, back-end change that speeds up the code)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Breaking change (whatever its nature)

## Key checklist

- [ ] All tests pass (eg. `python -m pytest`)
- [ ] The documentation builds and looks OK (eg. `python -m sphinx -b html docs docs/build`)
- [ ] Pre-commit hooks run successfully (eg. `pre-commit run --all-files`)

## Further checks

- [ ] Code is commented, particularly in hard-to-understand areas
- [ ] Tests added or an issue has been opened to tackle that in the future. (Indicate issue here: # (issue))
15 changes: 15 additions & 0 deletions {{ cookiecutter.project_slug }}/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Check links in Markdown files
on:
schedule:
- cron: "0 0 * * 1" # midnight every Monday

jobs:
check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: "yes"
use-verbose-mode: "yes"
47 changes: 47 additions & 0 deletions {{ cookiecutter.project_slug }}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Test and build

on: [push, pull_request, workflow_call]

jobs:
qa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pre-commit/action@v3.0.1

check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gaurav-nelson/github-action-markdown-link-check@v1
name: Check links in markdown files
with:
use-quiet-mode: "yes"
use-verbose-mode: "yes"

test:
needs: qa
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: ["3.12"]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: 1.2.2

- name: Install dependencies
run: poetry install

- name: Run tests
run: poetry run pytest
27 changes: 27 additions & 0 deletions {{ cookiecutter.project_slug }}/.github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on: [release]

jobs:
test:
uses: ./.github/workflows/ci.yml

# publish:
# runs-on: ubuntu-latest
# needs: test
# # The following steps to build a Docker image and publish to the GitHub container registry on release. Alternatively, can replace with other publising steps (ie. publishing to PyPI, deploying documentation etc.)
# steps:
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Get image metadata
# id: meta
# uses: docker/metadata-action@v5
# with:
# images: ghcr.io/${{ github.repository }}
# - name: Build and push Docker image
# uses: docker/build-push-action@v5
# with:
# push: true
# tags: ${{ steps.meta.outputs.tags }}
Loading