Files
stack/.woodpecker/ci.yml
kert e801b987b6 P18: config consolidation — fix #132 #133 #134 #137 #138 #139 #141
- stack.toml: add [platform] (domain, registry, repo, ci_email,
  host_ip, image_prefix) and [services] (gitea, woodpecker,
  rustfs, nessie, polaris, trino, grafana) sections
- Python clients: default URLs from cfg.services.* instead of
  hardcoded strings (gitea, woodpecker, rustfs, admin clients)
- diag reporter: resolve labels by name via Gitea API instead
  of hardcoded IDs; repo owner/name from cfg.platform.repo
- CI pipelines: YAML anchors &registry/&org for single source
  of truth; $REGISTRY/$ORG env vars in scan commands
- ci.yml: use $CI_REPO for git push URL and S3 badge target
- rebuild-all.yml: $IMAGE_PREFIX, $STACK_ROOT env vars
- deploy.yml: $CI_WORKSPACE for host volume mounts
2026-03-23 19:49:47 -04:00

123 lines
3.6 KiB
YAML

# ── Quality gate ─────────────────────────────────────────────────
# Runs on every push and PR. Must pass before merge to main.
# Gitea branch protection requires this pipeline's status checks.
when:
- event: [push, pull_request, manual]
steps:
- name: lint
image: ghcr.io/astral-sh/uv:python3.13-bookworm-slim
environment:
UV_PYTHON_PREFERENCE: only-system
UV_LINK_MODE: copy
UV_PROJECT_ENVIRONMENT: .venv
commands:
- uv sync --dev
- uv run ruff check src/ tests/ --output-format=concise
- uv run ruff format --check src/ tests/
- name: test
image: ghcr.io/astral-sh/uv:python3.13-bookworm-slim
environment:
UV_PYTHON_PREFERENCE: only-system
UV_LINK_MODE: copy
UV_PROJECT_ENVIRONMENT: .venv
commands:
- uv run pytest tests/ --cov=src --cov-report=term-missing --cov-fail-under=99 -q 2>&1 | tee pytest.out
- uv run python dev/scripts/coverage_badge.py < pytest.out > coverage.svg
depends_on:
- lint
- name: coverage-badge
image: ghcr.io/astral-sh/uv:python3.13-bookworm-slim
failure: ignore
environment:
UV_PYTHON_PREFERENCE: only-system
UV_LINK_MODE: copy
UV_PROJECT_ENVIRONMENT: .venv
GITEA_TOKEN:
from_secret: gitea_token
GITEA_URL:
from_secret: gitea_url
commands:
- uv run python dev/scripts/coverage_badge.py --post pytest.out
depends_on:
- test
- name: commit-badge
image: alpine/git
failure: ignore
environment:
REGISTRY_USER:
from_secret: registry_user
REGISTRY_PASS:
from_secret: registry_pass
commands:
- git config user.name woodpecker-ci
- git config user.email ci@${CI_REPO_OWNER}.io
- git add coverage.svg
- git diff --cached --quiet && echo "no change" && exit 0
- git commit -m "update coverage badge [skip ci]"
- git push http://$REGISTRY_USER:$REGISTRY_PASS@gitea:3000/${CI_REPO}.git HEAD:main
when:
- branch: main
event: push
depends_on:
- test
- name: upload-coverage-badge
image: woodpeckerci/plugin-s3
failure: ignore
settings:
endpoint: http://rustfs:9000
bucket: gitea
access_key:
from_secret: s3_access_key
secret_key:
from_secret: s3_secret_key
source: "coverage.svg"
target: /badges/${CI_REPO}/
path_style: true
overwrite: true
depends_on:
- test
- name: pr-comment
image: woodpeckerci/plugin-gitea-comment
settings:
gitea_url:
from_secret: gitea_url
api_key:
from_secret: gitea_token
message: >
**CI** for `${CI_COMMIT_SHA:0:8}` —
[pipeline #${CI_PIPELINE_NUMBER}](${CI_PIPELINE_URL})
when:
- event: pull_request
depends_on:
- test
- coverage-badge
- name: validate-compose
image: docker:cli
volumes:
- /run/user/1000/docker.sock:/var/run/docker.sock
commands:
- docker compose config --quiet
# ── Failure reporter ─────────────────────────────────────────
- name: report-failure
image: ghcr.io/astral-sh/uv:python3.13-bookworm-slim
environment:
UV_PYTHON_PREFERENCE: only-system
UV_LINK_MODE: copy
UV_PROJECT_ENVIRONMENT: .venv
GITEA_TOKEN:
from_secret: gitea_token
commands:
- uv sync --no-dev
- uv run python -m api.diag
when:
- status: [failure]