Files
Rail_Enterprise/.gitea/workflows/ci.yml
T
Alby96andClaude Opus 5.5 c1a0049bcf
CI / Build e test (pull_request) Successful in 1m20s
CI / Immagine Docker (pull_request) Successful in 37s
Infrastruttura: nome «Rail Enterprise», CI e rilasci su Gitea, documentazione
Il progetto adotta il nome «Rail Enterprise» ovunque (codice RailEnterprise.*,
variabili RE_*, intestazioni RESV/RECL, immagine rail-enterprise-server) per
allinearsi al repository Gitea. Aggiunge Gitea Actions sul modello di Chronos:
CI su PR e main, rilascio da tag con gioco Windows (client Godot + server in
server/), server Windows/Linux e immagine Docker nel registro Gitea, nightly.
Aggiunge i riferimenti visivi 06–09, i modelli di PR e issue, l'ADR 0014 e
aggiorna README (comandi locali), STATE e CLAUDE.md. 120 test verdi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 11:14:54 +01:00

105 lines
4.1 KiB
YAML

name: CI
# Gitea Actions (ADR 0014). Il runner è act_runner in modalità Docker sul server Linux che ospita Gitea: ogni job
# gira in un container. I job .NET usano l'immagine dell'SDK e fanno il checkout con git, perché le azioni JavaScript
# richiedono Node.js, assente in quell'immagine. Nessuna cache e nessun artefatto: il risultato è il verde o il rosso.
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
env:
DOTNET_NOLOGO: "1"
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1"
BUILD_CPUS: "4"
jobs:
build:
name: Build e test
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:10.0
timeout-minutes: 90
defaults:
run:
shell: bash
steps:
- name: Checkout
env:
TOKEN: ${{ github.token }}
run: |
git config --global --add safe.directory "$PWD"
git init -q .
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
git -c http.extraheader="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" fetch -q --depth=1 origin "${{ github.sha }}"
git checkout -q FETCH_HEAD
git log -1 --format='%h %s'
# Core e Protocol compilano anche per net8.0 (client Godot): serve il targeting pack 8.0, che l'SDK 10 scarica
# da solo come pacchetto di riferimento. Nessun PackageReference è ammesso (check-nuget).
- name: Zero pacchetti NuGet
run: scripts/check-nuget.sh
- name: Build Release (warning come errori)
run: dotnet build RailEnterprise.sln -c Release -m:"$BUILD_CPUS" -nologo
- name: Validazione dei dati
run: dotnet run --project src/RailEnterprise.Tools -c Release --no-build -- validate-data --data data
# Sulle PR i test lunghi (accettazioni pluriennali) si saltano; su main gira la suite completa.
- name: Test
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
dotnet run --project tests/RailEnterprise.Tests -c Release --no-build -- --skip-slow
else
dotnet run --project tests/RailEnterprise.Tests -c Release --no-build
fi
# Il server per Windows (quello che il gioco desktop avvia da «server/») si compila anche qui.
- name: Server Windows x64 (compilazione incrociata)
run: dotnet publish src/RailEnterprise.Server -c Release -r win-x64 --self-contained -p:ReServerOnly=true -o out/server-win-x64 -nologo
# Il client Godot compila con il proprio SDK (Godot.NET.Sdk da NuGet, unica eccezione ammessa): basta dotnet.
- name: Client Godot (compilazione C#)
run: dotnet build client/RailEnterprise.Client/RailEnterprise.Client.csproj -c Release -nologo
docker:
name: Immagine Docker
needs: build
runs-on: ubuntu-latest
timeout-minutes: 45
env:
NAME: re-ci-${{ github.run_id }}
steps:
- name: Checkout
env:
TOKEN: ${{ github.token }}
run: |
git config --global --add safe.directory "$PWD"
git init -q .
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
git -c http.extraheader="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" fetch -q --depth=1 origin "${{ github.sha }}"
git checkout -q FETCH_HEAD
- name: Build dell'immagine
run: docker build -f docker/Dockerfile -t "$NAME:ci" .
# Il container del job e quello del server non condividono la rete: la prova usa l'healthcheck interno.
- name: Prova di avvio (/health)
run: |
docker run -d --name "$NAME" -e RE_TOKEN=ci "$NAME:ci"
for i in $(seq 1 60); do
if docker exec "$NAME" dotnet RailEnterprise.Server.dll --healthcheck; then echo "server sano"; exit 0; fi
sleep 2
done
docker logs "$NAME" | tail -50
exit 1
- name: Pulizia
if: always()
run: |
docker rm -f "$NAME" 2> /dev/null || true
docker image rm "$NAME:ci" 2> /dev/null || true