All 6 Woodpecker pipelines + 2 CoreDNS files are now generated by gen_config.py from stack.toml. Templates directory removed. [images] schema in stack.toml defines every container image: - dockerfile, context, path_filter, scan, hadolint - trivy_severity, trivy_exit_code (per-image override) - prep_commands (pre-build steps like docs bib.sqlite copy) gen_config.py generates: - ci.yml: lint, test, coverage, validate-gen-config (drift check) - deploy.yml: build/scan/upload per image from [images] - harden.yml: no-cache rebuild + scan + vuln close per image - rebuild-all.yml: full rebuild + deploy per image - infra-ci.yml: hadolint + dry-run build per image with path_filter - release.yml: tag-triggered package release To add a new image: add [images.foo] to stack.toml, commit. Pre-commit hook auto-regenerates and stages all 8 derived files. CI validates with gen_config.py --check.
52 lines
1.8 KiB
Bash
Executable File
52 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
# Auto-recover broken venv before running any checks
|
|
if ! uv run python -c 'import sys' 2>/dev/null; then
|
|
echo "==> pre-commit: venv broken, running uv sync --dev"
|
|
uv sync --dev
|
|
fi
|
|
|
|
# Auto-regenerate derived config if stack.toml or templates changed
|
|
CONF_CHANGED=$(git diff --cached --name-only -- stack.toml dev/scripts/gen_config.py)
|
|
if [ -n "$CONF_CHANGED" ]; then
|
|
echo "==> pre-commit: regenerating config from stack.toml"
|
|
uv run python dev/scripts/gen_config.py
|
|
git add .woodpecker/ci.yml .woodpecker/deploy.yml .woodpecker/harden.yml .woodpecker/infra-ci.yml .woodpecker/rebuild-all.yml .woodpecker/release.yml coredns/hosts coredns/Corefile
|
|
fi
|
|
|
|
echo "==> pre-commit: ruff check (staged)"
|
|
# Only lint files that are staged for commit (avoid dirty-tree noise).
|
|
STAGED=$(git diff --cached --name-only --diff-filter=d -- 'src/*.py' 'tests/*.py')
|
|
if [ -n "$STAGED" ]; then
|
|
echo "$STAGED" | xargs uv run ruff check --quiet
|
|
fi
|
|
|
|
echo "==> pre-commit: ruff format --check (staged)"
|
|
if [ -n "$STAGED" ]; then
|
|
echo "$STAGED" | xargs uv run ruff format --check --quiet
|
|
fi
|
|
|
|
echo "==> pre-commit: pytest"
|
|
uv run python -m pytest tests/ --no-cov --tb=short -q
|
|
|
|
echo "==> pre-commit: marimo check"
|
|
uvx marimo check notebooks/*.py
|
|
|
|
echo "==> pre-commit: notebook run check"
|
|
# Only check notebooks that run standalone (no external services).
|
|
# Notebooks needing containers (api, nessie, polaris) or optional
|
|
# deps (vega_datasets, pyzotero) are excluded.
|
|
for nb in \
|
|
notebooks/acodb_explorer.py \
|
|
notebooks/bib_explorer.py \
|
|
notebooks/cms_quality_measures.py \
|
|
notebooks/pfs_calcs.py \
|
|
notebooks/sql_generator.py \
|
|
; do
|
|
echo " running $nb"
|
|
uv run python "$nb" 2>&1 || { echo "FAILED: $nb"; exit 1; }
|
|
done
|
|
|
|
echo "==> pre-commit: all checks passed"
|