Skip to content
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
36 changes: 15 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,24 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.12', '3.9', '3.10', '3.11']
python-version: ['3.10', '3.11', '3.12', '3.13']
fail-fast: false
env:
# cache busting if requirements haven't changed
CACHE_EPOCH: 1
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
- name: Cache pre-commit
uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install cookiecutter build
uv pip install --system cookiecutter build
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git config --global init.defaultBranch main
Expand All @@ -42,27 +36,27 @@ jobs:
GIT=$(which git)
sudo chmod -x ${GIT}
cookiecutter -v --no-input -f -o /tmp/cookie_python . project_slug=foo1-bar minimum_python_version=${{ matrix.python-version }}
python -m pip install /tmp/cookie_python/foo1-bar
uv pip install --system /tmp/cookie_python/foo1-bar
python -c "import foo1_bar; print(foo1_bar.__version__)"
python -m pip uninstall -y foo1
uv pip uninstall --system foo1-bar
sudo chmod +x ${GIT}
- name: with git only
run: |
cookiecutter -v --no-input -f -o /tmp/cookie_python . project_slug=foo2 minimum_python_version=${{ matrix.python-version }}
python -m pip install /tmp/cookie_python/foo2
python -m pip uninstall -y foo2
uv pip install --system /tmp/cookie_python/foo2
uv pip uninstall --system foo2
- name: with git and pre-commit
run: |
python -m pip install pre-commit
uv pip install --system pre-commit
cookiecutter -v --no-input -f -o /tmp/cookie_python . project_slug=foo3 minimum_python_version=${{ matrix.python-version }}
python -m pip install /tmp/cookie_python/foo3
python -m pip uninstall -y foo3
uv pip install --system /tmp/cookie_python/foo3
uv pip uninstall --system foo3
cd /tmp/cookie_python/foo3
python -c "import tests"
python -m pip install .[dev]
uv pip install --system .[dev]
make -C docs html
- name: upload generated projects
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
with:
name: cookie_python_${{ matrix.python-version }}
path: /tmp/cookie_python
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ repos:
hooks:
- id: yamlfix
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.3
rev: v0.9.0
hooks:
- id: ruff
- id: ruff-format
Expand Down
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"repository_url": "https://github.com/arup-group/{{cookiecutter.project_slug}}",
"create_git_repository": "yes",
"short_description": "One-liner to describe the package",
"minimum_python_version": "3.8",
"minimum_python_version": "3.10",
"_copy_without_render": [".github/*", "docs/_templates/autoapi/*", "docs/substitutions.py" ]
}
16 changes: 0 additions & 16 deletions {{cookiecutter.project_slug}}/.github/workflows/black.yml

This file was deleted.

28 changes: 0 additions & 28 deletions {{cookiecutter.project_slug}}/.github/workflows/linter.yml

This file was deleted.

This file was deleted.

20 changes: 20 additions & 0 deletions {{cookiecutter.project_slug}}/.github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: ruff
on: [pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install ruff
run: uv pip install --system ruff
- name: Run ruff format check
run: ruff format --check .
- name: Run ruff lint
run: ruff check .
27 changes: 13 additions & 14 deletions {{cookiecutter.project_slug}}/.github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,38 @@ jobs:
fail-fast: false
matrix:
config:
- {os: windows-2022, py: '3.7'}
- {os: ubuntu-22.04, py: '3.9'}
- {os: ubuntu-22.04, py: '3.10'}
- {os: ubuntu-22.04, py: '3.11'}
- {os: ubuntu-22.04, py: '3.12'}
- {os: ubuntu-22.04, py: '3.13'}

env:
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
OS: ${{ matrix.config.os }}
PYTHON: ${{ matrix.config.py }}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.8.0
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config.py }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[ci]
run: uv pip install --system .[ci]
- name: run pytest
run: |
pytest
run: pytest
- name: Upload coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
env_vars: OS,PYTHON
fail_ci_if_error: true
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: build docs
run: |
python -m pip install .[docs]
uv pip install --system .[docs]
make -C docs html
3 changes: 1 addition & 2 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ repos:
hooks:
- id: yamlfix
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.3
rev: v0.9.0
hooks:
- id: ruff
- id: ruff-format
Expand Down
7 changes: 4 additions & 3 deletions {{cookiecutter.project_slug}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ ENV_FILE?=.env
include $(ENV_FILE)
export $(shell sed 's/=.*//' $(ENV_FILE))

.PHONY: deps black docs
.PHONY: deps format docs

deps:
./dependencies.py

black:
black docs {{cookiecutter.project_slug}} tests
format:
ruff format .
ruff check --fix .

docs:
make -C docs html
25 changes: 13 additions & 12 deletions {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
[tool.black]
line-length = 120
skip-string-normalization = true

[tool.ruff]
target-version = "py{{ cookiecutter.minimum_python_version | replace(".", "") }}"
line-length = 120
extend-exclude = ["_version.py", "docs/conf.py"]

[tool.ruff.lint]
select = ["ALL"]
extend-ignore = ["E501", "ANN201", "ANN001", "D211", "D213"]
extend-exclude = ["_version.py", "docs/conf.py",]
fix = true
line-length = 120

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/*.py" = ["S101", "D103"]

[tool.pytest.ini_options]
Expand All @@ -35,9 +33,9 @@ python = "{{ cookiecutter.minimum_python_version }}"
[tool.hatch.envs.default.scripts]
test = "pytest"
lint = [
"black .",
"ruff --fix .",
"mypy src/{{ cookiecutter.__module_name }}/",
"ruff format .",
"ruff check --fix .",
"ty check src/{{ cookiecutter.__module_name }}/",
]

docs-build = "make -C docs html"
Expand Down Expand Up @@ -66,9 +64,12 @@ docs = ["sphinx>=6",
"sphinx-autoapi>=3",
"myst-nb>=0.18",
"furo>=2023.9.10"]
ci = [
"pytest",
"pytest-cov",
]
dev = [
"black",
"mypy",
"ty",
"ruff",
"pytest",
"pytest-cov",
Expand Down
Loading