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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ RUN_ON_START=0

# First run only includes items from the last N days
LOOKBACK_DAYS=7

# latest follows published releases; set a version tag to pin/roll back.
IMAGE_TAG=latest
3 changes: 3 additions & 0 deletions .github/dependency-policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python": "3.12"
}
76 changes: 31 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,34 @@
name: CI

permissions:
contents: read

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_call:
inputs:
ref:
type: string
default: ''
permissions:
contents: read
jobs:
lint:
name: Ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v7.1.0
with:
python-version: '3.12'

- name: Install lint dependencies
run: pip install -r requirements-dev.txt

- name: Lint
run: ruff check .

- name: Format check
run: ruff format --check .

test:
name: Pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v7.1.0
with:
python-version: '3.12'

- name: Install dependencies
run: pip install -r requirements-dev.txt

- name: Run tests
run: pytest -q
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.ref || github.ref }}
- uses: actions/setup-python@v7.1.0
with:
python-version: '3.12'
- run: pip install uv==0.13.7
- run: uv pip sync --system --require-hashes --exclude-newer 3d requirements-dev.lock
- run: ruff check .
- run: ruff format --check .
- run: python -m pytest tests/


images:
uses: ./.github/workflows/images.yml
with:
ref: ${{ inputs.ref }}
110 changes: 110 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Docker release

on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
ref:
description: 'Existing stable version tag, e.g. v1.2.3'
required: true
type: string
workflow_call:
inputs:
ref:
required: true
type: string

concurrency:
group: docker-release
cancel-in-progress: false

permissions:
contents: read

