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
2 changes: 1 addition & 1 deletion requirements/local.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-r testing.txt

tox==4.33.0
tox==4.42.0
tox-uv==1.29.0
2 changes: 1 addition & 1 deletion runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ COOKIECUTTER_DIR=$1
TEST_DIR=$(mktemp -d)
cookiecutter --no-input -o "$TEST_DIR" "$COOKIECUTTER_DIR"
pushd "$TEST_DIR/projectname"
tox
uv run --frozen --group testing --no-dev tox
popd
rm -rf "$TEST_DIR"
25 changes: 25 additions & 0 deletions {{cookiecutter.project_slug}}/.github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Cache
on:
push:
branches:
- main
permissions:
contents: read
jobs:
cache:
name: Setup ${{ github.ref_name }} cache
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@v6
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
prune-cache: false
- name: Install packages for cache
run: uv sync --frozen --group testing --no-dev
15 changes: 10 additions & 5 deletions {{cookiecutter.project_slug}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on: pull_request
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
name: Test -- tox
Expand All @@ -16,10 +18,10 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Python
uses: actions/setup-python@v6
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: 'requirements/*.txt'
prune-cache: false
- name: Setup Node.js
uses: actions/setup-node@v6
with:
Expand All @@ -32,6 +34,9 @@ jobs:
**/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('.nvmrc', 'package.json', 'package-lock.json') }}
- name: Run tests
env:
RUFF_OUTPUT_FORMAT: github
TOX_OVERRIDE: "testenv.pass_env=RUFF_OUTPUT_FORMAT"
run: |
pip install $(grep -E "^(tox|tox-uv)==" requirements/local.txt)
tox
echo "::add-matcher::.github/workflows/matchers/ruff.json"
uv run --frozen --group testing --no-dev tox
14 changes: 14 additions & 0 deletions {{cookiecutter.project_slug}}/.github/workflows/matchers/ruff.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"problemMatcher": [
{
"owner": "ruff",
"pattern": [
{
"regexp": "^(Would reformat): (.+)$",
"message": 1,
"file": 2
}
]
}
]
}
1 change: 1 addition & 0 deletions {{cookiecutter.project_slug}}/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.14
19 changes: 9 additions & 10 deletions {{cookiecutter.project_slug}}/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
FROM python:3.14-slim-trixie
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
WORKDIR /app
COPY requirements/ /app/requirements/
RUN pip install \
--disable-pip-version-check \
--no-cache-dir \
uv
RUN uv pip install \
--system \
--no-cache-dir \
--compile-bytecode \
--requirement /app/requirements/production.txt
ENV UV_PROJECT_ENVIRONMENT=/usr/local
COPY pyproject.toml uv.lock /app/
RUN uv sync \
--frozen \
--no-cache \
--compile-bytecode \
--group production \
--no-dev
COPY . /app
ARG SENTRY_RELEASE
RUN echo "$SENTRY_RELEASE" > .sentry-release
Expand Down
36 changes: 20 additions & 16 deletions {{cookiecutter.project_slug}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ SHELL=/bin/bash
help: ## This help dialog.
help: help-display

clean: ## Remove unneeded files generated from the various build tasks.
clean: coverage-clean
nuke: ## Full wipe of the local environment, uncommitted files, and database.
nuke: venv-check venv-wipe git-full-clean

reset: ## Reset your local environment. Useful after switching branches, etc.
reset: venv-check venv-wipe install-local
Expand All @@ -32,7 +32,7 @@ clear: ## Like reset but without the wiping of the installs.
clear: ;

check: ## Check for any obvious errors in the project's setup.
check: pipdeptree-check npm-check
check: uv-check npm-check

format: ## Run this project's code formatters.
format: ruff-format
Expand Down Expand Up @@ -68,23 +68,32 @@ ifndef VIRTUAL_ENV
endif

venv-wipe: venv-check
if ! pip list --format=freeze | grep -v "^pip=\|^setuptools=\|^wheel=" | xargs pip uninstall -y; then \
echo "Nothing to remove"; \
fi
uv pip freeze | uv pip uninstall -r -


# Destructive cleaning
git-full-clean:
git clean -ffdx


# Installs
install-local: npm-install pip-install-local
install-local: npm-install uv-install-local


# UV
uv-install-local: venv-check
uv sync --active --frozen --dev

# Pip
pip-install-local: venv-check
pip install -r requirements/local.txt
uv-upgrade: venv-check
uv lock --upgrade

uv-check: venv-check
uv lock --check


# Fabfile
fab-deploy:
fab deploy
fab $${site:-live} deploy


# Coverage
Expand Down Expand Up @@ -121,11 +130,6 @@ ruff-format:
ruff format


#pipdeptree
pipdeptree-check:
pipdeptree --warn fail > /dev/null


# Local server
flask-serve:
FLASK_APP=project FLASK_DEBUG=1 python -m flask run
Expand Down
6 changes: 6 additions & 0 deletions {{cookiecutter.project_slug}}/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
env.stage = env.get("stage", "production")


@task
def live():
# Intentional no-op for make commands, this is the default
pass


@task
def demo():
"""
Expand Down
27 changes: 27 additions & 0 deletions {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
[project]
version = "0.0"
name = "{{ cookiecutter.project_slug }}"
requires-python = "==3.14.*"
dependencies = [
"flask<4.0",
"sentry-sdk<3.0",
"serverless-wsgi<4.0",
]

[dependency-groups]
production = [
"awslambdaric<4.0",
]
testing = [
"coverage<8.0",
"pytest<10.0",
"pytest-flask<2.0",
"ruff<0.16",
"tox-uv<2.0",
]
dev = [
{include-group = "testing"},
"ipdb<0.14",
"pipdeptree<3.0",
]

[tool.black]
line-length = 99
target-version = ["py314"]
Expand Down
21 changes: 0 additions & 21 deletions {{cookiecutter.project_slug}}/requirements/base.txt

This file was deleted.

5 changes: 0 additions & 5 deletions {{cookiecutter.project_slug}}/requirements/local.txt

This file was deleted.

1 change: 0 additions & 1 deletion {{cookiecutter.project_slug}}/requirements/production.txt

This file was deleted.

7 changes: 0 additions & 7 deletions {{cookiecutter.project_slug}}/requirements/testing.txt

This file was deleted.

5 changes: 2 additions & 3 deletions {{cookiecutter.project_slug}}/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ no_package = true

[testenv]
basepython = python3.14
deps =
-rrequirements/base.txt
-rrequirements/testing.txt
runner = uv-venv-lock-runner
allowlist_externals = make
dependency_groups = testing
commands =
make check
make lint
Expand Down
Loading