-
Notifications
You must be signed in to change notification settings - Fork 1
Add local QA helpers and python 3.13/trixie support #20
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
Open
dannystaple
wants to merge
11
commits into
pimoroni:main
Choose a base branch
from
dannystaple:ci-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b210066
Add local QA helpers
dannystaple eac6693
Fix for Comment on uv version
dannystaple cf1c3b8
And this
dannystaple 93bf7db
Copy ownership
dannystaple f3f5732
Decided against this - it may need some library specific intervention…
dannystaple 9921898
Restore original order
dannystaple aba5f3a
Add the other python versions in - including 3.13
dannystaple e543cc9
What I was really here for next - python 3.13 and trixie
dannystaple 8b916bb
Doh
dannystaple 4340434
Python 3.9 - looks like hatch no longer works?
dannystaple 559ad1f
Whoops
dannystaple File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| # syntax=docker/dockerfile:1 | ||
| # Tagging convention: boilerplate-dev:python<python-ver>-v<testing-ver> | ||
| # python-ver — Python minor version used in the image (e.g. 3.13) | ||
| # testing-ver — Independent semver for the testing environment itself. | ||
| # Unlike library repos (where the testing version tracks the | ||
| # library release), this boilerplate has no release version of | ||
| # its own. Start at v0.0.1 and increment whenever the | ||
| # Dockerfile or its pinned dependencies change materially: | ||
| # patch — dependency bumps, minor tool config tweaks | ||
| # minor — new tools added, Python minor version bump | ||
| # major — breaking changes to the dev workflow | ||
| # | ||
| # Build a specific target: | ||
| # docker build \ | ||
| # --build-arg UID=$(id -u) --build-arg GID=$(id -g) \ | ||
| # --target testing-3.13 \ | ||
| # -f Dockerfile.testing -t boilerplate-dev:python3.13-v0.0.1 . | ||
| # | ||
| # Available targets: testing-3.9 testing-3.10 testing-3.11 testing-3.13 | ||
| # Default target : testing (alias for testing-3.13, matching Debian Trixie) | ||
| # | ||
| # Base image mapping (matches the Debian release that shipped each Python): | ||
| # 3.9 → python:3.9-slim-bullseye (Debian 11 — note: NOT buster; buster=3.7) | ||
| # 3.10 → python:3.10-slim-bookworm (Debian 12) | ||
| # 3.11 → python:3.11-slim-bookworm (Debian 12) | ||
| # 3.13 → python:3.13-slim-trixie (Debian 13) | ||
| # | ||
| # Note: testing-3.9 uses plain pip (not uv) because the shared lockfile | ||
| # was compiled for Python 3.11 and anyio>=4.0 requires Python>=3.10. | ||
| # | ||
| # Run: | ||
| # docker run --rm -it \ | ||
| # -v "$(pwd)":/app \ | ||
| # boilerplate-dev:python3.13-v0.0.1 \ | ||
| # make check | ||
|
|
||
| # ── Global build args ───────────────────────────────────────────────────────── | ||
| # Defaults live here; each stage redeclares with a bare ARG to inherit them. | ||
| ARG UID=1000 | ||
| ARG GID=1000 | ||
|
|
||
| # ── Shared uv binary ────────────────────────────────────────────────────────── | ||
| # Pin uv version once here; all testing stages except 3.9 copy from this stage. | ||
| FROM ghcr.io/astral-sh/uv:0.11.17 AS uv-base | ||
|
|
||
| # ── Python 3.9 (Debian Bullseye) — plain pip, no lockfile ──────────────────── | ||
| FROM python:3.9-slim-bullseye AS testing-3.9 | ||
| # hadolint ignore=DL3008 | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| make \ | ||
| dos2unix \ | ||
| shellcheck \ | ||
| git \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| ARG UID | ||
| ARG GID | ||
| RUN groupadd -g "${GID}" appuser \ | ||
| && useradd -l -u "${UID}" -g "${GID}" -m appuser | ||
| WORKDIR /app | ||
| COPY requirements-dev.txt ./ | ||
| # hadolint ignore=DL3013 | ||
| RUN pip install --no-cache-dir -r requirements-dev.txt | ||
| COPY --chown=appuser:appuser . . | ||
| USER appuser | ||
| RUN git config --global --add safe.directory /app | ||
|
|
||
| # ── Python 3.10 (Debian Bookworm) ───────────────────────────────────────────── | ||
| FROM python:3.10-slim-bookworm AS testing-3.10 | ||
| COPY --from=uv-base /uv /uvx /usr/local/bin/ | ||
| # hadolint ignore=DL3008 | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| make \ | ||
| dos2unix \ | ||
| shellcheck \ | ||
| git \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| ARG UID | ||
| ARG GID | ||
| RUN groupadd -g "${GID}" appuser \ | ||
| && useradd -l -u "${UID}" -g "${GID}" -m appuser | ||
| WORKDIR /app | ||
| COPY requirements-dev.lock ./ | ||
| RUN uv pip install --system --no-cache -r requirements-dev.lock | ||
| COPY --chown=appuser:appuser . . | ||
| USER appuser | ||
| RUN git config --global --add safe.directory /app | ||
|
|
||
| # ── Python 3.11 (Debian Bookworm) ───────────────────────────────────────────── | ||
| FROM python:3.11-slim-bookworm AS testing-3.11 | ||
| COPY --from=uv-base /uv /uvx /usr/local/bin/ | ||
| # hadolint ignore=DL3008 | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| make \ | ||
| dos2unix \ | ||
| shellcheck \ | ||
| git \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| ARG UID | ||
| ARG GID | ||
| RUN groupadd -g "${GID}" appuser \ | ||
| && useradd -l -u "${UID}" -g "${GID}" -m appuser | ||
| WORKDIR /app | ||
| COPY requirements-dev.lock ./ | ||
| RUN uv pip install --system --no-cache -r requirements-dev.lock | ||
| COPY --chown=appuser:appuser . . | ||
| USER appuser | ||
| RUN git config --global --add safe.directory /app | ||
|
|
||
| # ── Python 3.13 (Debian Trixie) ────────────────────────────────────────────── | ||
| FROM python:3.13-slim-trixie AS testing-3.13 | ||
| COPY --from=uv-base /uv /uvx /usr/local/bin/ | ||
| # hadolint ignore=DL3008 | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| make \ | ||
| dos2unix \ | ||
| shellcheck \ | ||
| git \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| ARG UID | ||
| ARG GID | ||
| RUN groupadd -g "${GID}" appuser \ | ||
| && useradd -l -u "${UID}" -g "${GID}" -m appuser | ||
| WORKDIR /app | ||
| COPY requirements-dev.lock ./ | ||
| RUN uv pip install --system --no-cache -r requirements-dev.lock | ||
| COPY --chown=appuser:appuser . . | ||
| USER appuser | ||
| RUN git config --global --add safe.directory /app | ||
|
|
||
| # ── Default alias (Trixie = 3.13) ───────────────────────────────────────────── | ||
| FROM testing-3.13 AS testing | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Local QA with Docker | ||
|
|
||
| A Docker-based testing image is provided so checks can be run on any machine without | ||
| installing tooling locally. Four Python versions are supported, each on the Debian release | ||
| that shipped it: | ||
|
|
||
| | Target | Python | Debian base | | ||
| |---|---|---| | ||
| | `testing-3.9` | 3.9 | Bullseye (11) | | ||
| | `testing-3.10` | 3.10 | Bookworm (12) | | ||
| | `testing-3.11` | 3.11 | Bookworm (12) | | ||
| | `testing-3.13` | 3.13 | Trixie (13) — default | | ||
|
|
||
| ## Build the image | ||
|
|
||
| Pass your host UID and GID so that files written inside the container are owned by your | ||
| user, not root. Use `--target` to select a Python version; omit it to get the default | ||
| (Python 3.13 / Trixie): | ||
|
|
||
| ```bash | ||
| # Default (Python 3.13 / Trixie) | ||
| docker build -f Dockerfile.testing \ | ||
| --build-arg UID=$(id -u) \ | ||
| --build-arg GID=$(id -g) \ | ||
| -t boilerplate-dev:python3.13-v0.0.1 . | ||
|
|
||
| # Specific version | ||
| docker build -f Dockerfile.testing \ | ||
| --build-arg UID=$(id -u) \ | ||
| --build-arg GID=$(id -g) \ | ||
| --target testing-3.11 \ | ||
| -t boilerplate-dev:python3.11-v0.0.1 . | ||
| ``` | ||
|
|
||
| > **Image tag convention:** `boilerplate-dev:python<python-ver>-v<testing-ver>` | ||
| > The testing version is independent of any library release. Start at `v0.0.1` and | ||
| > increment: patch for dependency bumps/minor tweaks, minor for new tools or a Python | ||
| > version bump, major for breaking changes to the dev workflow. | ||
|
|
||
| ## Run checks | ||
|
|
||
| All commands below mount the repository into the container so changes are picked up | ||
| without a rebuild. Run them from the repository root. Substitute the tag for whichever | ||
| Python version you built. | ||
|
|
||
| **Integrity checks** (trailing whitespace, DOS line-endings, CHANGELOG entry, git tag): | ||
|
|
||
| ```bash | ||
| docker run --rm -v "$(pwd)":/app boilerplate-dev:python3.13-v0.0.1 make check | ||
| ``` | ||
|
|
||
| **Shell script linting:** | ||
|
|
||
| ```bash | ||
| docker run --rm -v "$(pwd)":/app boilerplate-dev:python3.13-v0.0.1 make shellcheck | ||
| ``` | ||
|
|
||
| **QA** (ruff, isort, codespell, check-manifest, build, twine check): | ||
|
|
||
| ```bash | ||
| docker run --rm -v "$(pwd)":/app boilerplate-dev:python3.13-v0.0.1 make qa | ||
| ``` | ||
|
|
||
| **Tests:** | ||
|
|
||
| ```bash | ||
| docker run --rm -v "$(pwd)":/app boilerplate-dev:python3.13-v0.0.1 make pytest | ||
| ``` | ||
|
|
||
| ## Dependency lock file | ||
|
|
||
| The `testing-3.10`, `testing-3.11`, and `testing-3.13` targets install from | ||
| `requirements-dev.lock`. Regenerate it when `requirements-dev.txt` changes, using the | ||
| same uv version as the Dockerfile pin: | ||
|
|
||
| ```bash | ||
| uv self update 0.11.17 # align host uv with Dockerfile pin | ||
| uv pip compile requirements-dev.txt --output-file requirements-dev.lock --python-version 3.11 | ||
| ``` | ||
|
|
||
| Then rebuild the affected images. | ||
|
|
||
| > **Note on Python 3.9:** the `testing-3.9` target uses plain `pip` directly from | ||
| > `requirements-dev.txt` (no lockfile) because the shared lockfile was compiled for | ||
| > Python 3.11 and several transitive dependencies require Python ≥ 3.10. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.