jobs:
tag:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
sha: ${{ steps.tag.outputs.sha }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Require an existing stable tag on main
id: tag
env:
TAG: ${{ inputs.ref || github.ref_name }}
run: |
set -euo pipefail
[[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
sha="$(git rev-parse --verify "refs/tags/$TAG^{commit}")"
git merge-base --is-ancestor "$sha" origin/main
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "sha=$sha" >> "$GITHUB_OUTPUT"
checks:
needs: tag
uses: ./.github/workflows/ci.yml
with:
ref: ${{ needs.tag.outputs.sha }}
images:
needs: [tag, checks]
uses: ./.github/workflows/images.yml
with:
ref: ${{ needs.tag.outputs.sha }}
tag: ${{ needs.tag.outputs.tag }}
publish: true
permissions:
contents: read
packages: write
publish:
needs: [tag, images]
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v7
with:
ref: ${{ needs.tag.outputs.sha }}
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Assemble tested multi-platform version
env:
REPOSITORY: ${{ github.repository }}
TAG: ${{ needs.tag.outputs.tag }}
run: |
set -euo pipefail
image="ghcr.io/${REPOSITORY,,}"
for name in "$image"; do
docker buildx imagetools create --tag "$name:$TAG" "$name:$TAG-amd64" "$name:$TAG-arm64"
done
- name: Publish GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
TAG: ${{ needs.tag.outputs.tag }}
run: gh release view "$TAG" || gh release create "$TAG" --verify-tag --generate-notes
- name: Check published stable release order
id: latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
TAG: ${{ needs.tag.outputs.tag }}
run: python scripts/dependency_release.py latest --tag "$TAG"
- name: Advance Watchtower latest tags
if: steps.latest.outputs.advance_latest == 'true'
env:
REPOSITORY: ${{ github.repository }}
TAG: ${{ needs.tag.outputs.tag }}
run: |
set -euo pipefail
image="ghcr.io/${REPOSITORY,,}"
for name in "$image"; do
docker buildx imagetools create --tag "$name:latest" "$name:$TAG"
done
71 changes: 71 additions & 0 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Container images

on:
workflow_call:
inputs:
ref:
type: string
default: ''
tag:
type: string
default: smoke
publish:
type: boolean
default: false

jobs:
images:
name: Build and smoke (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.ref || github.ref }}
- uses: actions/setup-python@v7.1.0
with:
python-version: '3.12'
- uses: docker/setup-buildx-action@v4
- name: Configure image
env:
REPOSITORY: ${{ github.repository }}
VERSION: ${{ inputs.tag }}
ARCH: ${{ matrix.arch }}
run: |
echo "IMAGE=ghcr.io/${REPOSITORY,,}" >> "$GITHUB_ENV"
echo "TAG=${VERSION}-${ARCH}" >> "$GITHUB_ENV"
- name: Validate Compose
run: |
cp .env.example .env
docker compose config --quiet
docker compose -f docker-compose.yml -f docker-compose.build.yml config --quiet
- name: Build production image
uses: docker/build-push-action@v7
with:
context: .
load: true
tags: ${{ env.IMAGE }}:${{ env.TAG }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ inputs.ref || github.sha }}
cache-from: type=gha,scope=image-${{ matrix.arch }}
cache-to: type=gha,scope=image-${{ matrix.arch }},mode=max
- name: Smoke test without secrets or network
run: python scripts/smoke_container.py --image "$IMAGE:$TAG"
- uses: docker/login-action@v4
if: inputs.publish
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push tested architecture
if: inputs.publish
run: docker push "$IMAGE:$TAG"
95 changes: 95 additions & 0 deletions .github/workflows/nightly-minor-deps-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Nightly minor deps release

on:
schedule:
- cron: '37 14 * * *' # Brisbane time: 00:37
workflow_dispatch:

concurrency:
group: nightly-minor-deps
cancel-in-progress: false

permissions:
contents: read

jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: write
outputs:
release: ${{ steps.changes.outputs.release }}
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v7
with:
ref: main
fetch-depth: 0
- name: Remember tested main
run: echo "BASE_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
- uses: actions/setup-python@v7.1.0
with:
python-version: '3.12'
- name: Install pinned resolver
run: python -m pip install uv==0.13.7

- name: Refresh aged in-major dependencies
id: changes
run: python scripts/dependency_release.py update
- name: Install locked validation dependencies
if: steps.changes.outputs.changed == 'true'
run: |
uv venv --python 3.12 .venv
uv pip sync --python .venv/bin/python --require-hashes --exclude-newer 3d requirements-dev.lock
- name: Validate changed dependencies
if: steps.changes.outputs.changed == 'true'
run: |
.venv/bin/ruff check .
.venv/bin/ruff format --check .
.venv/bin/python -m pytest tests/

- uses: docker/setup-buildx-action@v4
if: steps.changes.outputs.release == 'true'
- name: Verify updated production image before committing
if: steps.changes.outputs.release == 'true'
run: |
docker buildx build --load -t production:smoke .
python scripts/smoke_container.py --image production:smoke
- name: Bump patch only for production changes
id: version
if: steps.changes.outputs.release == 'true'
run: python scripts/dependency_release.py bump
- name: Commit and atomically push tested dependencies
if: steps.changes.outputs.changed == 'true'
env:
RELEASE: ${{ steps.changes.outputs.release }}
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
git fetch origin main
if [ "$(git rev-parse origin/main)" != "$BASE_SHA" ]; then
echo 'main changed during validation; refusing to release an untested rebase.' >&2
exit 1
fi
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add requirements.lock requirements-dev.lock
if [ "$RELEASE" = true ]; then
git add pyproject.toml
git commit -m "chore(deps): nightly in-major production update (v$VERSION)"
git tag "v$VERSION"
git push --atomic origin HEAD:main "refs/tags/v$VERSION"
else
git commit -m 'chore(deps): nightly tooling update (no release)'
git push origin HEAD:main
fi
docker:
needs: update
if: needs.update.outputs.release == 'true'
uses: ./.github/workflows/docker-release.yml
with:
ref: v${{ needs.update.outputs.version }}
permissions:
contents: write
packages: write
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ Before merging any pull request:

1. **Read all comments** on the PR — conversation comments, review comments (including those on specific lines), and bot comments. Address or acknowledge them. Do not merge while review feedback is unresolved.
2. **Wait for CI to complete successfully.** GitHub Actions (and other required checks) on the PR must finish and pass. Do not merge while checks are pending, failed, cancelled, or skipped when they are required. If CI fails, fix the cause and wait for a green run before merging.

## Dependency release policy

Images and CI install hash-pinned `requirements*.lock`; direct constraints remain in `requirements*.txt`. Regenerate with `python scripts/dependency_release.py update` using pinned uv. Preserve the three-day release age, bounded upgrades, production-graph release decision, and exact-commit validation in the nightly workflows. Developer-only updates must not publish a release. Container checks use native ARM64 and AMD64 runners with no credentials or external-service access.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ FROM python:3.15.0-alpine3.24 AS build

WORKDIR /src

COPY --from=ghcr.io/astral-sh/uv:0.13.7@sha256:96f40d3904aad8d0bd010539001d36c8e2188b981e1334471a90c4a1d93bb490 /uv /usr/local/bin/uv

RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

RUN --mount=type=bind,source=requirements.txt,target=requirements.txt \
pip install --no-cache-dir --no-compile -r requirements.txt
RUN --mount=type=bind,source=requirements.lock,target=requirements.lock \
uv pip install --python /opt/venv/bin/python --require-hashes --exclude-newer 3d -r requirements.lock

FROM python:3.15.0-alpine3.24 AS runtime

Expand Down
Loading
Loading