Skip to content

Commit

Permalink
Convert to cookiecutter template
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdewar committed May 28, 2024
1 parent fb2f488 commit ce9a15e
Show file tree
Hide file tree
Showing 23 changed files with 401 additions and 42 deletions.
21 changes: 0 additions & 21 deletions .editorconfig

This file was deleted.

1 change: 1 addition & 0 deletions .editorconfig
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
8 changes: 8 additions & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"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"]
}
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
26 changes: 26 additions & 0 deletions {{ cookiecutter.project_slug }}/.github/PULL_REQUEST_TEMPLATE.md
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"
14 changes: 14 additions & 0 deletions {{ cookiecutter.project_slug }}/.github/workflows/check-links.yml
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Pre-commit auto-update

on:
schedule:
- cron: "0 0 * * 1" # midnight every Monday

jobs:
auto-update:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: browniebroke/pre-commit-autoupdate-action@main
- uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update/pre-commit-hooks
title: Update pre-commit hooks
commit-message: "chore: update pre-commit hooks"
body: Update versions of pre-commit hooks to latest version.
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 }}
129 changes: 129 additions & 0 deletions {{ cookiecutter.project_slug }}/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
3 changes: 3 additions & 0 deletions {{ cookiecutter.project_slug }}/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
# Disable checks here
MD013: false
Loading

0 comments on commit ce9a15e

Please sign in to comment.