Le Gitea Actions: test unitari a ogni push su main e sui tag, e sul tag vX.Y.Z la release con i commit dal tag prima (.gitea/workflows/test.yml); il runner sul PC si crea o riavvia con make runner (tools/gitea-runner, scripts/runner.sh, token di registrazione chiesto a Gitea con le credenziali di git); hook pre-push con check-public (make hooks) (Andrea)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GiECd9RWGMKV7n3K1mdy8T
This commit is contained in:
2026-11-01 10:58:38 +01:00
co-authored by Claude Opus 5.5
parent 3a9db6d109
commit 9499c7792b
7 changed files with 121 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
#!/bin/bash
# Prima di ogni push: il repo su git.manzolo.it è pubblico, quindi niente che check-public bocci deve partire.
# Si attiva una volta con `make hooks` (core.hooksPath = scripts/git-hooks).
cd "$(git rev-parse --show-toplevel)" || exit 1
bash scripts/check-public.sh || { echo; echo "pre-push: push bloccato da check-public (vedi sopra)."; exit 1; }
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
# Crea (se manca) e avvia il runner delle Gitea Actions su questo PC: `make runner`.
# Rifarlo da zero: `docker compose -f tools/gitea-runner/docker-compose.yml down`, cancellare $RUNNER_DATA e il runner
# vecchio da Gitea (repo → Impostazioni → Actions → Runner), poi di nuovo `make runner`.
# Il token di registrazione si chiede all'API di Gitea con le credenziali di git (serve lo scope write:repository).
set -euo pipefail
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
COMPOSE="$ROOT/tools/gitea-runner/docker-compose.yml"
REPO=${RUNNER_REPO:-manzolo/leggenda-del-regolo}
export RUNNER_DATA=${RUNNER_DATA:-$HOME/.local/share/gitea-runner}
export GITEA_RUNNER_NAME=${GITEA_RUNNER_NAME:-pc-$(hostname | tr '[:upper:]' '[:lower:]')}
mkdir -p "$RUNNER_DATA"
if [[ ! -s $RUNNER_DATA/.runner ]]; then
pass=$(printf 'protocol=https\nhost=git.manzolo.it\n\n' | git credential fill | sed -n 's/^password=//p')
user=$(printf 'protocol=https\nhost=git.manzolo.it\n\n' | git credential fill | sed -n 's/^username=//p')
[[ -n $pass ]] || { echo "nessuna credenziale git per git.manzolo.it"; exit 1; }
tok=$(curl -sf -X POST -u "$user:$pass" "https://git.manzolo.it/api/v1/repos/$REPO/actions/runners/registration-token" |
python3 -c 'import json,sys; print(json.load(sys.stdin)["token"])') ||
{ echo "Gitea non ha dato il token di registrazione (scope write:repository?)"; exit 1; }
echo "registro il runner $GITEA_RUNNER_NAME su $REPO"
GITEA_RUNNER_REGISTRATION_TOKEN=$tok docker compose -f "$COMPOSE" up -d
for _ in $(seq 30); do [[ -s $RUNNER_DATA/.runner ]] && break; sleep 1; done
[[ -s $RUNNER_DATA/.runner ]] || { docker logs --tail 20 gitea-runner; echo "registrazione non riuscita"; exit 1; }
chmod 600 "$RUNNER_DATA/.runner" 2>/dev/null || true
fi
# Senza token nell'ambiente del container: da qui in poi si autentica con .runner.
docker compose -f "$COMPOSE" up -d
sleep 2; docker logs --tail 1 gitea-runner