dc03d71898
- infra/Dockerfile.runner-base: new Ubuntu 24.04 image with Python 3.12 and Node 22 LTS pre-installed, tagged py3.12-node22. Eliminates the ~3-4 min deadsnakes PPA install that ran on every test job. - infra/runner-compose.yml: update ubuntu-latest label to use runner-base:py3.12-node22 instead of node:20-bullseye. - .forgejo/workflows/ci.yml: remove Python 3.12 install steps (now in base image), add actions/cache for pip keyed on pyproject.toml hash, bump node-version 20 → 22. - Dockerfile: bump frontend build stage node:20-alpine → node:22-alpine. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
138 lines
3.8 KiB
YAML
138 lines
3.8 KiB
YAML
# CI runs first; build only proceeds if all checks pass.
|
|
#
|
|
# Push to dev: typecheck + lint + test → build :dev + :<sha>
|
|
# Push to main: typecheck + lint + test → build :latest + :<sha>
|
|
# Tag v*: typecheck + lint + test → build :latest + :<sha> + :<version>
|
|
# Pull request: typecheck + lint + test only (no build)
|
|
#
|
|
# Required secrets (repo → Settings → Secrets → Actions):
|
|
# REGISTRY_USER — your Forgejo username
|
|
# REGISTRY_TOKEN — Forgejo PAT with write:packages scope
|
|
name: CI & Build
|
|
|
|
on:
|
|
push:
|
|
branches: [main, dev]
|
|
tags: ["v*"]
|
|
paths:
|
|
- "src/**"
|
|
- "frontend/**"
|
|
- "tests/**"
|
|
- "pyproject.toml"
|
|
- "alembic/**"
|
|
- "alembic.ini"
|
|
- "Dockerfile"
|
|
- "assets/**"
|
|
- ".forgejo/workflows/ci.yml"
|
|
pull_request:
|
|
paths:
|
|
- "src/**"
|
|
- "frontend/**"
|
|
- "tests/**"
|
|
- "pyproject.toml"
|
|
- ".forgejo/workflows/ci.yml"
|
|
|
|
env:
|
|
REGISTRY: git.fabledsword.com
|
|
IMAGE: git.fabledsword.com/bvandeusen/fabledassistant
|
|
|
|
jobs:
|
|
typecheck:
|
|
name: TypeScript typecheck
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "22"
|
|
cache: "npm"
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
working-directory: frontend
|
|
|
|
- name: Type check
|
|
run: npx vue-tsc --noEmit
|
|
working-directory: frontend
|
|
|
|
lint:
|
|
name: Python lint
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Install ruff
|
|
run: pip install ruff
|
|
|
|
- name: Lint
|
|
run: ruff check src/
|
|
|
|
test:
|
|
name: Python tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
# Python 3.12 is pre-installed in the runner-base image (py3.12-node22).
|
|
- name: Cache pip wheels
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: pip-${{ hashFiles('pyproject.toml') }}
|
|
restore-keys: pip-
|
|
|
|
- name: Create virtual environment
|
|
run: python3.12 -m venv /opt/venv
|
|
|
|
- name: Install package with dev deps
|
|
run: |
|
|
/opt/venv/bin/pip install --upgrade pip setuptools wheel
|
|
/opt/venv/bin/pip install --no-build-isolation http-ece
|
|
/opt/venv/bin/pip install -e ".[dev]"
|
|
|
|
- name: Run tests
|
|
run: /opt/venv/bin/python -m pytest tests/ -v
|
|
|
|
build:
|
|
name: Build & push image
|
|
needs: [typecheck, lint, test]
|
|
# Only build on branch/tag pushes — not on pull requests
|
|
if: github.event_name == 'push'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Generate image tags
|
|
id: tags
|
|
run: |
|
|
TAGS="${{ env.IMAGE }}:${{ github.sha }}"
|
|
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
|
|
TAGS="$TAGS,${{ env.IMAGE }}:latest"
|
|
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
|
|
TAGS="$TAGS,${{ env.IMAGE }}:dev"
|
|
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
|
TAGS="$TAGS,${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ github.ref_name }}"
|
|
fi
|
|
echo "value=$TAGS" >> $GITHUB_OUTPUT
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4
|
|
|
|
- name: Log in to Forgejo registry
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ secrets.REGISTRY_USER }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v7
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.tags.outputs.value }}
|
|
cache-from: type=registry,ref=${{ env.IMAGE }}:cache
|
|
cache-to: type=registry,ref=${{ env.IMAGE }}:cache,mode=max
|