From a788a9520b7309e45ebf398da7d1e56f9f2d7b7d Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Tue, 28 May 2024 15:31:03 +0100 Subject: [PATCH 1/7] Convert to cookiecutter template --- .editorconfig | 22 +-- .markdownlint.yaml | 4 +- .pre-commit-config.yaml | 11 -- .vscode | 1 + cookiecutter.json | 8 ++ myproject/__main__.py | 1 - {{ cookiecutter.project_slug }}/.editorconfig | 21 +++ .../.github/PULL_REQUEST_TEMPLATE.md | 26 ++++ .../.github/dependabot.yml | 15 ++ .../.github/workflows/check-links.yml | 14 ++ .../.github/workflows/ci.yml | 47 +++++++ .../workflows/pre-commit_autoupdate.yml | 20 +++ .../.github/workflows/publish.yml | 27 ++++ {{ cookiecutter.project_slug }}/.gitignore | 129 ++++++++++++++++++ .../.markdownlint.yaml | 3 + .../.pre-commit-config.yaml | 33 +++++ .../.vscode}/extensions.json | 0 .../.vscode}/settings.json | 0 {{ cookiecutter.project_slug }}/README.md | 45 ++++++ .../pyproject.toml | 11 +- .../test_{{ cookiecutter.project_slug}}.py | 2 +- .../__init__.py | 2 +- .../__main__.py | 1 + 23 files changed, 401 insertions(+), 42 deletions(-) mode change 100644 => 120000 .editorconfig mode change 100644 => 120000 .markdownlint.yaml create mode 120000 .vscode create mode 100644 cookiecutter.json delete mode 100644 myproject/__main__.py create mode 100644 {{ cookiecutter.project_slug }}/.editorconfig create mode 100644 {{ cookiecutter.project_slug }}/.github/PULL_REQUEST_TEMPLATE.md create mode 100644 {{ cookiecutter.project_slug }}/.github/dependabot.yml create mode 100644 {{ cookiecutter.project_slug }}/.github/workflows/check-links.yml create mode 100644 {{ cookiecutter.project_slug }}/.github/workflows/ci.yml create mode 100644 {{ cookiecutter.project_slug }}/.github/workflows/pre-commit_autoupdate.yml create mode 100644 {{ cookiecutter.project_slug }}/.github/workflows/publish.yml create mode 100644 {{ cookiecutter.project_slug }}/.gitignore create mode 100644 {{ cookiecutter.project_slug }}/.markdownlint.yaml create mode 100644 {{ cookiecutter.project_slug }}/.pre-commit-config.yaml rename {.vscode => {{ cookiecutter.project_slug }}/.vscode}/extensions.json (100%) rename {.vscode => {{ cookiecutter.project_slug }}/.vscode}/settings.json (100%) create mode 100644 {{ cookiecutter.project_slug }}/README.md rename pyproject.toml => {{ cookiecutter.project_slug }}/pyproject.toml (69%) rename tests/test_myproject.py => {{ cookiecutter.project_slug }}/tests/test_{{ cookiecutter.project_slug}}.py (72%) rename {myproject => {{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}}/__init__.py (55%) create mode 100644 {{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}/__main__.py diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 7ec55f1..0000000 --- a/.editorconfig +++ /dev/null @@ -1,21 +0,0 @@ -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 diff --git a/.editorconfig b/.editorconfig new file mode 120000 index 0000000..e725f5c --- /dev/null +++ b/.editorconfig @@ -0,0 +1 @@ +{{ cookiecutter.project_slug }}/.editorconfig \ No newline at end of file diff --git a/.markdownlint.yaml b/.markdownlint.yaml deleted file mode 100644 index 0c53543..0000000 --- a/.markdownlint.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -# Disable checks here -MD013: false diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 120000 index 0000000..974f181 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1 @@ +{{ cookiecutter.project_slug }}/.markdownlint.yaml \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e0de92c..c4eda0d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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: diff --git a/.vscode b/.vscode new file mode 120000 index 0000000..199e9bf --- /dev/null +++ b/.vscode @@ -0,0 +1 @@ +{{ cookiecutter.project_slug }}/.vscode \ No newline at end of file diff --git a/cookiecutter.json b/cookiecutter.json new file mode 100644 index 0000000..a5790c8 --- /dev/null +++ b/cookiecutter.json @@ -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"] +} diff --git a/myproject/__main__.py b/myproject/__main__.py deleted file mode 100644 index b9f1c2a..0000000 --- a/myproject/__main__.py +++ /dev/null @@ -1 +0,0 @@ -"""The entry point for the myproject program.""" diff --git a/{{ cookiecutter.project_slug }}/.editorconfig b/{{ cookiecutter.project_slug }}/.editorconfig new file mode 100644 index 0000000..7ec55f1 --- /dev/null +++ b/{{ cookiecutter.project_slug }}/.editorconfig @@ -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 diff --git a/{{ cookiecutter.project_slug }}/.github/PULL_REQUEST_TEMPLATE.md b/{{ cookiecutter.project_slug }}/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..0122e04 --- /dev/null +++ b/{{ cookiecutter.project_slug }}/.github/PULL_REQUEST_TEMPLATE.md @@ -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)) diff --git a/{{ cookiecutter.project_slug }}/.github/dependabot.yml b/{{ cookiecutter.project_slug }}/.github/dependabot.yml new file mode 100644 index 0000000..2138914 --- /dev/null +++ b/{{ cookiecutter.project_slug }}/.github/dependabot.yml @@ -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" diff --git a/{{ cookiecutter.project_slug }}/.github/workflows/check-links.yml b/{{ cookiecutter.project_slug }}/.github/workflows/check-links.yml new file mode 100644 index 0000000..ca347bb --- /dev/null +++ b/{{ cookiecutter.project_slug }}/.github/workflows/check-links.yml @@ -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" diff --git a/{{ cookiecutter.project_slug }}/.github/workflows/ci.yml b/{{ cookiecutter.project_slug }}/.github/workflows/ci.yml new file mode 100644 index 0000000..45ff975 --- /dev/null +++ b/{{ cookiecutter.project_slug }}/.github/workflows/ci.yml @@ -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 diff --git a/{{ cookiecutter.project_slug }}/.github/workflows/pre-commit_autoupdate.yml b/{{ cookiecutter.project_slug }}/.github/workflows/pre-commit_autoupdate.yml new file mode 100644 index 0000000..1b05599 --- /dev/null +++ b/{{ cookiecutter.project_slug }}/.github/workflows/pre-commit_autoupdate.yml @@ -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. diff --git a/{{ cookiecutter.project_slug }}/.github/workflows/publish.yml b/{{ cookiecutter.project_slug }}/.github/workflows/publish.yml new file mode 100644 index 0000000..2b13fae --- /dev/null +++ b/{{ cookiecutter.project_slug }}/.github/workflows/publish.yml @@ -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 }} diff --git a/{{ cookiecutter.project_slug }}/.gitignore b/{{ cookiecutter.project_slug }}/.gitignore new file mode 100644 index 0000000..b6e4761 --- /dev/null +++ b/{{ cookiecutter.project_slug }}/.gitignore @@ -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/ diff --git a/{{ cookiecutter.project_slug }}/.markdownlint.yaml b/{{ cookiecutter.project_slug }}/.markdownlint.yaml new file mode 100644 index 0000000..0c53543 --- /dev/null +++ b/{{ cookiecutter.project_slug }}/.markdownlint.yaml @@ -0,0 +1,3 @@ +--- +# Disable checks here +MD013: false diff --git a/{{ cookiecutter.project_slug }}/.pre-commit-config.yaml b/{{ cookiecutter.project_slug }}/.pre-commit-config.yaml new file mode 100644 index 0000000..e0de92c --- /dev/null +++ b/{{ cookiecutter.project_slug }}/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + 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 + rev: "0.28.3" + hooks: + - id: check-github-workflows + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 + hooks: + - id: prettier + # 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: + - id: markdownlint-fix diff --git a/.vscode/extensions.json b/{{ cookiecutter.project_slug }}/.vscode/extensions.json similarity index 100% rename from .vscode/extensions.json rename to {{ cookiecutter.project_slug }}/.vscode/extensions.json diff --git a/.vscode/settings.json b/{{ cookiecutter.project_slug }}/.vscode/settings.json similarity index 100% rename from .vscode/settings.json rename to {{ cookiecutter.project_slug }}/.vscode/settings.json diff --git a/{{ cookiecutter.project_slug }}/README.md b/{{ cookiecutter.project_slug }}/README.md new file mode 100644 index 0000000..cfc2917 --- /dev/null +++ b/{{ cookiecutter.project_slug }}/README.md @@ -0,0 +1,45 @@ +# {{ cookiecutter.project_name }} + +{{ cookiecutter.project_description }} + +This is a Python application that uses [poetry](https://python-poetry.org) for packaging +and dependency management. It also provides [pre-commit](https://pre-commit.com/) hooks +(for [ruff](https://pypi.org/project/ruff/) and +[mypy](https://mypy.readthedocs.io/en/stable/)) and automated tests using +[pytest](https://pytest.org/) and [GitHub Actions](https://github.com/features/actions). + +## For developers + +This is a Python application that uses [poetry](https://python-poetry.org) for packaging +and dependency management. It also provides [pre-commit](https://pre-commit.com/) hooks +for various linters and formatters and automated tests using +[pytest](https://pytest.org/) and [GitHub Actions](https://github.com/features/actions). +Pre-commit hooks are automatically kept updated with a dedicated GitHub Action. + +To get started: + +1. [Download and install Poetry](https://python-poetry.org/docs/#installation) following the instructions for your OS. +1. Clone this repository and make it your working directory +1. Set up the virtual environment: + + ```bash + poetry install + ``` + +1. Activate the virtual environment (alternatively, ensure any Python-related command is preceded by `poetry run`): + + ```bash + poetry shell + ``` + +1. Install the git hooks: + + ```bash + pre-commit install + ``` + +1. Run the main app: + + ```bash + python -m {{ cookiecutter.project_slug }} + ``` diff --git a/pyproject.toml b/{{ cookiecutter.project_slug }}/pyproject.toml similarity index 69% rename from pyproject.toml rename to {{ cookiecutter.project_slug }}/pyproject.toml index 37a1f22..f5128b3 100644 --- a/pyproject.toml +++ b/{{ cookiecutter.project_slug }}/pyproject.toml @@ -1,8 +1,11 @@ [tool.poetry] -name = "MyProject" +name = "{{ cookiecutter.project_slug }}" version = "0.1.0" -description = "" -authors = ["Jane Doe "] +description = "{{ cookiecutter.project_description }}" +authors = [ + "{{ cookiecutter.author }} <{{ cookiecutter.author_email }}>", + "Imperial College London RSE Team " +] [tool.poetry.dependencies] python = "^3.12" @@ -27,7 +30,7 @@ module = "tests.*" disallow_untyped_defs = false [tool.pytest.ini_options] -addopts = "-v --mypy -p no:warnings --cov=myproject --cov-report=html --doctest-modules --ignore=myproject/__main__.py" +addopts = "-v --mypy -p no:warnings --cov={{ cookiecutter.project_slug }} --cov-report=html --doctest-modules --ignore={{ cookiecutter.project_slug }}/__main__.py" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/tests/test_myproject.py b/{{ cookiecutter.project_slug }}/tests/test_{{ cookiecutter.project_slug}}.py similarity index 72% rename from tests/test_myproject.py rename to {{ cookiecutter.project_slug }}/tests/test_{{ cookiecutter.project_slug}}.py index a369f07..7b2cace 100644 --- a/tests/test_myproject.py +++ b/{{ cookiecutter.project_slug }}/tests/test_{{ cookiecutter.project_slug}}.py @@ -1,6 +1,6 @@ """Tests for the main module.""" -from myproject import __version__ +from {{ cookiecutter.project_slug }} import __version__ def test_version() -> None: diff --git a/myproject/__init__.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}/__init__.py similarity index 55% rename from myproject/__init__.py rename to {{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}/__init__.py index 8a0eea9..af3e610 100644 --- a/myproject/__init__.py +++ b/{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}/__init__.py @@ -1,4 +1,4 @@ -"""The main module for MyProject.""" +"""The main module for {{ cookiecutter.project_name }}.""" from importlib.metadata import version diff --git a/{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}/__main__.py b/{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}/__main__.py new file mode 100644 index 0000000..e82668e --- /dev/null +++ b/{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}/__main__.py @@ -0,0 +1 @@ +"""The entry point for the {{ cookiecutter.project_name }} program.""" From 710bc0c7cea201a35f008ce62a671b698e835286 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Tue, 28 May 2024 15:53:21 +0100 Subject: [PATCH 2/7] Add human readable prompts --- cookiecutter.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cookiecutter.json b/cookiecutter.json index a5790c8..d91d4b7 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -4,5 +4,12 @@ "project_description": "", "author": "Jane Doe", "author_email": "jane_doe@imperial.ac.uk", - "_copy_without_render": [".github"] + "_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" + } } From 9c1b0c94c5cb9ee233b23d8c97ce74d221d39375 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Tue, 28 May 2024 16:04:55 +0100 Subject: [PATCH 3/7] Remove unnecessary pre-commit CI workflows --- .github/workflows/ci.yml | 7 ------- .github/workflows/pre-commit_autoupdate.yml | 20 -------------------- 2 files changed, 27 deletions(-) delete mode 100644 .github/workflows/pre-commit_autoupdate.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45ff975..673a718 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,12 +3,6 @@ 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: @@ -20,7 +14,6 @@ jobs: use-verbose-mode: "yes" test: - needs: qa runs-on: ${{ matrix.os }} strategy: fail-fast: false diff --git a/.github/workflows/pre-commit_autoupdate.yml b/.github/workflows/pre-commit_autoupdate.yml deleted file mode 100644 index 1b05599..0000000 --- a/.github/workflows/pre-commit_autoupdate.yml +++ /dev/null @@ -1,20 +0,0 @@ -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. From ee671c823b39028597ab89ebb58e89d43b06c1f1 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Tue, 28 May 2024 16:20:29 +0100 Subject: [PATCH 4/7] CI: Don't run workflows on every push --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 673a718..c8ae25f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,10 @@ name: Test and build -on: [push, pull_request, workflow_call] +on: + push: + branches: [main] + pull_request: + workflow_dispatch: jobs: check-links: From b432a7e7085f5039a2a15c8ebf697e7dc06a24ab Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Tue, 28 May 2024 16:12:26 +0100 Subject: [PATCH 5/7] CI: Test project --- .github/workflows/ci.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8ae25f..e553126 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,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 From 860af7ec75532f3aa7865026d86aec265d10d85a Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Tue, 28 May 2024 16:29:23 +0100 Subject: [PATCH 6/7] Revert "Remove unnecessary tests/__init__.py file" This reverts commit da25d1ea7c721affd80d06e5e0d75d2c42578228. --- {{ cookiecutter.project_slug }}/tests/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 {{ cookiecutter.project_slug }}/tests/__init__.py diff --git a/{{ cookiecutter.project_slug }}/tests/__init__.py b/{{ cookiecutter.project_slug }}/tests/__init__.py new file mode 100644 index 0000000..76d8514 --- /dev/null +++ b/{{ cookiecutter.project_slug }}/tests/__init__.py @@ -0,0 +1,6 @@ +"""Unit tests for MyProject.""" + +from logging import getLogger + +# Disable flake8 logger as it can be rather verbose +getLogger("flake8").propagate = False From 278d96f4cf12e7f84688d43409a4048ad20f8fb7 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Tue, 28 May 2024 16:29:40 +0100 Subject: [PATCH 7/7] Revert "Add missing return-type annotation" This reverts commit 65d042117d54ac49a4d938cd2f835978d3f8c6dc. --- .../tests/test_{{ cookiecutter.project_slug}}.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{ cookiecutter.project_slug }}/tests/test_{{ cookiecutter.project_slug}}.py b/{{ cookiecutter.project_slug }}/tests/test_{{ cookiecutter.project_slug}}.py index 7b2cace..75e8ef8 100644 --- a/{{ cookiecutter.project_slug }}/tests/test_{{ cookiecutter.project_slug}}.py +++ b/{{ cookiecutter.project_slug }}/tests/test_{{ cookiecutter.project_slug}}.py @@ -3,6 +3,6 @@ from {{ cookiecutter.project_slug }} import __version__ -def test_version() -> None: +def test_version(): """Check that the version is acceptable.""" assert __version__ == "0.1.0"