Author SHA1 Message Date
Alby96andClaude Opus 5.5 8d1b344366 Revisione: il browser che non risponde nemmeno alla navigazione viene comunque in primo piano (#67)
verifica / installatore (push) Waiting for needed jobs
verifica / immagine (push) Waiting for needed jobs
verifica / controlli (push) Successful in 18s
verifica / prove (push) Waiting to run
Con la correzione #67 un browser che resta muto per tutta l'attesa conta come a riposo, e Febe prova ad aprire la
pagina iniziale. Un browser che si sta ancora riavviando dopo «Scollega» rifiuta però anche Page.navigate: l'errore
risaliva fino all'API e Alberto vedeva, dopo dieci secondi, un errore interno al posto della finestra. Ora quella
navigazione mancata si annota nel registro («non aperta (il browser non risponde)») e la finestra viene in primo
piano come prima. Nuova prova con un browser che non risponde a nulla, per «Usa il browser» e «Apri il browser».

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 12:28:37 +01:00
Alby96andClaude Opus 5.5 8edb706e06 Correzione: il browser che non risponde ancora si aspetta, poi si apre l'accesso (#67)
verifica / controlli (push) Successful in 19s
verifica / prove (push) Successful in 20m6s
verifica / installatore (push) Successful in 2m10s
verifica / immagine (push) Canceled after 0s
Subito dopo «Scollega» il browser riparte con il profilo vuoto e, sotto carico,
può non dire ancora quale pagina mostra. Febe prendeva l'indirizzo sconosciuto
per una pagina di Alberto e lasciava la finestra bianca (about:blank), contro
la #52. Decisione di Alberto del 29 novembre 2026: quando l'indirizzo è
sconosciuto si richiede al browser ogni 200 ms, al massimo per 10 secondi
(AddressWait); se resta muto la pagina conta come quella di riposo e si apre
la pagina iniziale (l'accesso, senza sessione). Una pagina nota che Alberto
usa non si tocca mai; l'attesa finisce con la richiesta.

Il finto browser delle prove può restare muto (Silent): quattro prove nuove
per la risposta tardiva, il silenzio oltre l'attesa, la pagina di Alberto
lasciata com'è e l'annullamento durante l'attesa.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 11:57:57 +01:00
24 changed files with 736 additions and 509 deletions

No files matched your search

+6 -5
View File
@@ -1,9 +1,10 @@
#!/usr/bin/env bash
# Prepares the Debian container of the «prove» job (debian:trixie, plain Debian 13: no JavaScript action, hence no
# Node) so that no test is skipped: the distribution's real Chromium (on Ubuntu it is a snap, which does not work in
# containers) with its languages, Xvfb, the it_IT.UTF-8 locale, time zones and the same fonts as the Febe image; ICU,
# OpenSSL, zlib and libstdc++ for the .NET SDK (dotnet.sh). git, curl and the certificates are installed by the step
# before the sources. setpriv, getent and the nobody user (65534) come with Debian (tests of the container start).
# Prepara il contenitore Debian del lavoro «prove» (debian:trixie, Debian 13 senza nient'altro: nessuna azione
# JavaScript, quindi niente Node) perché nessuna prova si salti: Chromium vero della distribuzione (su Ubuntu è uno
# snap, che nei contenitori non va) con le sue lingue, Xvfb, la lingua it_IT.UTF-8, fusi orari e gli stessi caratteri
# dell'immagine di Febe; ICU, OpenSSL, zlib e libstdc++ per l'SDK .NET (dotnet.sh). git, curl e i certificati li
# installa il passo prima dei sorgenti. setpriv, getent e l'utente nobody (65534) vengono con Debian (prove
# dell'avvio del contenitore).
#
# .gitea/scripts/ambiente-prove.sh
set -euo pipefail
+12 -12
View File
@@ -1,20 +1,20 @@
#!/usr/bin/env bash
# CI artifacts, instead of actions/upload-artifact (a JavaScript action, which needs Node): the files go to the Gitea
# package registry, generic package febe-ci, one version per run:
# Artefatti della CI, al posto di actions/upload-artifact (un'azione JavaScript, che vuole Node): i file vanno nel
# registro dei pacchetti di Gitea, pacchetto generico febe-ci, una versione per esecuzione:
#
# <versione>-ci.<numero> from the verifica workflow (like Febe-Setup-<versione>-ci.<numero>.exe)
# <versione>-rilascio.<numero> from the rilascio workflow
# <versione>-ci.<numero> dal flusso verifica (come Febe-Setup-<versione>-ci.<numero>.exe)
# <versione>-rilascio.<numero> dal flusso rilascio
#
# with <versione> from Directory.Build.props and <numero> the run number (NUMERO). They are downloaded from the package
# page on Gitea (owner ▸ Packages ▸ febe-ci). The Monday cleanup (full pulizia-docker.sh) removes the versions created
# more than 14 days earlier, as the artifact expiry used to do.
# con <versione> da Directory.Build.props e <numero> il numero dell'esecuzione (NUMERO). Si scaricano dalla pagina del
# pacchetto su Gitea (proprietario ▸ Pacchetti ▸ febe-ci). La pulizia del lunedì (pulizia-docker.sh completa) toglie le
# versioni create più di 14 giorni prima, come faceva la scadenza degli artefatti.
#
# .gitea/scripts/artefatti.sh verifica|rilascio <file>...
#
# Variables: REGISTRY_TOKEN (token with «package: read and write», only in the curl header, never printed), GITEA_URL
# (the server address, gitea.server_url), PROPRIETARIO, NUMERO. Without REGISTRY_TOKEN a warning and no file uploaded:
# the job stays green, as for the image. A missing file or a refusal by the registry fails the step. A file with the
# same name already uploaded (a new attempt of the same run) is replaced.
# Variabili: REGISTRY_TOKEN (token con «package: read and write», solo nell'intestazione di curl, mai stampato), GITEA_URL
# (l'indirizzo del server, gitea.server_url), PROPRIETARIO, NUMERO. Senza REGISTRY_TOKEN un avviso e nessun file
# caricato: il lavoro resta verde, come per l'immagine. Un file che manca o un rifiuto del registro fanno fallire il
# passo. Un file con lo stesso nome già caricato (un nuovo tentativo della stessa esecuzione) si sostituisce.
set -euo pipefail
flusso="${1:-}"
@@ -46,7 +46,7 @@ proprietario="${PROPRIETARIO:?Manca PROPRIETARIO.}"
base="${GITEA_URL:?Manca GITEA_URL.}"
base="${base%/}/api/packages/$proprietario/generic/febe-ci/$versione"
# One call to the registry: the HTTP code, 000 if Gitea does not answer. The token is only in the curl header.
# Una chiamata al registro: il codice HTTP, 000 se Gitea non risponde. Il token sta solo nell'intestazione di curl.
chiedi() {
local codice
codice=$(curl -sS --max-time 900 -H "Authorization: token $REGISTRY_TOKEN" -o /dev/null -w '%{http_code}' "$@") || true
+14 -14
View File
@@ -1,18 +1,18 @@
#!/usr/bin/env bash
# Quick checks before building (the «controlli» job of the CI): a few seconds, and they stop at once the errors that
# would otherwise be found after half an hour of tests. They can also be run by hand, from the repository root:
# Controlli veloci prima di compilare (lavoro «controlli» della CI): pochi secondi, e fermano subito gli errori che
# altrimenti si scoprirebbero dopo mezz'ora di prove. Si lanciano anche a mano, dalla radice del repository:
#
# bash .gitea/scripts/controlli.sh
#
# 1. every shell script of the repository is valid syntax (bash -n; sh -n for the sh ones) and has Unix line
# endings, like the awk programs of the CI;
# 2. the CI workflows read as block YAML: no tabs nor Windows line endings, two-space indentation outside text
# blocks, «on:» and «jobs:» present; and they are made of commands only: no «uses:», that is no action
# (JavaScript actions need Node, and the Febe CI is written in house: decision of 18 November 2026);
# 3. no file contains conflict markers left over from a merge;
# 4. the version in Directory.Build.props has the form x.y.z[-something], the one installer/costruisci.sh accepts;
# 5. every project listed in Febe.slnx exists;
# 6. every JSON file of the repository parses (configurations, cleaned samples, Chromium policies), with json.awk.
# 1. ogni script di shell del repository è sintassi valida (bash -n; sh -n per quelli in sh) e ha le righe Unix, come
# i programmi awk della CI;
# 2. i flussi della CI si leggono come YAML a blocchi: niente tabulazioni né righe Windows, rientri di due spazi fuori
# dai blocchi di testo, «on:» e «jobs:» presenti; e sono fatti solo di comandi: nessun «uses:», cioè nessuna
# azione (le azioni JavaScript vogliono Node, e la CI di Febe è scritta in casa: decisione del 18 novembre 2026);
# 3. nessun file contiene segni di conflitto rimasti da un'unione;
# 4. la versione di Directory.Build.props è nella forma x.y.z[-qualcosa], quella che installer/costruisci.sh accetta;
# 5. ogni progetto elencato in Febe.slnx esiste;
# 6. ogni file JSON del repository si legge (configurazioni, campioni ripuliti, criteri di Chromium), con json.awk.
set -uo pipefail
radice="$(git rev-parse --show-toplevel)" || exit 2
@@ -51,8 +51,8 @@ while IFS= read -r -d '' flusso; do
if grep -n $'\t' "$flusso" > /dev/null; then
errore "$flusso contiene tabulazioni: in YAML il rientro si fa con gli spazi."
fi
# A text block («run: |», «>-») holds all the lines indented more than its key; outside, indentation goes two
# spaces at a time and no line calls an action.
# Un blocco di testo («run: |», «>-») tiene tutte le righe più rientrate della sua chiave; fuori, i rientri sono di
# due spazi in due e nessuna riga chiama un'azione.
if rilievi=$(awk '
FNR == 1 { blocco = -1; on = 0; jobs = 0 }
{
@@ -104,7 +104,7 @@ done < <(sed -n 's:.*<Project Path="\([^"]*\)".*:\1:p' Febe.slnx)
echo " $(grep -c '<Project Path=' Febe.slnx) progetti"
echo "== File JSON"
# A single process for all files; prints the files that do not parse, one per line, with the reason and the line.
# Un solo processo per tutti i file; stampa i file che non si leggono, uno per riga, con il motivo e la riga.
mapfile -d '' json < <(git ls-files -z -- '*.json')
if ((${#json[@]} > 0)); then
if ! guasti=$(awk -f .gitea/scripts/json.awk -f .gitea/scripts/json-valido.awk "${json[@]}"); then
+30 -30
View File
@@ -1,29 +1,29 @@
#!/usr/bin/env bash
# Builds the Febe Docker image with the buildx builder of the run (docker-container), always with the same arguments
# and the same labels: the build that is published comes entirely from the cache of the one that was tested and
# scanned, so the layers are the same.
# Costruzione dell'immagine Docker di Febe con il builder buildx dell'esecuzione (docker-container), sempre con gli
# stessi argomenti e le stesse etichette: la costruzione che si pubblica esce intera dalla cache di quella che si è
# provata e scansionata, quindi gli strati sono gli stessi.
#
# costruisci-immagine.sh builder <registro> the buildx builder of the run (BUILDER), with the
# docker-container driver and the buildkit configuration
# that says the home registry answers in HTTP (instead
# of docker/setup-buildx-action, a JavaScript action);
# pulizia-docker.sh esecuzione removes it
# costruisci-immagine.sh archivio <file.tar> <nome locale> archive of the image, for docker load and for Trivy
# costruisci-immagine.sh pubblica <nome:etichetta>... push to the REGISTRY registry by buildx, with
# REGISTRO_UTENTE and REGISTRO_TOKEN in a client
# configuration of its own, removed at the end; the
# daemon never talks to the registry (it would try HTTPS)
# costruisci-immagine.sh builder <registro> il builder buildx dell'esecuzione (BUILDER), con il
# driver docker-container e la configurazione di
# buildkit che dice che il registro di casa risponde in
# HTTP (al posto di docker/setup-buildx-action, un'azione
# JavaScript); lo toglie pulizia-docker.sh esecuzione
# costruisci-immagine.sh archivio <file.tar> <nome locale> archivio dell'immagine, per docker load e per Trivy
# costruisci-immagine.sh pubblica <nome:etichetta>... spinta sul registro REGISTRY da buildx, con
# REGISTRO_UTENTE e REGISTRO_TOKEN in una configurazione
# del client solo sua, tolta alla fine; il demone non
# parla mai con il registro (proverebbe HTTPS)
#
# The image is a plain manifest, without attestations (--provenance=false --sbom=false). With the attestations, which
# buildx adds by itself, it would be an index: Gitea keeps every child manifest as a version of its own, sha256:…
# without a tag, with the configuration and the layers, and removing a :sha- tag from the registry would remove only
# the index. With a plain manifest the layers belong to the tag's version, and the registry cleanup really frees them.
# L'immagine è un manifest semplice, senza attestazioni (--provenance=false --sbom=false). Con le attestazioni, che
# buildx aggiunge da sé, sarebbe un indice: Gitea tiene ogni manifest figlio come una versione a sé, sha256:… senza
# etichetta, con la configurazione e gli strati, e togliere dal registro un'etichetta :sha- toglierebbe solo l'indice.
# Con un manifest semplice gli strati stanno nella versione dell'etichetta, e la pulizia del registro li libera davvero.
#
# Required variables: BUILDER, VERSIONE, GIT_COMMIT, FLUSSO (verifica or rilascio), ESECUZIONE (gitea.run_id).
# The febe.ci.* labels say which workflow, run, branch and commit built the image. They are not used by the cleanup:
# they are also in the published images and Docker copies them into every container created from those, even in a
# real Febe. That is why febe.ci.prova, the mark of test containers only (prova-immagine.sh), is never set here:
# PipelineTests checks it.
# Variabili richieste: BUILDER, VERSIONE, GIT_COMMIT, FLUSSO (verifica o rilascio), ESECUZIONE (gitea.run_id).
# Le etichette febe.ci.* dicono quale flusso, esecuzione, ramo e commit hanno costruito l'immagine. Non servono alla
# pulizia: stanno anche nelle immagini pubblicate e Docker le copia in ogni contenitore creato da quelle, anche in un
# Febe vero. Per questo qui non si mette mai febe.ci.prova, il segno dei soli contenitori di prova (prova-immagine.sh):
# lo controlla PipelineTests.
set -euo pipefail
modo="${1:?Indica il modo: builder, archivio o pubblica.}"
@@ -32,11 +32,11 @@ cd "$(git rev-parse --show-toplevel)"
if [[ "$modo" == builder ]]; then
registro="${1:?Indica il registro, per esempio 192.168.30.23:3000.}"
# Only a host name (or an address) with the port: the value ends up in a TOML file.
# Solo un nome di host (o un indirizzo) con la porta: il valore finisce in un file TOML.
[[ "$registro" =~ ^[A-Za-z0-9.-]+(:[0-9]+)?$ ]] || { echo "Registro non valido: «$registro»." >&2; exit 2; }
configurazione="${RUNNER_TEMP:-/tmp}/buildkitd-${BUILDER:?}.toml"
printf '[registry."%s"]\n http = true\n insecure = true\n' "$registro" > "$configurazione"
# --buildkitd-config since buildx 0.13; before, it was called --config.
# --buildkitd-config da buildx 0.13; prima si chiamava --config.
opzione=--buildkitd-config
aiuto=$(docker buildx create --help 2> /dev/null) || true
[[ "$aiuto" == *--buildkitd-config* ]] || opzione=--config
@@ -69,11 +69,11 @@ case "$modo" in
etichette+=(-t "$nome")
done
# The credentials in a client configuration entirely our own, only for this push and then removed: the runner's
# one is never touched (no jq to modify it, no credential left in its folder). buildx passes them to the builder;
# the daemon is not involved (it would try HTTPS). From the original client we keep the plugins, the contexts and
# the current context; the buildx builders are found through BUILDX_CONFIG. The name is fixed for the run, so the
# «Pulizia (sempre)» step removes it even after an interruption that skips the trap.
# Le credenziali in una configurazione del client tutta nostra, solo per questa spinta e poi tolta: quella del
# runner non si tocca mai (niente jq per modificarla, nessuna credenziale che resti nella sua cartella). buildx le
# passa al builder; il demone non c'entra (proverebbe HTTPS). Del client originale restano i plugin, i contesti e
# il contesto corrente; i builder buildx li trova con BUILDX_CONFIG. Il nome è fisso per l'esecuzione, così il passo
# «Pulizia (sempre)» la toglie anche dopo un'interruzione che salta la trap.
originale="${DOCKER_CONFIG:-$HOME/.docker}"
configurazione="${RUNNER_TEMP:-/tmp}/febe-docker-${ESECUZIONE}"
rm -rf "$configurazione"
@@ -88,7 +88,7 @@ case "$modo" in
[[ "$contesto" =~ ^[A-Za-z0-9][A-Za-z0-9_.+-]*$ ]] || contesto=""
fi
credenziali=$(printf '%s:%s' "$REGISTRO_UTENTE" "$REGISTRO_TOKEN" | base64 -w0)
# Only base64 characters, and the registry checked above: the JSON is written without any need for escapes.
# Solo caratteri di base64, e il registro controllato sopra: il JSON si scrive senza bisogno di escape.
[[ "$credenziali" =~ ^[A-Za-z0-9+/]+=*$ ]] || { echo "Credenziali del registro non codificabili." >&2; exit 2; }
(
umask 077
+13 -13
View File
@@ -1,19 +1,19 @@
#!/usr/bin/env bash
# Installs the .NET SDK for a CI job, instead of actions/setup-dotnet (a JavaScript action, which needs Node). Like
# that action it takes the newest SDK of the channel (default 10.0, like «10.0.x»), but it verifies it: the version
# and the SHA-512 hash of the archive come from Microsoft's release metadata (read with json.awk and dotnet-sdk.awk,
# POSIX awk), the archive from builds.dotnet.microsoft.com, and it is installed only if the hash matches. Never an
# install script downloaded on the fly.
# Installa l'SDK .NET per un lavoro della CI, al posto di actions/setup-dotnet (un'azione JavaScript, che vuole Node).
# Come quella prende l'ultimo SDK del canale (predefinito 10.0, come «10.0.x»), ma lo verifica: la versione e
# l'impronta SHA-512 dell'archivio vengono dai metadati dei rilasci di Microsoft (letti con json.awk e dotnet-sdk.awk,
# awk POSIX), l'archivio da builds.dotnet.microsoft.com, e si installa solo se l'impronta coincide. Mai uno script di
# installazione scaricato al volo.
#
# .gitea/scripts/dotnet.sh [canale]
#
# Where: in the runner's tool cache (RUNNER_TOOL_CACHE, the act-toolcache volume that act_runner mounts in every job,
# containers included), in febe-dotnet/<versione>; without it, in the job's temporary folder. A version already
# installed and verified is not downloaded again; older versions in febe-dotnet are removed. Adds dotnet to the PATH
# of the following steps (GITHUB_PATH) and writes DOTNET_ROOT (GITHUB_ENV); outside the CI it only prints the folder.
# Needs curl, tar, sha512sum and awk. In the Debian container of the tests the SDK's system libraries (ICU, OpenSSL)
# are installed by ambiente-prove.sh; on the runner image ICU is not guaranteed, and the jobs that run there
# (installatore, windows, release) use DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true.
# Dove: nella cache degli strumenti del runner (RUNNER_TOOL_CACHE, il volume act-toolcache che act_runner monta in ogni
# lavoro, anche nei contenitori), in febe-dotnet/<versione>; senza, nella cartella temporanea del lavoro. Una versione
# già installata e verificata non si riscarica; le versioni più vecchie di febe-dotnet si tolgono. Aggiunge dotnet al
# PATH dei passi seguenti (GITHUB_PATH) e scrive DOTNET_ROOT (GITHUB_ENV); fuori dalla CI stampa solo la cartella.
# Serve curl, tar, sha512sum e awk. Nel contenitore Debian delle prove le librerie di sistema dell'SDK (ICU, OpenSSL)
# le installa ambiente-prove.sh; sull'immagine del runner ICU non è garantito, e i lavori che ci girano (installatore,
# windows, release) usano DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true.
set -euo pipefail
canale="${1:-10.0}"
@@ -56,7 +56,7 @@ else
mv "$temporanea/sdk" "$cartella"
fi
# The earlier versions, which no job will use any more (the CI runs one job at a time), and interrupted downloads.
# Le versioni precedenti, che nessun lavoro userà più (la CI fa un lavoro alla volta), e gli scarichi interrotti.
for vecchia in "$radice"/* "$radice"/.scarico-*; do
[[ -d "$vecchia" && "$vecchia" != "$cartella" && "$vecchia" != "$temporanea" ]] || continue
rm -rf "$vecchia"
+8 -8
View File
@@ -1,14 +1,14 @@
#!/usr/bin/env bash
# JSON for the CI steps, without third-party programs (no jq, no Node; decision of Alberto of 18 November 2026):
# reads with json.awk and json-campi.awk, writes strings with json-stringa.awk. POSIX awk, no network.
# JSON per i passi della CI, senza programmi di terzi (niente jq, niente Node; decisione di Alberto del 18 novembre
# 2026): legge con json.awk e json-campi.awk, scrive le stringhe con json-stringa.awk. awk POSIX, niente rete.
#
# json.sh campi <percorso> <campo,campo...> <file.json>... for each object at that place, one line with the fields
# separated by a TAB (json-campi.awk): empty path for
# the root object, «*» for every element of a list,
# for example «Results/*/Vulnerabilities/*»
# json.sh stringa <testo> the text as a JSON string, quotes included
# json.sh campi <percorso> <campo,campo...> <file.json>... per ogni oggetto a quel posto, una riga con i campi
# separati da un TAB (json-campi.awk): percorso vuoto
# per l'oggetto radice, «*» per ogni elemento di un
# elenco, per esempio «Results/*/Vulnerabilities/*»
# json.sh stringa <testo> il testo come stringa JSON, virgolette comprese
#
# A file that is not valid JSON: no output, the reason on stderr, exit status 2. PipelineTests tests it.
# Un file che non è JSON valido: niente in uscita, il motivo su stderr, uscita 2. Lo provano le PipelineTests.
set -euo pipefail
qui="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+21 -21
View File
@@ -1,21 +1,21 @@
#!/usr/bin/env bash
# Test of the image just built, on the runner's Docker daemon. Every container runs WITHOUT NETWORK (--network none):
# Febe cannot reach any site, let alone Instagram (rule 1), and the health check goes through the container's
# internal network.
# Every container carries the label febe.ci.prova=<esecuzione>, set here with «docker run --label» and never in an
# image: it is the mark by which pulizia-docker.sh recognises a test container, together with the name
# febe-prova-<esecuzione>. The febe.ci.* labels of the image are not enough: Docker copies them into every container,
# even into a real Febe started from a published image.
# Prova dell'immagine appena costruita, sul demone Docker del runner. Ogni contenitore gira SENZA RETE
# (--network none): Febe non può raggiungere alcun sito, tanto meno Instagram (regola 1), e il controllo di salute
# passa dalla rete interna del contenitore.
# Ogni contenitore porta l'etichetta febe.ci.prova=<esecuzione>, messa qui con «docker run --label» e mai in
# un'immagine: è il segno con cui pulizia-docker.sh riconosce un contenitore di prova, insieme al nome
# febe-prova-<esecuzione>. Le etichette febe.ci.* dell'immagine non bastano: Docker le copia in ogni contenitore, anche
# in un Febe vero avviato da un'immagine pubblicata.
#
# .gitea/scripts/prova-immagine.sh <immagine> [esecuzione]
#
# 1. the distribution's Chromium answers and the Febe policies (no saved passwords) are in place;
# 2. the it_IT.UTF-8 locale is generated;
# 3. the container starts as the guide says (Febe's seccomp profile, interface password, default PUID/PGID), the
# image's health check becomes «healthy» and «febe --controllo-salute» answers;
# 4. process 1 is Febe (no tini) and no orphan processes are left in the container to be reaped;
# 5. on stop it stops by itself, within the 30 seconds the guide allows.
# The password is random, lives only in the Docker client's environment and is never printed.
# 1. Chromium della distribuzione risponde e i criteri di Febe (niente password salvate) sono al loro posto;
# 2. la lingua it_IT.UTF-8 è generata;
# 3. il contenitore parte come dice la guida (profilo seccomp di Febe, password dell'interfaccia, PUID/PGID
# predefiniti), il controllo di salute dell'immagine diventa «healthy» e «febe --controllo-salute» risponde;
# 4. il processo 1 è Febe (niente tini) e nel contenitore non restano processi orfani da raccogliere;
# 5. allo stop si ferma da solo, entro i 30 secondi che la guida concede.
# La password è casuale, vive solo nell'ambiente del client Docker e non si stampa mai.
set -euo pipefail
immagine="${1:?Indica quale immagine provare.}"
@@ -24,8 +24,8 @@ radice="$(git rev-parse --show-toplevel)"
etichette=(--label "febe.ci.prova=$esecuzione")
nome="febe-prova-$esecuzione"
# Removes the test container of this run (also the one of an earlier attempt), but only if it carries the test mark:
# a container with the same name and without the mark stays, and «docker run --name» stops.
# Toglie il contenitore di prova di questa esecuzione (anche quello di un tentativo precedente), ma solo se porta il
# segno della prova: un contenitore con lo stesso nome e senza segno resta, e «docker run --name» si ferma.
togli() {
local segno
segno=$(docker container inspect -f '{{index .Config.Labels "febe.ci.prova"}}' "$nome" 2> /dev/null) || return 0
@@ -52,7 +52,7 @@ docker run -d --name "$nome" --network none "${etichette[@]}" \
--stop-timeout 30 -e FEBE_PASSWORD "$immagine" > /dev/null
unset FEBE_PASSWORD
# The image's first health check comes 30 seconds after the start (HEALTHCHECK --interval=30s): up to 3 minutes.
# Il primo controllo di salute dell'immagine arriva 30 secondi dopo l'avvio (HEALTHCHECK --interval=30s): fino a 3 minuti.
stato=""
for _ in $(seq 1 36); do
if [[ "$(docker inspect -f '{{.State.Running}}' "$nome")" != "true" ]]; then
@@ -77,16 +77,16 @@ fi
echo "salute: healthy, e febe --controllo-salute risponde"
echo "== Processo 1 e processi orfani"
# Without tini process 1 is Febe, and the .NET runtime as process 1 also reaps the orphaned children of Chromium.
# A process that has just ended may stay a «zombie» for an instant: only one that stays so for 10 seconds counts.
# Senza tini il processo 1 è Febe, e il runtime .NET da processo 1 raccoglie anche i figli di Chromium rimasti orfani.
# Un processo appena finito può restare «zombie» per un istante: conta solo uno che resta tale per 10 secondi.
primo="$(docker exec "$nome" cat /proc/1/comm)"
if [[ "$primo" != "febe" ]]; then
echo "Il processo 1 del contenitore è «$primo» invece di febe. Registro:" >&2
docker logs --tail 80 "$nome" >&2 || true
exit 1
fi
# The ids of the zombie processes that are children of process 1, sorted: the ones it has to reap (orphans end up
# there). One that vanishes while being read does not count.
# I numeri dei processi zombie figli del processo 1, ordinati: quelli che tocca a lui raccogliere (gli orfani finiscono
# lì). Uno sparito durante la lettura non conta.
orfani_zombie='for f in /proc/[0-9]*/status; do
awk '\''$1 == "State:" { z = $2 } $1 == "Pid:" { p = $2 } $1 == "PPid:" { q = $2 } END { if (z == "Z" && q == 1) print p }'\'' "$f" 2> /dev/null
done'
+159 -158
View File
@@ -1,70 +1,71 @@
#!/usr/bin/env bash
# Cleanup of the runner's Docker daemon and of the container registry. The daemon is the same one that builds
# Encelado, Mimante and Alberto's other projects (and very probably the one of the Unraid applications), and a real
# Febe may run on it too. Since 21 October 2026 (decision of Alberto) the cleanup also removes what nobody needs any
# more, of any project: the images no container uses, the build cache, the leftovers of act_runner. Never a
# container, a volume or a network that does not belong to the CI.
# Pulizia del demone Docker del runner e del registro dei container. Il demone è lo stesso che costruisce Encelado,
# Mimante e gli altri progetti di Alberto (e molto probabilmente quello delle applicazioni di Unraid), e ci può girare
# anche un Febe vero. Dal 21 ottobre 2026 (decisione di Alberto) la pulizia toglie anche ciò che non serve più a
# nessuno, di qualunque progetto: le immagini che nessun contenitore usa, la cache di costruzione, i resti di
# act_runner. Mai un contenitore, un volume o una rete che non sia della CI.
#
# Of the Febe CI, what can be proven to be its own is removed. The labels febe.ci.workflow, febe.ci.run, febe.ci.ref
# and febe.ci.commit say where an image comes from, but they do NOT choose what to remove: they are also in the
# published images (:main, :sha-, :X.Y.Z, :latest), and Docker copies them into every container created from those,
# so a real Febe carries them too. What is removed is recognised like this:
# - test containers: the label febe.ci.prova=<esecuzione>, which only prova-immagine.sh sets with
# «docker run --label» and which no image carries (PipelineTests checks it), AND the exact name
# febe-prova-<the same run> (the other test containers, without a name, run with --rm and Docker removes them by
# itself as soon as they end);
# - tested images: the local name febe-ci:<esecuzione>, removed by name, never by id and never with -f. If the same
# image also has a registry name, only febe-ci:<esecuzione> is removed; if a container uses it, it stays;
# - buildx builders: the container buildx_buildkit_febe-ci-<esecuzione>0, with the moby/buildkit image, and its
# …_state volume, which hold the build cache of that run;
# - the febe:ci image left by the old verification workflow (before 20 October 2026), if nobody uses it.
# Of act_runner, the leftovers of the jobs are removed: act_runner names everything it creates for a job
# GITEA-ACTIONS-TASK-<task number>… (the job container, its volumes <nome> and <nome>-env, its network
# <nome>-<lavoro>-network). Only stopped containers, and volumes and networks no container uses, older than 90
# minutes: a job that starts creates them and uses them at once. The act-toolcache volume (the tool cache, shared
# among the jobs) stays.
# Della CI di Febe si toglie ciò che si può provare suo. Le etichette febe.ci.workflow, febe.ci.run, febe.ci.ref e
# febe.ci.commit dicono da dove viene un'immagine, ma NON scelgono che cosa togliere: stanno anche nelle immagini
# pubblicate (:main, :sha-, :X.Y.Z, :latest), e Docker le copia in ogni contenitore creato da quelle, quindi le porta
# anche un Febe vero. Ciò che si toglie si riconosce così:
# - contenitori di prova: l'etichetta febe.ci.prova=<esecuzione>, che mette solo prova-immagine.sh con
# «docker run --label» e che nessuna immagine porta (lo controlla PipelineTests), E il nome esatto
# febe-prova-<la stessa esecuzione> (gli altri contenitori della prova, senza nome, girano con --rm e Docker li
# toglie da sé appena finiscono);
# - immagini provate: il nome locale febe-ci:<esecuzione>, tolto per nome, mai per identificativo e mai con -f. Se la
# stessa immagine ha anche un nome del registro, si toglie solo febe-ci:<esecuzione>; se un contenitore la usa, resta;
# - builder buildx: il contenitore buildx_buildkit_febe-ci-<esecuzione>0, con l'immagine moby/buildkit, e il suo
# volume …_state, che contengono la cache di costruzione di quell'esecuzione;
# - l'immagine febe:ci lasciata dal vecchio flusso di verifica (prima del 20 ottobre 2026), se nessuno la usa.
# Di act_runner si tolgono i resti dei lavori: act_runner chiama tutto ciò che crea per un lavoro
# GITEA-ACTIONS-TASK-<numero del compito>… (il contenitore del lavoro, i suoi volumi <nome> e <nome>-env, la sua rete
# <nome>-<lavoro>-network). Solo i contenitori fermi e i volumi e le reti che nessun contenitore usa, più vecchi di 90
# minuti: un lavoro che parte li crea e li usa subito. Il volume act-toolcache (la cache degli strumenti, condivisa fra
# i lavori) resta.
#
# pulizia-docker.sh esecuzione <id> everything the run <id> created (at the start and at the end of its
# «immagine» job, always)
# pulizia-docker.sh penzolanti the unnamed images no container uses and the daemon's dangling build cache
# (the part no image shares) unused for 24 hours, of all projects (at the end
# of every «immagine» job, after «esecuzione»)
# pulizia-docker.sh residui [minuti] the leftovers of interrupted runs, older than N minutes (default 90: a job
# lasts at most 60 minutes, so none of them is still alive)
# pulizia-docker.sh settimanale residui, febe:ci, unnamed images older than 72 hours: the narrow cleanup of
# before 21 October 2026, now only by hand
# pulizia-docker.sh completa residui, febe:ci, act_runner leftovers, the images no container uses
# created more than 24 hours ago, the build cache unused for 24 hours and,
# with REGISTRY_TOKEN, the registry's sha- tags beyond the 10 most recent and
# the CI artifacts (febe-ci) older than 14 days («pulizia» workflow, every
# Monday and by hand)
# pulizia-docker.sh <modo> --prova lists what it would remove and removes nothing: only commands that read
# (on the registry only GET)
# pulizia-docker.sh esecuzione <id> tutto ciò che ha creato l'esecuzione <id> (all'inizio e alla fine del suo
# lavoro «immagine», sempre)
# pulizia-docker.sh penzolanti le immagini senza nome che nessun contenitore usa e la cache di costruzione
# penzolante del demone (quella che nessuna immagine condivide) non usata da
# 24 ore, di tutti i progetti (alla fine di ogni lavoro «immagine», dopo
# «esecuzione»)
# pulizia-docker.sh residui [minuti] i resti di esecuzioni interrotte, più vecchi di N minuti (predefinito 90: un
# lavoro dura al massimo 60 minuti, quindi nessuno di essi è ancora vivo)
# pulizia-docker.sh settimanale residui, febe:ci, immagini senza nome più vecchie di 72 ore: la pulizia
# stretta di prima del 21 ottobre 2026, ora solo a mano
# pulizia-docker.sh completa residui, febe:ci, resti di act_runner, le immagini che nessun contenitore
# usa create più di 24 ore fa, la cache di costruzione non usata da 24 ore e,
# con REGISTRY_TOKEN, le etichette sha- del registro oltre le 10 più recenti e
# gli artefatti della CI (febe-ci) di più di 14 giorni (flusso «pulizia», ogni
# lunedì e a mano)
# pulizia-docker.sh <modo> --prova elenca che cosa toglierebbe e non toglie nulla: solo comandi che leggono
# (sul registro solo GET)
#
# All the arguments are checked before touching Docker: an option other than --prova (--dry-run, -n, --Prova) or an
# extra argument (prova without dashes) stops everything with code 2, instead of starting the real cleanup in place
# of the dry run.
# Gli argomenti si controllano tutti prima di toccare Docker: un'opzione diversa da --prova (--dry-run, -n, --Prova) o
# un argomento in più (prova senza trattini) fermano tutto con codice 2, invece di far partire la pulizia vera al posto
# della prova.
#
# Never docker system prune, container prune, volume prune or network prune; never image prune -a or builder prune -a
# without the 24-hour filter; never a container, a volume or a network that does not belong to the CI. The images are
# removed by Docker itself (image prune), which never removes an image used by a container, not even a stopped one;
# with -a, though, it removes their extra names, and the script writes them out (in the dry run it estimates them,
# depending on the store). On the registry never main, latest or an X.Y.Z version: only the sha-<hexadecimal> tags of
# the verification and the <x.y.z>-ci.<n> and <x.y.z>-rilascio.<n> artifacts of the generic febe-ci package.
# Mai docker system prune, container prune, volume prune o network prune; mai image prune -a o builder prune -a senza
# il filtro delle 24 ore; mai un contenitore, un volume o una rete che non sia della CI. Le immagini le toglie Docker
# stesso (image prune), che non toglie mai un'immagine usata da un contenitore, nemmeno fermo; con -a, però, le toglie i
# nomi in più, e lo script li scrive (nella prova li stima, secondo lo store). Sul registro mai main, latest o una
# versione X.Y.Z: solo le etichette sha-<esadecimale> della verifica e gli artefatti <x.y.z>-ci.<n> e
# <x.y.z>-rilascio.<n> del pacchetto generico febe-ci.
#
# In the «residui», «settimanale» and «completa» modes a test container is removed only if it is stopped. One still
# running after 90 minutes (its job was killed right during the container test) stays where it is: it is reported,
# with the command to remove it by hand. The builders are the exception: they are always running and their cache goes
# away only by removing the container; they are recognised by the exact name and the buildkit image, never by a label.
# Nei modi «residui», «settimanale» e «completa» un contenitore di prova si toglie solo se è fermo. Uno ancora acceso
# dopo 90 minuti (il suo lavoro è stato ucciso proprio durante la prova del contenitore) resta dov'è: lo si segnala, con
# il comando per toglierlo a mano. I builder sono l'eccezione: sono sempre accesi e la loro cache se ne va solo
# togliendo il contenitore; si riconoscono dal nome esatto e dall'immagine di buildkit, mai da un'etichetta.
#
# An object already gone is not an error: the cleanup can be repeated. In the «esecuzione», «penzolanti» and «residui»
# modes a problem becomes a warning (a green job does not turn red because of the cleanup, which the Monday workflow
# repeats); in the «settimanale» and «completa» modes it fails the job, so that someone looks at it. The registry is
# the exception: a refusal by its API is only a warning, and the following Monday it is tried again.
# Un oggetto già sparito non è un errore: la pulizia si può ripetere. Nei modi «esecuzione», «penzolanti» e «residui»
# un problema diventa un avviso (un lavoro verde non diventa rosso per la pulizia, che il flusso del lunedì ripete); nei
# modi «settimanale» e «completa» fa fallire il lavoro, perché qualcuno lo guardi. Il registro è l'eccezione: un
# rifiuto della sua API è solo un avviso, e il lunedì dopo si riprova.
#
# Variables for the registry («completa» mode): REGISTRY_TOKEN (token with «package: read and write», never printed),
# GITEA_API (the server's API, for example https://gitea.example/api/v1) and PROPRIETARIO (the owner of the febe
# package). The choice of the versions to remove lives in versioni-registro.sh, next to this script.
# Variabili per il registro (modo «completa»): REGISTRY_TOKEN (token con «package: read and write», mai stampato),
# GITEA_API (l'API del server, per esempio https://gitea.example/api/v1) e PROPRIETARIO (il proprietario del pacchetto
# febe). La scelta delle versioni da togliere sta in versioni-registro.sh, accanto a questo script.
set -uo pipefail
uso() {
@@ -92,21 +93,21 @@ esac
cartella_script="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
problemi=0
# In a dry run: the containers (id and name) and the image names the real cleanup would remove, so that the lists
# that follow treat them as already removed (a volume used only by a container that would go away, for example,
# would go away too).
# In prova: i contenitori (identificativo e nome) e i nomi di immagine che la pulizia vera toglierebbe, perché gli
# elenchi che seguono li trattino come già tolti (un volume usato solo da un contenitore che se ne andrebbe, per
# esempio, se ne andrebbe anche lui).
previsti=()
nomi_previsti=()
# For the summary: how many objects per kind, in the order they appear, and the space reclaimed by Docker.
# Per il riepilogo: quanti oggetti per tipo, nell'ordine in cui compaiono, e lo spazio recuperato da Docker.
declare -A conteggi=()
tipi=()
note=()
# The build cache that is pruned is the one of the daemon's builder, «default». docker builder is an alias of docker
# buildx when the plugin is there, and buildx works on the current builder: if someone had made the run's builder
# current (costruisci-immagine.sh builder does not), the «esecuzione» mode would have just removed it. The other
# buildx commands of this script name the builder explicitly.
# La cache di costruzione che si pota è quella del builder del demone, «default». docker builder è un alias di docker
# buildx quando c'è il plugin, e buildx lavora sul builder corrente: se qualcuno avesse reso corrente il builder
# dell'esecuzione (costruisci-immagine.sh builder non lo fa), il modo «esecuzione» l'avrebbe appena tolto. Gli altri
# comandi buildx di questo script indicano il builder per nome.
export BUILDX_BUILDER=default
avviso() {
@@ -114,7 +115,7 @@ avviso() {
problemi=$((problemi + 1))
}
# A warning that does not turn the job red: for the registry.
# Un avviso che non fa diventare rosso il lavoro: per il registro.
segnala() {
echo "::warning::$*"
}
@@ -124,7 +125,7 @@ conta() {
conteggi[$1]=$((${conteggi[$1]:-0} + 1))
}
# True if the first word is among the ones that follow.
# Vero se la prima parola è fra quelle che seguono.
fra() {
local cercata="$1" voce
shift
@@ -134,9 +135,9 @@ fra() {
return 1
}
# Minutes elapsed since an RFC 3339 instant as Docker writes it (Created of a container or an image, CreatedAt of a
# volume, {{json .Created}} of a network, in quotes), with or without fractions of a second, with «Z» or with the
# offset from universal time (+02:00). If it cannot be read, 0: when in doubt the object is young and stays.
# Minuti trascorsi da un istante RFC 3339 come lo scrive Docker (Created di un contenitore o di un'immagine, CreatedAt
# di un volume, {{json .Created}} di una rete, fra virgolette), con o senza frazioni di secondo, con «Z» o con lo scarto
# dall'ora universale (+02:00). Se non si legge, 0: nel dubbio l'oggetto è giovane e resta.
eta_minuti() {
local creato="${1:-}" secondi
creato="${creato//\"/}"
@@ -157,8 +158,8 @@ durata() {
fi
}
# Among the given containers (ids, one per line), those that remain after this cleanup: in a dry run without the ones
# the real cleanup would remove.
# Fra i contenitori dati (identificativi, uno per riga), quelli che restano dopo questa pulizia: in prova senza quelli
# che la pulizia vera toglierebbe.
restanti() {
local id
while read -r id; do
@@ -167,9 +168,9 @@ restanti() {
done <<< "${1:-}"
}
# The CI test containers, one per line «id name»: the label febe.ci.prova (of the given run, or of any run if the
# first argument is empty) and the exact name febe-prova-<label value>. The states that follow narrow the choice
# (Docker joins them with OR). Exits with 1 if Docker does not answer.
# I contenitori di prova della CI, uno per riga «id nome»: l'etichetta febe.ci.prova (dell'esecuzione indicata, o di
# qualunque se il primo argomento è vuoto) e il nome esatto febe-prova-<valore dell'etichetta>. Gli stati che seguono
# restringono la scelta (Docker li unisce in OR). Esce con 1 se Docker non risponde.
contenitori_di_prova() {
local run="$1"
shift
@@ -184,8 +185,8 @@ contenitori_di_prova() {
done <<< "$elenco"
}
# Removes a container with its anonymous volumes (in a dry run it only lists it). With «forza» even if it is running:
# only for those of the run itself and for the builders. Exits with 0 if the container goes away (or would).
# Toglie un contenitore con i suoi volumi anonimi (in prova lo elenca soltanto). Con «forza» anche se è acceso: solo
# per quelli dell'esecuzione stessa e per i builder. Esce con 0 se il contenitore se ne va (o se ne andrebbe).
togli_contenitore() {
local id="$1" nome="$2" opzioni=(-v)
[[ "${3:-}" == forza ]] && opzioni=(-f -v)
@@ -202,8 +203,8 @@ togli_contenitore() {
return 1
}
# Removes the local name febe-ci:<esecuzione> (or febe:ci), never the image by id and never with -f: if the image also
# has another name (a registry one, for example) that one stays; if a container uses it, everything stays.
# Toglie il nome locale febe-ci:<esecuzione> (o febe:ci), mai l'immagine per identificativo e mai con -f: se l'immagine
# ha anche un altro nome (del registro, per esempio) quello resta; se un contenitore la usa, resta tutto.
togli_immagine() {
local riferimento="$1" nomi
[[ "$riferimento" =~ ^febe-ci:[0-9]+$ ]] || [[ "$riferimento" == febe:ci ]] \
@@ -226,9 +227,9 @@ togli_immagine() {
return 1
}
# A CI buildx builder: first with buildx (if this client knows it), then container and volume by name, because a job
# other than the one that created it does not have its configuration. The container is removed only if it runs the
# buildkit image, and the volume only when the container is gone.
# Un builder buildx della CI: prima con buildx (se questo client lo conosce), poi contenitore e volume per nome, perché
# un lavoro diverso da quello che l'ha creato non ne ha la configurazione. Il contenitore si toglie solo se gira
# l'immagine di buildkit, e il volume solo quando il contenitore non c'è più.
togli_builder() {
local builder="$1"
[[ "$builder" =~ ^febe-ci-[0-9]+$ ]] || { avviso "Nome di builder inatteso: «$builder»."; return 1; }
@@ -261,8 +262,8 @@ togli_builder() {
return "$esito"
}
# A volume or a network of act_runner. Docker itself does not remove a volume a container uses, nor a network with a
# running container attached.
# Un volume o una rete di act_runner. Docker stesso non toglie un volume che un contenitore usa, né una rete con un
# contenitore acceso collegato.
togli_volume() {
local nome="$1"
if ((prova)); then
@@ -291,8 +292,8 @@ togli_rete() {
return 1
}
# True if no container, running or stopped, uses the volume or the network (in a dry run: none that the real cleanup
# would leave). When in doubt (Docker does not answer) false: it stays.
# Vero se nessun contenitore, acceso o fermo, usa il volume o la rete (in prova: nessuno che la pulizia vera
# lascerebbe). Nel dubbio (Docker non risponde) falso: resta.
nessuno_usa() {
local tipo="$1" nome="$2" utenti
if [[ "$tipo" == volume ]]; then
@@ -325,7 +326,7 @@ residui() {
echo "== Resti di esecuzioni interrotte della CI di Febe, più vecchi di $minuti minuti"
local elenco id nome eta riferimento builder
# Stopped test containers: they are removed. Without -f: if one started again in the meantime, Docker leaves it alone.
# Contenitori di prova fermi: si tolgono. Senza -f: se nel frattempo uno ripartisse, Docker lo lascia stare.
if elenco=$(contenitori_di_prova "" exited created dead); then
while read -r id nome; do
[[ -n "${id:-}" ]] || continue
@@ -336,7 +337,7 @@ residui() {
avviso "Non riesco a elencare i contenitori di prova fermi."
fi
# Test containers still running: they are not touched, they are reported.
# Contenitori di prova ancora accesi: non si toccano, si segnalano.
if elenco=$(contenitori_di_prova "" running restarting paused); then
while read -r id nome; do
[[ -n "${id:-}" ]] || continue
@@ -349,7 +350,7 @@ residui() {
avviso "Non riesco a elencare i contenitori di prova accesi."
fi
# Tested images: only the febe-ci:<esecuzione> names.
# Immagini provate: solo i nomi febe-ci:<esecuzione>.
if elenco=$(docker image ls --filter "reference=febe-ci" --format '{{.Repository}}:{{.Tag}}'); then
while read -r riferimento; do
[[ "${riferimento:-}" =~ ^febe-ci:[0-9]+$ ]] || continue
@@ -360,7 +361,7 @@ residui() {
avviso "Non riesco a elencare le immagini febe-ci."
fi
# buildx builders. Docker's name filter matches part of the name: the exact name is checked here.
# Builder buildx. Il filtro per nome di Docker cerca una parte del nome: il nome esatto si controlla qui.
if elenco=$(docker ps -a --no-trunc --filter "name=buildx_buildkit_febe-ci-" --format '{{.ID}} {{.Names}}'); then
while read -r id nome; do
[[ -n "${id:-}" ]] || continue
@@ -375,7 +376,7 @@ residui() {
fi
}
# The leftovers of the Febe CI and the febe:ci image of the old workflow («settimanale» and «completa» modes).
# I resti della CI di Febe e l'immagine febe:ci del vecchio flusso (modi «settimanale» e «completa»).
resti_della_ci() {
residui 90
echo "== Immagine febe:ci del vecchio flusso di verifica"
@@ -384,16 +385,16 @@ resti_della_ci() {
fi
}
# act_runner names its objects GITEA-ACTIONS-TASK-<task number>, followed by «_WORKFLOW-…» or, in older versions, by
# «-WORKFLOW-…» with a hash at the end.
# act_runner chiama i suoi oggetti GITEA-ACTIONS-TASK-<numero del compito>, seguito da «_WORKFLOW-…» o, nelle versioni
# più vecchie, da «-WORKFLOW-…» con un'impronta in fondo.
nome_act='^GITEA-ACTIONS-TASK-[0-9]+[-_]'
resti_di_act_runner() {
local minuti="$1" elenco id nome eta
echo "== Resti di act_runner (GITEA-ACTIONS-TASK-…) più vecchi di $minuti minuti: contenitori fermi, volumi e reti che nessun contenitore usa"
# Stopped containers. Docker's name filter matches part of the name: the exact start is checked here. Without -f:
# Docker does not remove a running container.
# Contenitori fermi. Il filtro per nome di Docker cerca una parte del nome: l'inizio esatto si controlla qui. Senza
# -f: Docker non toglie un contenitore acceso.
if elenco=$(docker ps -a --no-trunc --filter "name=GITEA-ACTIONS-TASK-" --filter "status=exited" \
--filter "status=created" --filter "status=dead" --format '{{.ID}} {{.Names}}'); then
while read -r id nome; do
@@ -407,7 +408,7 @@ resti_di_act_runner() {
avviso "Non riesco a elencare i contenitori di act_runner."
fi
# Volumes no container uses, not even a stopped one.
# Volumi che nessun contenitore usa, nemmeno fermo.
if elenco=$(docker volume ls -q --filter "name=GITEA-ACTIONS-TASK-"); then
while read -r nome; do
[[ -n "${nome:-}" && "$nome" =~ $nome_act ]] || continue
@@ -419,8 +420,8 @@ resti_di_act_runner() {
avviso "Non riesco a elencare i volumi di act_runner."
fi
# Networks no container is attached to, not even a stopped one. Created of a network is a Go time, which the template
# prints as «2026-10-21 06:17:03 +0200 CEST»: in JSON it is RFC 3339.
# Reti a cui nessun contenitore è collegato, nemmeno fermo. Created di una rete è un istante di Go, che il modello
# stampa come «2026-10-21 06:17:03 +0200 CEST»: in JSON è RFC 3339.
if elenco=$(docker network ls --no-trunc --filter "name=GITEA-ACTIONS-TASK-" --format '{{.ID}} {{.Name}}'); then
while read -r id nome; do
[[ -n "${id:-}" && "${nome:-}" =~ $nome_act ]] || continue
@@ -433,8 +434,9 @@ resti_di_act_runner() {
fi
}
# The images of the containers, running or stopped, except those the cleanup would remove: «id image» one per line,
# the image as it was given to docker run (a name or an id). Read only: it serves the dry-run listing.
# Le immagini dei contenitori, accesi o fermi, tranne quelli che la pulizia toglierebbe: «identificativo immagine» una
# per riga, l'immagine come la si è data a docker run (un nome o un identificativo). Solo lettura: serve all'elenco
# della prova.
immagini_in_uso() {
local elenco id nome
elenco=$(docker ps -a --no-trunc --format '{{.ID}} {{.Names}}') || return 1
@@ -447,8 +449,8 @@ immagini_in_uso() {
return 0
}
# The full name of an image name, as Docker sorts it: docker.io/library/ or docker.io/ in front of Docker Hub names
# written without a domain, :latest if the tag is missing.
# Il nome completo di un nome d'immagine, come lo ordina Docker: docker.io/library/ o docker.io/ davanti ai nomi di
# Docker Hub scritti senza dominio, :latest se manca l'etichetta.
nome_completo() {
local nome="$1" primo
[[ "${nome##*/}" == *:* ]] || nome="$nome:latest"
@@ -464,13 +466,13 @@ nome_completo() {
fi
}
# In a dry run: the names «image prune -a» would remove from an image a container uses (the names and the images of
# the containers, as docker image ls and docker container inspect write them), one per line. The image stays, but the
# extra names do not (moby). With the classic store Docker removes the names in alphabetical order of the full name
# and stops at the last one, the only one it refuses to remove because a container uses the image
# (daemon/images/image_prune.go and image_delete.go, isSingleReference): even the name the container was created from
# may go. With containerd the names the containers were created from stay and, if one uses it by id and no name would
# stay, the last one in alphabetical order (daemon/containerd/image_prune.go).
# In prova: i nomi che «image prune -a» toglierebbe a un'immagine che un contenitore usa (i nomi e le immagini dei
# contenitori, come li scrivono docker image ls e docker container inspect), uno per riga. L'immagine resta, ma i nomi
# in più no (moby). Con lo store classico Docker toglie i nomi in ordine alfabetico del nome completo e si ferma
# all'ultimo, l'unico che rifiuta di togliere perché un contenitore usa l'immagine (daemon/images/image_prune.go e
# image_delete.go, isSingleReference): può andarsene anche il nome da cui il contenitore è stato creato. Con containerd
# restano i nomi da cui i contenitori sono stati creati e, se uno la usa per identificativo e nessun nome resterebbe,
# l'ultimo in ordine alfabetico (daemon/containerd/image_prune.go).
nomi_che_perde() {
local id="$1" nomi="$2" configurazioni="$3" nome completo configurazione resto per_id=0 ordinati quanti
local -A protetti=()
@@ -506,10 +508,10 @@ nomi_che_perde() {
return 0
}
# In a dry run: the images the pruning would remove, with size and age. No container uses them (apart from those this
# cleanup would remove) and they were created more than N minutes ago; with «senza-nome» only the unnamed ones. With
# «tutte», for an image a container uses, the extra names Docker would remove from it. It is an estimate made here: in
# the real cleanup Docker decides (image prune).
# In prova: le immagini che la potatura toglierebbe, con dimensione ed età. Nessun contenitore le usa (a parte quelli
# che questa pulizia toglierebbe) e sono state create più di N minuti fa; con «senza-nome» solo quelle senza nome. Con
# «tutte», di un'immagine che un contenitore usa, i nomi in più che Docker le toglierebbe. È una stima fatta qui: nella
# pulizia vera decide Docker (image prune).
elenca_immagini() {
local minimo="$1" quali="$2" usate elenco id nome breve dimensione eta quante=0 configurazione
local -A nomi=() elenco_nomi=() dimensioni=() aveva_nomi=() usata_da=()
@@ -541,11 +543,11 @@ elenca_immagini() {
[[ "$nome" == *":<none>" ]] || elenco_nomi[$id]+="$nome"$'\n'
done <<< "$elenco"
for id in "${ordine[@]}"; do
# An image whose names the cleanup removes above already goes away with the last one.
# Un'immagine i cui nomi la pulizia toglie qui sopra se ne va già con l'ultimo.
[[ -n "${aveva_nomi[$id]:-}" && -z "${nomi[$id]}" ]] && continue
breve="${id#sha256:}"
if [[ -n "${usata_da[$id]+x}" ]]; then
# A container uses it: it stays. With -a, though, Docker removes its extra names.
# Un contenitore la usa: resta. Con -a, però, Docker le toglie i nomi in più.
[[ "$quali" == tutte && -n "${elenco_nomi[$id]}" ]] || continue
eta=$(eta_minuti "$(docker image inspect -f '{{.Created}}' "$id" 2> /dev/null)")
((eta >= minimo)) || continue
@@ -573,8 +575,8 @@ elenca_immagini() {
((quante > 0)) || echo " nessuna"
}
# In a dry run: how much build cache the daemon has. How much of it the pruning would remove Docker does not say
# without removing it: at most the part nobody is using («RECLAIMABLE» of docker system df).
# In prova: quanta cache di costruzione ha il demone. Quanta ne toglierebbe la potatura Docker non lo dice senza
# toglierla: al più quella che nessuno sta usando («RECLAIMABLE» di docker system df).
elenca_cache() {
local riga tipo dimensione recuperabile
riga=$(docker system df --format '{{.Type}}|{{.Size}}|{{.Reclaimable}}' 2> /dev/null | grep '^Build Cache|')
@@ -587,11 +589,11 @@ elenca_cache() {
note+=("cache di costruzione: $dimensione in tutto, al più $recuperabile da togliere")
}
# The daemon's image store: «containerd» (io.containerd.snapshotter.v1, the default in new Docker Engine installations
# since 29) or «classico» (overlay2 and the other earlier drivers). It decides from when the 24 hours of image prune
# --filter until count: with the classic store from the image build (Created of the configuration), with containerd
# from when the name arrived on the daemon (CreatedAt of its record, which a new pull of the same name does not
# change).
# Lo store delle immagini del demone: «containerd» (io.containerd.snapshotter.v1, predefinito nelle installazioni nuove
# di Docker Engine dalla 29) o «classico» (overlay2 e gli altri driver di prima). Ne dipende da quando contano le 24 ore
# di image prune --filter until: con lo store classico dalla costruzione dell'immagine (Created della configurazione),
# con containerd da quando il nome è arrivato sul demone (CreatedAt del suo record, che un nuovo pull dello stesso nome
# non cambia).
store=""
rileva_store() {
local stato
@@ -609,21 +611,21 @@ rileva_store() {
esac
}
# Every image with each of its names, «id name» one per line (<none>:<none> if it has none).
# Ogni immagine con ciascuno dei suoi nomi, «identificativo nome» una per riga (<none>:<none> se non ne ha).
immagini_e_nomi() {
docker image ls --no-trunc --format '{{.ID}} {{.Repository}}:{{.Tag}}' 2> /dev/null
}
# The space reclaimed according to Docker: «Total reclaimed space: 1.2GB» (docker) or «Total: 1.2GB» (buildx).
# Lo spazio recuperato secondo Docker: «Total reclaimed space: 1.2GB» (docker) o «Total: 1.2GB» (buildx).
spazio_recuperato() {
local riga
riga=$(grep -E '^Total' <<< "$1" | tail -n 1 | sed -E 's/^Total( reclaimed space)?:[[:space:]]*//')
echo "${riga:-0B}"
}
# A Docker image pruning: the names removed, how many images and how much space. An error is a warning. The names are
# compared before and after: with -a Docker also removes the extra names of an image a container uses and that stays,
# and the job log says so.
# Una potatura di immagini di Docker: i nomi tolti, quante immagini e quanto spazio. Un errore è un avviso. I nomi si
# confrontano prima e dopo: con -a Docker toglie anche i nomi in più di un'immagine che un contenitore usa e che resta,
# e il registro del lavoro lo dice.
pota_immagini() {
local cosa="$1" uscita prima dopo recuperato prima_nomi dopo_nomi dopo_id id nome breve
shift
@@ -657,7 +659,7 @@ pota_immagini() {
fi
}
# A build cache pruning: how much space. An error is a warning.
# Una potatura della cache di costruzione: quanto spazio. Un errore è un avviso.
pota_cache() {
local cosa="$1" uscita recuperato
shift
@@ -670,8 +672,8 @@ pota_cache() {
note+=("$cosa: $recuperato recuperati")
}
# A call to the Gitea API with the registry token, which is only in the curl header and never in the job log. Prints
# the HTTP code: 000 if Gitea does not answer.
# Una chiamata all'API di Gitea con il token del registro, che sta solo nell'intestazione di curl e mai nel registro
# del lavoro. Stampa il codice HTTP: 000 se Gitea non risponde.
chiedi() {
local metodo="$1" indirizzo="$2" uscita="$3" codice
codice=$(curl -sS --max-time 30 -X "$metodo" -H "Authorization: token $REGISTRY_TOKEN" -H "Accept: application/json" \
@@ -688,22 +690,21 @@ spiega() {
esac
}
# The sha- tags of the febe package beyond the 10 most recent, with the package API of Gitea 28:
# GET /api/v1/packages/{proprietario}/container/febe?page=N&limit=50 the versions, one page at a time until an
# empty one arrives (the server may give
# fewer than 50 per page)
# DELETE /api/v1/packages/{proprietario}/container/febe/{versione} one version (answers 204)
# Which ones to remove is chosen by versioni-registro.sh (POSIX awk with json.awk: no Node, no jq); here the
# sha-<hexadecimal> form is checked again before every DELETE. Every refusal by the API is a warning that does not
# turn the job red, and after a refusal the registry is not touched any more (the token is the same). The sha256:…
# versions without a tag (the child manifests of an index, with the layers) are never touched: the API does not say
# whether a tag still uses them. Only their number is reported; the CI publishes plain manifests
# (costruisci-immagine.sh), so there should be none, and those no tag uses are removed by a Gitea cleanup rule
# (docs/processo.md, «Registro dei container»).
# Then the CI artifacts (artefatti.sh): the versions of the generic febe-ci package created more than 14 days ago,
# Le etichette sha- del pacchetto febe oltre le 10 più recenti, con l'API dei pacchetti di Gitea 28:
# GET /api/v1/packages/{proprietario}/container/febe?page=N&limit=50 le versioni, una pagina alla volta finché
# ne arriva una vuota (il server può darne
# meno di 50 per pagina)
# DELETE /api/v1/packages/{proprietario}/container/febe/{versione} una versione (risponde 204)
# Quali togliere lo sceglie versioni-registro.sh (awk POSIX con json.awk: niente Node, niente jq); qui si ricontrolla
# la forma sha-<esadecimale> prima di ogni DELETE. Ogni rifiuto dell'API è un avviso che non fa diventare rosso il
# lavoro, e dopo un rifiuto il registro non si tocca più (il token è lo stesso). Le versioni sha256:… senza etichetta (i
# manifest figli di un indice, con gli strati) non si toccano mai: l'API non dice se un'etichetta le usa ancora. Si
# dice solo quante sono; la CI pubblica manifest semplici (costruisci-immagine.sh), quindi non dovrebbero essercene, e
# quelle che nessuna etichetta usa le toglie una regola di pulizia di Gitea (docs/processo.md, «Registro dei container»).
# Poi gli artefatti della CI (artefatti.sh): le versioni del pacchetto generico febe-ci create più di 14 giorni fa,
# GET /api/v1/packages/{proprietario}/generic/febe-ci?page=N&limit=50
# DELETE /api/v1/packages/{proprietario}/generic/febe-ci/{versione} the version with its files (204)
# only with the form <x.y.z>-ci.<n> or <x.y.z>-rilascio.<n>, checked again before every DELETE.
# DELETE /api/v1/packages/{proprietario}/generic/febe-ci/{versione} la versione con i suoi file (204)
# solo con la forma <x.y.z>-ci.<n> o <x.y.z>-rilascio.<n>, ricontrollata prima di ogni DELETE.
registro() {
local tenere=10
echo "== Registro: le etichette sha- del pacchetto febe oltre le $tenere più recenti"
@@ -736,9 +737,9 @@ registro() {
artefatti_della_ci
}
# The pages of the versions of a package in the folder, pagina-<n>.json, up to the first empty one (the server may give
# fewer than 50 per page). Exits with 0 if it read them, 1 if the package is not there (404 on the first page), 2 if
# the API refuses (and reports it).
# Le pagine delle versioni di un pacchetto nella cartella, pagina-<n>.json, fino alla prima vuota (il server può darne
# meno di 50 per pagina). Esce con 0 se le ha lette, 1 se il pacchetto non c'è (404 alla prima pagina), 2 se l'API
# rifiuta (e lo segnala).
pagine() {
local base="$1" cartella="$2" nome="$3" pagina codice
for ((pagina = 1; ; pagina++)); do
@@ -760,7 +761,7 @@ pagine() {
done
}
# The sha- tags of the febe container, from the pages already read.
# Le etichette sha- del contenitore febe, dalle pagine già lette.
contenitore() {
local base="$1" cartella="$2" scelte senza_etichetta quante codice
if ! scelte=$(bash "$cartella_script/versioni-registro.sh" "$tenere" "$cartella"/pagina-*.json) \
@@ -799,8 +800,8 @@ contenitore() {
done <<< "$scelte"
}
# The CI artifacts (artefatti.sh): the versions of the generic febe-ci package created more than 14 days ago, like the
# artifact expiry of the old days.
# Gli artefatti della CI (artefatti.sh): le versioni del pacchetto generico febe-ci create più di 14 giorni fa, come la
# scadenza degli artefatti di una volta.
artefatti_della_ci() {
local giorni=14 base="${GITEA_API%/}/packages/$PROPRIETARIO/generic/febe-ci" cartella esito scelte versione creata codice
echo "== Registro: gli artefatti della CI (pacchetto febe-ci) creati più di $giorni giorni fa"
@@ -840,8 +841,8 @@ artefatti_della_ci() {
done <<< "$scelte"
}
# The cache with the same limit as on Monday: without it, every push of every branch would remove the intermediate
# layers and the mounted caches (RUN --mount=type=cache) that the builds of the other projects have just used.
# La cache con lo stesso limite del lunedì: senza, a ogni push di ogni ramo se ne andrebbero gli strati intermedi e le
# cache montate (RUN --mount=type=cache) che le costruzioni degli altri progetti hanno appena usato.
penzolanti() {
echo "== Immagini senza nome che nessun contenitore usa e cache di costruzione penzolante non usata da 24 ore, di tutti i progetti"
if ((prova)); then
@@ -863,9 +864,9 @@ settimanale() {
fi
}
# Everything «settimanale» does (the unnamed images older than 72 hours are among those no container uses created
# more than 24 hours ago) plus the act_runner leftovers, everyone's images and cache, and the registry. Containers
# first, so that their images, volumes and networks are left with nobody using them.
# Tutto ciò che fa «settimanale» (le immagini senza nome più vecchie di 72 ore sono fra quelle che nessun contenitore
# usa create più di 24 ore fa) e in più i resti di act_runner, le immagini e la cache di tutti e il registro. Prima i
# contenitori, così le loro immagini, i loro volumi e le loro reti restano senza nessuno che li usi.
completa() {
resti_della_ci
resti_di_act_runner 90
+15 -15
View File
@@ -1,15 +1,15 @@
#!/usr/bin/env bash
# Summary of the test results (.trx files of «dotnet test --logger trx»): passed, failed and skipped for each file,
# the names of the failed ones and the reasons of the skipped ones. It writes it to the log and, if the runner offers
# it, to the job summary (GITHUB_STEP_SUMMARY). No response body nor personal data: only test names and messages.
# Riepilogo dei risultati delle prove (file .trx di «dotnet test --logger trx»): superate, fallite e saltate per ogni
# file, i nomi delle fallite e i motivi delle saltate. Lo scrive nel registro e, se il runner lo offre, nel riepilogo
# del lavoro (GITHUB_STEP_SUMMARY). Nessun corpo di risposta né dato personale: solo nomi di prove e messaggi.
#
# .gitea/scripts/riepilogo-prove.sh <cartella dei .trx> [saltate ammesse]
#
# Exits with 1 if a test failed, if the skipped ones are more than those allowed (default 0: the CI has Chromium and
# Xvfb, so no test has a reason to be skipped) or if there is no result at all. The only exception is the «da fare»
# category: the inconclusive results of FeaturesStillToDo (H.264 conformance streams for the parts the decoder does
# not handle yet) whose reason starts with «da fare: » are listed and do not count among the skipped ones.
# Any other inconclusive result, even with «da fare: » in its message, is a skipped one.
# Esce con 1 se una prova è fallita, se le saltate sono più di quelle ammesse (predefinito 0: nella CI ci sono
# Chromium e Xvfb, quindi nessuna prova ha motivo di saltarsi) o se non c'è nessun risultato. Fa eccezione solo la
# categoria «da fare»: le inconclusive di FeaturesStillToDo (flussi di conformità H.264 delle parti che il
# decodificatore non gestisce ancora) il cui motivo comincia con «da fare: » si elencano e non contano fra le saltate.
# Qualunque altra inconclusiva, anche con «da fare: » nel messaggio, è una saltata.
set -euo pipefail
cartella="${1:?Indica la cartella con i file .trx.}"
@@ -29,10 +29,10 @@ trap 'rm -f "$riepilogo"' EXIT
fallite_totali=0
saltate_totali=0
dafare_totali=0
# «Da fare»: an inconclusive result of FeaturesStillToDo whose reason starts with «da fare: » right after the MSTest
# frame («Assert.Inconclusive. », «Assert.Inconclusive failed. », «Assert.Inconclusive non riuscito. »): it marks a part
# not written yet, not a broken environment, and is counted apart. Both the test name and the start of the reason are
# constrained: no other test can skip silently by writing «da fare: » in its message.
# «Da fare»: una inconclusiva di FeaturesStillToDo il cui motivo comincia con «da fare: » subito dopo la cornice di MSTest
# («Assert.Inconclusive. », «Assert.Inconclusive failed. », «Assert.Inconclusive non riuscito. »): segna una parte non
# ancora scritta, non un ambiente rotto, e si conta a parte. Il nome della prova e l'inizio del motivo sono entrambi
# vincolati: nessun'altra prova può saltarsi in silenzio scrivendo «da fare: » nel messaggio.
da_fare='$1 != "Passed" && $1 != "Failed" && $1 != "Error" && $1 != "Timeout" && $1 != "Aborted" && $2 ~ /^FeaturesStillToDo( |\(|$)/ && $3 ~ /^Assert\.Inconclusive[^.]*\. *da fare: /'
{
echo "### Prove"
@@ -43,7 +43,7 @@ da_fare='$1 != "Passed" && $1 != "Failed" && $1 != "Error" && $1 != "Timeout" &&
for trx in "${file[@]}"; do
nome="$(basename "$trx")"
# One result per line (the .trx files are XML over several lines), then name, outcome and first message of each.
# Un risultato per riga (i .trx sono XML su più righe), poi nome, esito e primo messaggio di ciascuno.
righe="$(tr '\r\n' ' ' < "$trx" | sed 's/<UnitTestResult /\n<UnitTestResult /g' | awk '
function attributo(testo, chiave, inizio) {
if (match(testo, chiave "=\"[^\"]*\"")) {
@@ -83,14 +83,14 @@ for trx in "${file[@]}"; do
if (( fallite > 0 )); then
echo " Fallite:"
# The extra lines are read and discarded (no «head»: with pipefail the SIGPIPE would stop the script).
# Le righe in più si leggono e si scartano (niente «head»: con pipefail il SIGPIPE fermerebbe lo script).
printf '%s\n' "$righe" | awk -F'\t' '$1 == "Failed" || $1 == "Error" || $1 == "Timeout" || $1 == "Aborted" {
if (++n > 50) next; m = $3; if (length(m) > 300) m = substr(m, 1, 300) "…"; print " - " $2 ": " m }'
fi
if (( saltate > 0 )); then
echo " Saltate, per motivo:"
# The reason without the MSTest frame («Il metodo … ha generato un'eccezione. Assert.Inconclusive.»).
# Il motivo senza la cornice di MSTest («Il metodo … ha generato un'eccezione. Assert.Inconclusive.»).
printf '%s\n' "$righe" | awk -F'\t' "!($da_fare)"' && $1 != "Passed" && $1 != "Failed" && $1 != "Error" && $1 != "Timeout" && $1 != "Aborted" {
m = $3; sub(/^.*Assert\.Inconclusive\. */, "", m); if (m == "") m = "(nessun motivo)"; print m }' \
| sort | uniq -c | sort -rn | awk 'NR <= 30 { sub(/^ */, " "); print }'
+11 -11
View File
@@ -1,15 +1,15 @@
#!/usr/bin/env bash
# Vulnerability scan of the Docker image with Trivy, at a fixed version (strumento.sh), on the archive produced by
# the build (docker save or buildx --output type=docker): no daemon is needed, and the very image that was tested is
# scanned. Debian packages and Febe's .NET dependencies (the *.deps.json files).
# Scansione delle vulnerabilità dell'immagine Docker con Trivy, a versione fissa (strumento.sh), sull'archivio prodotto
# dalla costruzione (docker save o buildx --output type=docker): non serve il demone, e si scansiona proprio
# l'immagine provata. Pacchetti di Debian e dipendenze .NET di Febe (i file *.deps.json).
#
# .gitea/scripts/scansione-immagine.sh <immagine.tar> [cartella dei rapporti]
#
# The rule (docs/processo.md, «Rilievi di sicurezza»):
# - CRITICAL with a fix available: the job fails and the image is not published;
# - HIGH, and CRITICAL still without a fix: reported in the log and in trivy.json, without stopping anything.
# The exceptions live only in .trivyignore, at the repository root: one identifier per line, with the expiry
# (exp:AAAA-MM-GG) and, on the line above, the written reason and who decided it.
# La regola (docs/processo.md, «Rilievi di sicurezza»):
# - CRITICAL con una correzione disponibile: il lavoro fallisce e l'immagine non si pubblica;
# - HIGH, e CRITICAL ancora senza correzione: si riportano nel registro e in trivy.json, senza fermare nulla.
# Le eccezioni stanno solo in .trivyignore, alla radice del repository: un identificativo per riga, con la scadenza
# (exp:AAAA-MM-GG) e, sulla riga sopra, il motivo scritto e chi l'ha deciso.
set -euo pipefail
radice="$(git rev-parse --show-toplevel)"
@@ -22,7 +22,7 @@ strumenti="$lavoro/febe-strumenti"
bash "$radice/.gitea/scripts/strumento.sh" trivy "$strumenti"
mkdir -p "$rapporti"
# No progress bars, no check for new versions, no usage data.
# Niente barre di avanzamento, niente controllo di versioni nuove, niente dati d'uso.
export TRIVY_NO_PROGRESS=true TRIVY_SKIP_VERSION_CHECK=true TRIVY_DISABLE_TELEMETRY=true
export TRIVY_CACHE_DIR="$lavoro/febe-trivy-cache"
comuni=(image --input "$archivio" --scanners vuln --timeout 20m)
@@ -35,8 +35,8 @@ echo "== Vulnerabilità HIGH e CRITICAL (rapporto: non fermano il lavoro)"
"$strumenti/trivy" "${comuni[@]}" --severity HIGH,CRITICAL --format json --output "$rapporti/trivy.json" --exit-code 0
"$strumenti/trivy" convert --format table "$rapporti/trivy.json"
# The count with our own JSON reader (json.sh, awk): no jq. One line per vulnerability, severity and the version that
# fixes it (empty or null if there is none). An unreadable report stops nothing: it just says so.
# Il conteggio con il lettore JSON nostro (json.sh, awk): niente jq. Una riga per vulnerabilità, gravità e versione
# che la corregge (vuota o null se non c'è). Un rapporto illeggibile non ferma nulla: lo dice e basta.
if vulnerabilita=$(bash "$radice/.gitea/scripts/json.sh" campi "Results/*/Vulnerabilities/*" Severity,FixedVersion "$rapporti/trivy.json"); then
conteggio=$(awk -F '\t' '
$1 == "HIGH" { alte++ }
+8 -9
View File
@@ -1,15 +1,14 @@
#!/usr/bin/env bash
# Looks for secrets (tokens, keys, passwords) with gitleaks, at a fixed version (strumento.sh), in the whole history
# of the commit being verified: every commit it descends from, not only the last one. Each branch is checked on its
# own push (main at every merge), so a finding on one branch does not block the others. A secret never appears in
# full: --redact replaces it with REDACTED in the log and in the report, and here only rule, file, line, commit and
# fingerprint are printed.
# Cerca segreti (gettoni, chiavi, password) con gitleaks, a versione fissa (strumento.sh), in tutta la storia del
# commit verificato: ogni commit da cui discende, non solo l'ultimo. Ogni ramo si controlla al suo push (main a ogni
# unione), così un rilievo su un ramo non blocca gli altri. Un segreto non compare mai per intero: --redact lo
# sostituisce con REDACTED nel registro e nel rapporto, e qui si stampano solo regola, file, riga, commit e impronta.
#
# .gitea/scripts/segreti.sh [cartella del rapporto]
#
# What to do with a finding: docs/processo.md, «Rilievi di sicurezza». In short: a real secret is revoked at once
# (removing it from the history is not enough); a false alarm already checked (fake test data) goes into
# .gitleaksignore with its fingerprint and, on the line above, a comment saying what it is and who checked it.
# Che cosa fare con un rilievo: docs/processo.md, «Rilievi di sicurezza». In breve: un segreto vero si revoca subito
# (toglierlo dalla storia non basta); un falso allarme già controllato (un dato di prova finto) si mette in
# .gitleaksignore con la sua impronta e, sulla riga sopra, un commento che dice che cos'è e chi l'ha controllato.
set -euo pipefail
radice="$(git rev-parse --show-toplevel)"
@@ -38,7 +37,7 @@ if ((stato == 0)); then
exit 0
fi
# The summary with our own JSON reader (json.sh, awk): no jq.
# Il riassunto con il lettore JSON nostro (json.sh, awk): niente jq.
if [[ -s "$rapporto" ]] \
&& rilievi=$(bash "$radice/.gitea/scripts/json.sh" campi "*" RuleID,File,StartLine,Commit,Fingerprint "$rapporto"); then
quanti=0
+8 -8
View File
@@ -1,15 +1,15 @@
#!/usr/bin/env bash
# Installs one of the two external tools of the CI, the only ones Alberto approved and only for the CI (20 October
# 2026): gitleaks (secrets in the history) and Trivy (image vulnerabilities). Fixed version, archive downloaded from
# the project's release and installed only if its SHA-256 hash matches the one written here. The hashes are those of
# the releases' *_checksums.txt files, checked again on 20 October 2026 against the downloaded archive and the hash
# GitHub shows for the attachment.
# Installa uno dei due strumenti esterni della CI, gli unici approvati da Alberto e solo per la CI (20 ottobre 2026):
# gitleaks (segreti nella storia) e Trivy (vulnerabilità dell'immagine). Versione fissa, archivio scaricato dalla
# release del progetto e installato solo se la sua impronta SHA-256 coincide con quella scritta qui. Le impronte sono
# quelle dei file *_checksums.txt delle release, ricontrollate il 20 ottobre 2026 sull'archivio scaricato e
# sull'impronta che GitHub mostra per l'allegato.
#
# .gitea/scripts/strumento.sh gitleaks|trivy <cartella>
#
# To update a tool, version and hash change together, in a single commit, with a line in docs/decisioni.md. Never
# «latest», never third-party actions (trivy-action was compromised in March 2026, CVE-2026-33634), never an install
# script downloaded on the fly.
# Per aggiornare uno strumento si cambiano versione e impronta insieme, in un commit solo, con una riga in
# docs/decisioni.md. Mai «latest», mai le azioni di terzi (trivy-action fu compromessa a marzo 2026, CVE-2026-33634),
# mai uno script di installazione scaricato al volo.
set -euo pipefail
nome="${1:?Indica lo strumento: gitleaks o trivy.}"
+19 -20
View File
@@ -1,24 +1,23 @@
#!/usr/bin/env bash
# Chooses the versions to remove from Gitea's package registry (pulizia-docker.sh, «completa» mode). It reads only the
# files it is given, with json.awk and versioni-registro.awk (POSIX awk: no jq, no Node): no network, no writes, so it
# is tested with a JSON file (PipelineTests).
# Sceglie le versioni da togliere dal registro dei pacchetti di Gitea (pulizia-docker.sh, modo «completa»). Legge solo
# i file che riceve, con json.awk e versioni-registro.awk (awk POSIX: niente jq, niente Node): niente rete, niente
# scritture, quindi si prova con un file JSON (PipelineTests).
#
# versioni-registro.sh <quante tenere> <pagina.json>... the sha-<7 to 40 hexadecimal digits> tags of
# the febe container beyond the N most recent
# versioni-registro.sh senza-etichetta <pagina.json>... the sha256:<64 digits> versions of the febe
# container (the manifests of an index: only to
# be counted)
# versioni-registro.sh scadute <giorni> <adesso> <pagina.json>... the <x.y.z>-ci.<n> and <x.y.z>-rilascio.<n>
# versions of the generic febe-ci package (the CI
# artifacts, artefatti.sh) created more than
# <giorni> days before <adesso>, in seconds since
# 1970
# versioni-registro.sh <quante tenere> <pagina.json>... le etichette sha-<da 7 a 40 cifre esadecimali>
# del contenitore febe oltre le N più recenti
# versioni-registro.sh senza-etichetta <pagina.json>... le versioni sha256:<64 cifre> del contenitore
# febe (i manifest di un indice: solo da contare)
# versioni-registro.sh scadute <giorni> <adesso> <pagina.json>... le versioni <x.y.z>-ci.<n> e
# <x.y.z>-rilascio.<n> del pacchetto generico
# febe-ci (gli artefatti della CI, artefatti.sh)
# create più di <giorni> giorni prima di <adesso>,
# in secondi dal 1970
#
# Each page is a response of GET /api/v1/packages/{owner}/{type}/{name} of Gitea 28. Prints, oldest first and one per
# line, «version<TAB>created». Everything else always stays: main, latest, the X.Y.Z versions (also X.Y.Z-rc.N), the
# digests, every other tag, a sha- tag or an artifact without a readable date. Among the sha- tags the dates count,
# not the text; with equal dates the identifier. If a file is not a JSON list it exits with 2 and prints nothing: when
# in doubt nothing is removed.
# Ogni pagina è una risposta di GET /api/v1/packages/{proprietario}/{tipo}/{nome} di Gitea 28. Stampa, dalla più
# vecchia e una per riga, «versione<TAB>creata». Tutto il resto resta sempre: main, latest, le versioni X.Y.Z (anche
# X.Y.Z-rc.N), i digest, ogni altra etichetta, una sha- o un artefatto senza una data che si legga. Fra le sha- contano
# le date, non il testo; a parità di data l'identificativo. Se un file non è un elenco JSON esce con 2 e non stampa
# nulla: nel dubbio non si toglie niente.
set -euo pipefail
qui="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -49,7 +48,7 @@ export LC_ALL=C
tab=$'\t'
versioni=$(awk -v tipo="$tipo" -v nome="$nome" -f "$qui/json.awk" -f "$qui/versioni-registro.awk" "$@") || exit 2
# Lines: milliseconds (or «-»), identifier, order, version, date as written.
# Righe: millisecondi (o «-»), identificativo, ordine, versione, data come scritta.
case "$modo" in
senza-etichetta)
awk -F "$tab" -v OFS="$tab" '$4 ~ /^sha256:[0-9a-f]+$/ && length($4) == 71 { if ($1 == "-") $1 = 0; print }' <<< "$versioni" \
@@ -61,7 +60,7 @@ case "$modo" in
| sort -t "$tab" -k1,1n -k2,2n -k3,3n | cut -f4,5
;;
*)
# The most recent first (date, then identifier), the first N are skipped, the rest from the oldest.
# Le più recenti prima (data, poi identificativo), si saltano le prime N, il resto dalla più vecchia.
awk -F "$tab" '$1 != "-" && $4 ~ /^sha-[0-9a-f]+$/ && length($4) >= 11 && length($4) <= 44' <<< "$versioni" \
| sort -t "$tab" -k1,1nr -k2,2nr -k3,3n | tail -n "+$((modo + 1))" \
| awk '{ righe[NR] = $0 } END { for (i = NR; i > 0; i--) print righe[i] }' | cut -f4,5
+22 -23
View File
@@ -1,22 +1,22 @@
# Monday cleanup (at 4:17, Gitea server time) and by hand (Actions ▸ pulizia ▸ Esegui) of the runner's Docker daemon and
# of the container registry. By hand, with «Solo prova» ticked, it lists what it would remove and removes nothing: to
# be run before the first real cleanup and after every change to the script.
# Every verification and release run already removes what it creates and, for everyone, the unnamed images and the
# dangling build cache unused for 24 hours. Here, since 21 October 2026 (decision of Alberto: delete everything that
# is no longer needed), what nobody needs any more is removed too, of any project (pulizia-docker.sh completa):
# - the leftovers of the Febe CI: stopped test containers (label febe.ci.prova and name febe-prova-<esecuzione>,
# never the febe.ci.* labels a real Febe inherits from the image), local names febe-ci:<esecuzione>, builders
# febe-ci-<esecuzione>, the febe:ci image of the old workflow;
# - the leftovers of act_runner: stopped containers, volumes and networks GITEA-ACTIONS-TASK-… no container uses,
# older than 90 minutes;
# - the images no container uses, running or stopped, created more than 24 hours ago (from an image in use Docker
# removes the extra names), and the daemon's build cache unused for 24 hours. The base images (debian:trixie,
# moby/buildkit, …) are downloaded again by the first run that asks for them;
# - with the REGISTRY_TOKEN secret, the registry's sha- tags beyond the 10 most recent, never main, latest or X.Y.Z,
# and the CI artifacts (generic package febe-ci, artefatti.sh) created more than 14 days ago.
# Never system prune, container prune, volume prune or network prune; never a container, a volume or a network that
# does not belong to the CI. A test container still running is reported and the job turns red; a refusal by the
# registry API is only a warning. Details in .gitea/scripts/pulizia-docker.sh and in docs/processo.md, «Pulizia».
# Pulizia del lunedì (alle 4:17, ora del server di Gitea) e a mano (Actions ▸ pulizia ▸ Esegui) del demone Docker del
# runner e del registro dei container. A mano, con «Solo prova» spuntato, elenca che cosa toglierebbe e non toglie
# nulla: da lanciare prima della prima pulizia vera e dopo ogni cambio dello script.
# Ogni esecuzione di verifica e di rilascio toglie già ciò che crea e, per tutti, le immagini senza nome e la cache di
# costruzione penzolante non usata da 24 ore. Qui, dal 21 ottobre 2026 (decisione di Alberto: eliminare tutto ciò che
# non serve più), si toglie anche ciò che non serve più a nessuno, di qualunque progetto (pulizia-docker.sh completa):
# - i resti della CI di Febe: contenitori di prova fermi (etichetta febe.ci.prova e nome febe-prova-<esecuzione>, mai
# le etichette febe.ci.* che un Febe vero eredita dall'immagine), nomi locali febe-ci:<esecuzione>, builder
# febe-ci-<esecuzione>, l'immagine febe:ci del vecchio flusso;
# - i resti di act_runner: contenitori fermi, volumi e reti GITEA-ACTIONS-TASK-… che nessun contenitore usa, più
# vecchi di 90 minuti;
# - le immagini che nessun contenitore usa, né acceso né fermo, create più di 24 ore fa (di un'immagine in uso Docker
# toglie i nomi in più), e la cache di costruzione del demone non usata da 24 ore. Le immagini di base
# (debian:trixie, moby/buildkit, …) si riscaricano alla prima esecuzione che le chiede;
# - con il segreto REGISTRY_TOKEN, le etichette sha- del registro oltre le 10 più recenti, mai main, latest o X.Y.Z,
# e gli artefatti della CI (pacchetto generico febe-ci, artefatti.sh) creati più di 14 giorni fa.
# Mai system prune, container prune, volume prune o network prune; mai un contenitore, un volume o una rete che non sia
# della CI. Un contenitore di prova ancora acceso si segnala e il lavoro diventa rosso; un rifiuto dell'API del
# registro è solo un avviso. Dettagli in .gitea/scripts/pulizia-docker.sh e in docs/processo.md, «Pulizia».
name: pulizia
on:
@@ -67,10 +67,9 @@ jobs:
git checkout -q --force --detach "$GITHUB_SHA"
git log -1 --format='Commit %h: %s'
# Gitea 28 puts the «prova» checkbox in the event as text, "true" or "false"; on Monday the event has no inputs
# and the cleanup is the real one. A start through the API passes the value as it is: any other («True», «1»)
# stops the job without touching anything. The registry token goes only into this step's environment and is
# never printed.
# Gitea 28 mette nell'evento la casella «prova» come testo, "true" o "false"; il lunedì l'evento non ha input e
# la pulizia è quella vera. Un avvio con l'API passa il valore così com'è: qualunque altro («True», «1») ferma il
# lavoro senza toccare nulla. Il token del registro va solo nell'ambiente di questo passo e non si stampa mai.
- name: Pulizia completa del demone Docker e del registro
env:
PROVA: ${{ gitea.event.inputs.prova }}
+58 -58
View File
@@ -1,43 +1,43 @@
# Release at every vX.Y.Z tag (also vX.Y.Z-something for a preview):
# 1. prove: the tag matches <Version> in Directory.Build.props, the solution builds with warnings as errors and all
# the tests pass, in the same Debian 13 container as the verification (real Chromium and Xvfb) and without any
# skipped test. Without green tests nothing is built or released;
# 2. windows: Febe.exe in a single file, our own installer (src/Febe.Installer) and the portable zip
# (installer/costruisci.sh, runs on Linux with the .NET SDK only): the gate before the image;
# 3. immagine: after the installer, the Docker image (the tests also run inside the build), tested without network
# and scanned with Trivy as in the verification (a CRITICAL with a fix stops everything), then published on the
# Gitea container registry as <registro>/<proprietario>/febe:X.Y.Z and :latest (only for versions without a
# dash). The job says whether it published it, and at the end it always removes the run's images, containers,
# cache and builder, then the unnamed images and the dangling build cache unused for 24 hours of all the
# daemon's projects;
# 4. release: only after the tests, the installer and the image. It rebuilds installer and zip from the same commit
# with the same script (without actions there is no way to pass artifacts between jobs that does not depend on
# REGISTRY_TOKEN, and the release must come out without it too), then creates the release (or completes it, if
# it already exists) with installer, portable zip, Unraid template and the Docker Compose archive (compose.yml
# with the seccomp profile next to it); the notes say where the image is, or that it was not published.
# Rilascio a ogni tag vX.Y.Z (anche vX.Y.Z-qualcosa per un'anteprima):
# 1. prove: il tag coincide con <Version> di Directory.Build.props, la soluzione si compila con gli avvisi come errori
# e tutte le prove passano, nello stesso contenitore Debian 13 della verifica (Chromium e Xvfb veri) e
# senza nessuna prova saltata. Senza prove verdi non si costruisce né si rilascia nulla;
# 2. windows: Febe.exe in un file solo, il programma di installazione nostro (src/Febe.Installer) e lo zip portabile
# (installer/costruisci.sh, gira su Linux con il solo .NET SDK): il cancello prima dell'immagine;
# 3. immagine: dopo l'installatore, l'immagine Docker (le prove girano anche dentro la build), provata senza rete e
# scansionata con Trivy come nella verifica (una CRITICAL con correzione ferma tutto), poi pubblicata sul registro
# dei container di Gitea come <registro>/<proprietario>/febe:X.Y.Z e :latest (solo per le versioni senza
# trattino). Il lavoro dice se l'ha pubblicata, e alla fine toglie sempre immagini, contenitori, cache e builder
# dell'esecuzione, poi le immagini senza nome e la cache di costruzione penzolante non usata da 24 ore di tutti i
# progetti del demone;
# 4. release: solo dopo le prove, l'installatore e l'immagine. Ricostruisce installatore e zip dallo stesso commit con
# lo stesso script (senza azioni non c'è un passaggio di artefatti fra i lavori che non dipenda da REGISTRY_TOKEN,
# e la release deve uscire anche senza), poi crea la release (o la completa, se esiste già) con installatore, zip
# portabile, modello Unraid e l'archivio per Docker Compose (compose.yml con il profilo seccomp accanto); le note
# dicono dove sta l'immagine, o che non è stata pubblicata.
#
# No actions, as in the verification (decision of 18 November 2026): sources with git and the job token, SDK with
# .gitea/scripts/dotnet.sh, buildx builder with costruisci-immagine.sh builder, test results and Trivy report in the
# generic package febe-ci (version <versione>-rilascio.<numero>, with REGISTRY_TOKEN; artefatti.sh).
# Niente azioni, come nella verifica (decisione del 18 novembre 2026): sorgenti con git e il gettone del lavoro, SDK con
# .gitea/scripts/dotnet.sh, builder buildx con costruisci-immagine.sh builder, risultati delle prove e rapporto di Trivy
# nel pacchetto generico febe-ci (versione <versione>-rilascio.<numero>, con REGISTRY_TOKEN; artefatti.sh).
#
# Repository secret (Impostazioni ▸ Actions ▸ Segreti): REGISTRY_TOKEN, a user token with the permissions
# «package: read and write». Without it, the image is built and tested but not published: the release comes out
# anyway, with the Windows installer, and its notes say the image of this version is missing. Once the secret is
# added, the tag's workflow is run again: the image is published and the release notes are corrected.
# Optional variable (Impostazioni ▸ Actions ▸ Variabili): REGISTRY, the registry name as the runner reaches it (for
# example 192.168.30.23:3000); if missing, the host of the Gitea server address (its ROOT_URL) is used.
# The registry answers in HTTP: publishing goes through buildx with a builder of its own (docker-container) whose
# buildkit configuration says that registry is HTTP and insecure, so the runner's Docker does not need it among its
# insecure-registries. The credentials go into the Docker client configuration, without «docker login» (which would
# go through the daemon, and the daemon would try HTTPS).
# Segreto del repository (Impostazioni ▸ Actions ▸ Segreti): REGISTRY_TOKEN, un token dell'utente con i permessi
# «package: read and write». Senza, l'immagine si costruisce e si prova ma non si pubblica: la release esce lo stesso,
# con l'installatore per Windows, e le sue note dicono che l'immagine di questa versione non c'è. Aggiunto il segreto,
# si rilancia il flusso del tag: l'immagine si pubblica e le note della release si correggono.
# Variabile facoltativa (Impostazioni ▸ Actions ▸ Variabili): REGISTRY, il nome del registro come lo raggiunge il
# runner (per esempio 192.168.30.23:3000); se manca si usa l'host dell'indirizzo del server Gitea (il suo ROOT_URL).
# Il registro risponde in HTTP: la pubblicazione passa da buildx con un builder proprio (docker-container) a cui la
# configurazione di buildkit dice che quel registro è in HTTP e insicuro, così non serve che il Docker del runner lo
# abbia fra gli insecure-registries. Le credenziali vanno nella configurazione del client Docker, senza «docker login»
# (che passerebbe dal demone, e il demone proverebbe HTTPS).
name: rilascio
on:
push:
tags: ["v*"]
# Like the verification and the cleanup: every step with «bash -e -o pipefail», whatever the default shell of the
# runner or of the container (the Sorgenti step uses bash arrays; in a Debian container the default would be dash).
# Come la verifica e la pulizia: ogni passo con «bash -e -o pipefail», qualunque sia la shell predefinita del runner
# o del contenitore (i Sorgenti usano gli array di bash; in un contenitore Debian la predefinita sarebbe dash).
defaults:
run:
shell: bash
@@ -51,9 +51,9 @@ jobs:
prove:
runs-on: ubuntu-latest
timeout-minutes: 60
# The same environment as the verification tests: Debian 13 with real Chromium and Xvfb and the summary that
# allows no skipped tests. On ubuntu-latest the browser tests (among them the return after sign-in,
# return-path.js) would be inconclusive and a release would come out without having run them.
# Lo stesso ambiente delle prove della verifica: Debian 13 con Chromium e Xvfb veri e il riepilogo che non
# ammette prove saltate. Su ubuntu-latest le prove nel browser (fra cui il ritorno dopo l'accesso, return-path.js)
# sarebbero inconcludenti e un rilascio uscirebbe senza averle fatte.
container:
image: debian:trixie
options: --shm-size=1g
@@ -108,7 +108,7 @@ jobs:
dotnet test tests/Febe.Tests -c Release --no-build --nologo
--logger "trx;LogFileName=prove.trx" --results-directory out/prove
# No skipped test: an inconclusive test (for example without Chromium) stops the release.
# Nessuna prova saltata: una prova inconcludente (per esempio senza Chromium) ferma il rilascio.
- name: Riepilogo delle prove
if: ${{ !cancelled() }}
run: bash .gitea/scripts/riepilogo-prove.sh out/prove 0
@@ -128,7 +128,7 @@ jobs:
needs: prove
timeout-minutes: 30
env:
# Like the installer job of verifica.yml: the runner image does not guarantee ICU, and it is not needed here.
# Come l'installatore di verifica.yml: l'immagine del runner non garantisce ICU, e qui non serve.
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: "true"
steps:
- name: Sorgenti
@@ -163,7 +163,7 @@ jobs:
immagine:
runs-on: ubuntu-latest
# After the installer: :X.Y.Z and :latest come out only if the release can come out too.
# Dopo l'installatore: :X.Y.Z e :latest escono solo se anche la release potrà uscire.
needs: [prove, windows]
timeout-minutes: 60
env:
@@ -198,7 +198,7 @@ jobs:
git checkout -q --force --detach "$GITHUB_SHA"
git log -1 --format='Commit %h: %s'
# What an interrupted run could not remove, and an earlier attempt of this same run.
# Ciò che un'esecuzione interrotta non ha potuto togliere, e un tentativo precedente di questa stessa esecuzione.
- name: Resti di esecuzioni interrotte
run: |
bash .gitea/scripts/pulizia-docker.sh residui 90
@@ -219,11 +219,11 @@ jobs:
echo "IMAGE=$REGISTRY/$OWNER/febe" >> "$GITHUB_ENV"
echo "immagine=$REGISTRY/$OWNER/febe" >> "$GITHUB_OUTPUT"
# A buildx builder of our own, which knows that the home registry answers in HTTP.
# Un builder buildx proprio, che sa che il registro di casa risponde in HTTP.
- name: Builder buildx dell'esecuzione
run: bash .gitea/scripts/costruisci-immagine.sh builder "$REGISTRY"
# The same arguments and labels as the publication (costruisci-immagine.sh): that one comes from this one's cache.
# Gli stessi argomenti ed etichette della pubblicazione (costruisci-immagine.sh): quella esce dalla cache di questa.
- name: Costruzione dell'immagine (le prove girano dentro la build)
run: |
bash .gitea/scripts/costruisci-immagine.sh archivio "$ARCHIVIO" "$PROVA"
@@ -267,37 +267,37 @@ jobs:
REGISTRO_UTENTE: ${{ gitea.actor }}
run: |
set -eu
# costruisci-immagine.sh pubblica puts the credentials in a client configuration of its own, removed at the
# end: buildx passes them to the builder, the daemon is not involved.
# Le credenziali le mette costruisci-immagine.sh pubblica in una configurazione del client solo sua, tolta
# alla fine: buildx le passa al builder, il demone non c'entra.
NOMI="$IMAGE:$VERSION"
case "$VERSION" in
*-*) echo "Versione di anteprima: :latest non si sposta." ;;
*) NOMI="$NOMI $IMAGE:latest" ;;
esac
# The same build as before (from the builder's cache), this time pushed to the registry by buildx.
# La stessa costruzione di prima (dalla cache del builder), questa volta spinta sul registro da buildx.
bash .gitea/scripts/costruisci-immagine.sh pubblica $NOMI
echo "pubblicata=si" >> "$GITHUB_OUTPUT"
- name: Pulizia (sempre)
if: always()
run: |
# The client configuration with the credentials, if an interruption skipped the trap of whoever wrote it.
# La configurazione del client con le credenziali, se un'interruzione ha saltato la trap di chi l'ha scritta.
rm -rf "${RUNNER_TEMP:-/tmp}/febe-docker-$ESECUZIONE"
if [ -n "${ARCHIVIO:-}" ]; then rm -f "$ARCHIVIO"; fi
bash .gitea/scripts/pulizia-docker.sh esecuzione "$ESECUZIONE"
# Then, for all the daemon's projects, what nobody uses: unnamed images and dangling build cache unused for
# 24 hours. It never fails the job.
# Poi, per tutti i progetti del demone, ciò che nessuno usa: immagini senza nome e cache di costruzione
# penzolante non usata da 24 ore. Non fa mai fallire il lavoro.
bash .gitea/scripts/pulizia-docker.sh penzolanti || echo "::warning::La pulizia di ciò che nessuno usa non è riuscita."
release:
runs-on: ubuntu-latest
# The tests are green, the installer is there and the image was built: published, or not published only because
# the secret is missing (the «immagine» job says so and the notes report it). If the build, the container test,
# the scan or the push to the registry fail, no release comes out.
# Le prove sono verdi, l'installatore c'è e l'immagine si è costruita: pubblicata, o non pubblicata per la sola
# mancanza del segreto (il lavoro «immagine» lo dice e le note lo riportano). Se la costruzione, la prova del
# contenitore, la scansione o la spinta sul registro falliscono, non esce nessuna release.
needs: [prove, windows, immagine]
timeout-minutes: 40
env:
# Like «windows»: the runner image does not guarantee ICU, and building the installer does not need it.
# Come «windows»: l'immagine del runner non garantisce ICU, e per costruire l'installatore non serve.
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: "true"
steps:
- name: Sorgenti
@@ -324,7 +324,7 @@ jobs:
- name: SDK .NET 10
run: bash .gitea/scripts/dotnet.sh 10.0
# The same commit and the same script as the «windows» job, which already acted as the gate before the image.
# Lo stesso commit e lo stesso script del lavoro «windows», che ha già fatto da cancello prima dell'immagine.
- name: Febe.exe, programma di installazione e zip portabile per la release
run: bash installer/costruisci.sh "${GITHUB_REF_NAME#v}"
@@ -339,7 +339,7 @@ jobs:
set -eu
TAG="${GITHUB_REF_NAME}"
VERSION="${TAG#v}"
case "$VERSION" in *-*|0.*) PRE=true ;; *) PRE=false ;; esac # 0.x versions are previews
case "$VERSION" in *-*|0.*) PRE=true ;; *) PRE=false ;; esac # le versioni 0.x sono anteprime
NOTE=$(awk -v v="$VERSION" '/^## /{p=($2==v)} p' CHANGELOG.md || true)
[ -n "$NOTE" ] || NOTE="Febe $VERSION"
if [ "$PUBBLICATA" = "si" ]; then
@@ -349,12 +349,12 @@ jobs:
esac
IMMAGINE_NOTA="Immagine Docker: $DOVE. Il registro risponde in HTTP: il Docker che la scarica deve averlo fra gli \`insecure-registries\`."
else
IMMAGINE_NOTA="**L'immagine Docker di questa versione non è stata pubblicata** (${MOTIVO:-motivo sconosciuto}): questo rilascio non aggiorna \`:latest\`, e Unraid e Docker Compose continuano a usare l'immagine che avevano già, se ce n'era una. Febe per Windows, qui allegato, è provato come sempre. Per pubblicare l'immagine, rilancia il flusso di rilascio di questo tag dopo aver risolto il problema: queste note si aggiornano."
IMMAGINE_NOTA="**L'immagine Docker di questa versione non è stata pubblicata** (${MOTIVO:-motivo sconosciuto}): \`:latest\` resta sulla versione precedente, e Unraid e Docker Compose continuano a usare quella. Febe per Windows, qui allegato, è provato come sempre. Per pubblicare l'immagine, rilancia il flusso di rilascio di questo tag dopo aver risolto il problema: queste note si aggiornano."
fi
NOTE=$(printf '%s\n\n### Immagine Docker\n\n%s\n' "$NOTE" "$IMMAGINE_NOTA")
# JSON read and written with .gitea/scripts/json.sh (awk), no jq. Gitea's responses go to a file: the reader
# reads files, not a stream.
# JSON letto e scritto con .gitea/scripts/json.sh (awk), niente jq. Le risposte di Gitea in un file: il
# lettore legge file, non un flusso.
RISPOSTA="${RUNNER_TEMP:-/tmp}/febe-release-${GITHUB_RUN_ID:-0}.json"
ID=""
if curl -sf -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG" -o "$RISPOSTA"; then
@@ -371,7 +371,7 @@ jobs:
echo "Release $TAG creata (id $ID)"
else
[[ "$ID" =~ ^[0-9]+$ ]] || { echo "Identificativo della release inatteso: «$ID»." >&2; exit 1; }
# The notes say how it went this time (for example: the image is now published).
# Le note dicono come è andata questa volta (per esempio: l'immagine ora è pubblicata).
printf '{"body":%s}' "$(bash .gitea/scripts/json.sh stringa "$NOTE")" \
| curl -sf -X PATCH -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
--data-binary @- "$API/releases/$ID" > /dev/null
@@ -379,7 +379,7 @@ jobs:
fi
cp docker/unraid/febe.xml "out/febe-unraid-$VERSION.xml"
# compose.yml points to the seccomp profile with a relative path: the archive carries them together.
# compose.yml indica il profilo seccomp con un percorso relativo: l'archivio li porta insieme.
COMPOSE="out/febe-compose-$VERSION"
rm -rf "$COMPOSE"
mkdir -p "$COMPOSE/chromium"
+57 -56
View File
@@ -1,34 +1,34 @@
# Verification: at every push on any branch (tags are taken by rilascio.yml) and by hand (Actions ▸ verifica ▸ Esegui).
# Its four jobs are the checks required to merge into main (docs/processo.md):
# controlli script syntax, workflows in block YAML and without actions, conflict markers, version, projects of
# the solution, JSON; secrets in the whole history with gitleaks (version and hash pinned);
# prove build of the whole solution with warnings as errors and all the tests of tests/Febe.Tests (never
# «dotnet test» on the whole solution: tests/Febe.Tests.Windows runs only on Windows) with real
# Chromium and Xvfb in a Debian 13 container: no test may be skipped, except the «da fare» ones of
# H264ConformanceTests.FeaturesStillToDo (riepilogo-prove.sh counts them apart).
# The synthetic world of the test site has seed 13 and, for the SitoDiProva category, also the seed of
# this run, written in the log to reproduce a failure;
# installatore Febe-Setup-<versione>-ci.<numero>.exe (our own installer, src/Febe.Installer) and the portable zip;
# only the .NET SDK is needed;
# immagine after the installer: the Docker image built with buildx, tested without network (start, health,
# Chromium, it_IT) and scanned with Trivy (it stops for a CRITICAL with a fix); only after a push on
# main it publishes it as :main and :sha-<7 characters> (:latest is left to the release). At the end,
# always, it removes this run's images, containers, cache and builder, then the unnamed images and the
# dangling build cache unused for 24 hours of all the daemon's projects.
# Verifica: a ogni push su qualunque ramo (i tag li prende rilascio.yml) e a mano (Actions ▸ verifica ▸ Esegui).
# I suoi quattro lavori sono i controlli richiesti per unire in main (docs/processo.md):
# controlli sintassi degli script, flussi in YAML a blocchi e senza azioni, segni di conflitto, versione,
# progetti della soluzione, JSON; segreti in tutta la storia con gitleaks (versione e impronta fissate);
# prove compilazione di tutta la soluzione con gli avvisi come errori e tutte le prove di tests/Febe.Tests
# (mai «dotnet test» sulla soluzione intera: tests/Febe.Tests.Windows gira solo su Windows) con
# Chromium e Xvfb veri in un contenitore Debian 13: nessuna prova deve saltarsi, tranne le «da fare»
# di H264ConformanceTests.FeaturesStillToDo (riepilogo-prove.sh le conta a parte).
# Il mondo sintetico del sito di prova ha il seme 13 e, per la categoria SitoDiProva, anche il seme di
# questa esecuzione, scritto nel registro per rifare un errore;
# installatore Febe-Setup-<versione>-ci.<numero>.exe (il programma di installazione nostro, src/Febe.Installer) e
# lo zip portabile; serve solo il .NET SDK;
# immagine dopo l'installatore: l'immagine Docker costruita con buildx, provata senza rete (parte, salute,
# Chromium, it_IT) e scansionata con Trivy (si ferma per una CRITICAL con correzione); solo dopo un push
# su main la pubblica come :main e :sha-<7 caratteri> (:latest resta al rilascio). Alla fine, sempre,
# toglie immagini, contenitori, cache e builder di questa esecuzione, poi le immagini senza nome e la
# cache di costruzione penzolante non usata da 24 ore di tutti i progetti del demone.
#
# No actions (decision of Alberto of 18 November 2026: no external components): every step is a command. The sources
# arrive with git and the job token, the .NET SDK with .gitea/scripts/dotnet.sh (verified against the hash in
# Microsoft's metadata), the buildx builder with costruisci-immagine.sh builder. The artifacts (test results,
# installer and zip, gitleaks and Trivy reports) go to Gitea's package registry, generic package febe-ci, version
# <versione>-ci.<numero>, with REGISTRY_TOKEN (.gitea/scripts/artefatti.sh); the Monday cleanup removes those older
# than 14 days. Without the secret a warning, and the job stays green. No step uses Node.
# Niente azioni (decisione di Alberto del 18 novembre 2026: niente componenti esterni): ogni passo è un comando. I
# sorgenti arrivano con git e il gettone del lavoro, l'SDK .NET con .gitea/scripts/dotnet.sh (verificato con l'impronta
# dei metadati di Microsoft), il builder buildx con costruisci-immagine.sh builder. Gli artefatti (risultati delle
# prove, installatore e zip, rapporti di gitleaks e di Trivy) vanno nel registro dei pacchetti di Gitea, pacchetto
# generico febe-ci, versione <versione>-ci.<numero>, con REGISTRY_TOKEN (.gitea/scripts/artefatti.sh); la pulizia del
# lunedì toglie quelli di più di 14 giorni. Senza il segreto un avviso, e il lavoro resta verde. Nessun passo usa Node.
#
# No «pull_request»: in Gitea a pull request shows the status of its last commit, which the branch push has already
# verified; pull_request would redo everything on the same commit (refs/pull/N/head) on the only runner.
# Runner: act_runner with the ubuntu-latest label, one job at a time. The jobs talk to the server's Docker daemon, the
# same as Encelado, Mimante and the other projects: no mounts of the job folder into other containers (on the server
# the paths are different); images travel as archives and build contexts.
# What of Gitea 28 is used and why: docs/decisioni.md (20 October and 18 November 2026) and docs/processo.md.
# Niente «pull_request»: in Gitea una richiesta di unione mostra lo stato del suo ultimo commit, che il push del ramo
# ha già verificato; pull_request rifarebbe tutto sullo stesso commit (refs/pull/N/head) sull'unico runner.
# Runner: act_runner con l'etichetta ubuntu-latest, un lavoro alla volta. I lavori parlano con il demone Docker del
# server, lo stesso di Encelado, Mimante e degli altri progetti: niente montaggi della cartella del lavoro in altri
# contenitori (sul server i percorsi sono diversi); le immagini passano come archivi e contesti di costruzione.
# Che cosa di Gitea 28 si usa e perché: docs/decisioni.md (20 ottobre e 18 novembre 2026) e docs/processo.md.
name: verifica
on:
@@ -44,10 +44,10 @@ on:
permissions:
contents: read
# On a branch the last push counts: the earlier run is cancelled. On main every commit has its own group, so every
# merge runs to the end and publishes its :sha-. The event is part of the group: a run by hand never cancels the one
# of a push, which is the only one that writes the commit statuses required to merge (a cancelled job leaves the
# «failure» status, and workflow_dispatch writes none).
# Su un ramo conta l'ultimo push: l'esecuzione precedente si annulla. Su main ogni commit ha il suo gruppo, così ogni
# unione arriva fino in fondo e pubblica la sua :sha-. L'evento fa parte del gruppo: un'esecuzione a mano non annulla
# mai quella di un push, che è l'unica a scrivere gli stati del commit richiesti per unire (un lavoro annullato lascia
# lo stato «failure», e workflow_dispatch non ne scrive).
concurrency:
group: verifica-${{ gitea.event_name }}-${{ gitea.ref }}${{ gitea.ref == 'refs/heads/main' && format('-{0}', gitea.sha) || '' }}
cancel-in-progress: ${{ gitea.ref != 'refs/heads/main' }}
@@ -68,9 +68,9 @@ jobs:
env:
NUMERO: ${{ gitea.run_number }}
steps:
# The commit's sources with git and the job token, which is valid only while the job runs and does not stay in
# the repository configuration. Here the whole history (PROFONDITA 0): gitleaks reads every commit the verified
# one descends from. The same step, letter for letter, opens every job (PipelineTests checks it).
# I sorgenti del commit con git e il gettone del lavoro, che vale solo finché il lavoro gira e non resta nella
# configurazione del repository. Qui tutta la storia (PROFONDITA 0): gitleaks legge ogni commit da cui discende
# quello verificato. Lo stesso passo, lettera per lettera, apre ogni lavoro (lo controlla PipelineTests).
- name: Sorgenti
env:
TOKEN: ${{ gitea.token }}
@@ -112,9 +112,9 @@ jobs:
needs: controlli
runs-on: ubuntu-latest
timeout-minutes: 60
# Debian 13, nothing else: the distribution's real Chromium, as in the Febe image (on Ubuntu it is a snap). Without
# actions Node is not needed: git and curl before the sources, the rest from ambiente-prove.sh, the SDK from
# dotnet.sh. Shared memory larger than the default 64 MB: the interface tests use a Chromium without a window.
# Debian 13, nient'altro: Chromium vero della distribuzione, come nell'immagine di Febe (su Ubuntu è uno snap). Senza
# azioni non serve Node: git e curl prima dei sorgenti, il resto da ambiente-prove.sh, l'SDK da dotnet.sh.
# Memoria condivisa più ampia dei 64 MB predefiniti: le prove dell'interfaccia usano un Chromium senza finestra.
container:
image: debian:trixie
options: --shm-size=1g
@@ -151,7 +151,7 @@ jobs:
git checkout -q --force --detach "$GITHUB_SHA"
git log -1 --format='Commit %h: %s'
# Before everything else, so that a wrong seed asked by hand stops the job at once.
# Prima di tutto il resto, così un seme chiesto a mano e sbagliato ferma subito il lavoro.
- name: Semi del mondo sintetico
id: semi
run: |
@@ -209,8 +209,8 @@ jobs:
timeout-minutes: 30
env:
NUMERO: ${{ gitea.run_number }}
# This job runs on the runner image, which does not guarantee ICU: publishing and packaging do not need it, so
# .NET goes into invariant globalization instead of stopping («Couldn't find a valid ICU package»).
# Questo lavoro gira sull'immagine del runner, che non garantisce ICU: pubblicare e impacchettare non ne hanno
# bisogno, quindi .NET va in globalizzazione invariante invece di fermarsi («Couldn't find a valid ICU package»).
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: "true"
steps:
- name: Sorgenti
@@ -254,8 +254,8 @@ jobs:
((${#artefatti[@]} == 2)) || { echo "Servono il programma di installazione e lo zip portabile, non: ${artefatti[*]:-niente}." >&2; exit 1; }
bash .gitea/scripts/artefatti.sh verifica "${artefatti[@]}"
# After the installer, not only after the tests: :main and :sha- come only from a commit with the whole verification
# green. On the only runner the jobs go one at a time anyway, so the duration does not change.
# Dopo l'installatore, non solo dopo le prove: :main e :sha- escono solo da un commit con tutta la verifica verde.
# Sull'unico runner i lavori vanno comunque uno alla volta, quindi la durata non cambia.
immagine:
needs: [prove, installatore]
runs-on: ubuntu-latest
@@ -288,13 +288,14 @@ jobs:
git checkout -q --force --detach "$GITHUB_SHA"
git log -1 --format='Commit %h: %s'
# What an interrupted run (cancelled, timed out) could not remove, and an earlier attempt of this same run.
# Ciò che un'esecuzione interrotta (annullata, scaduta) non ha potuto togliere, e un tentativo precedente di
# questa stessa esecuzione.
- name: Resti di esecuzioni interrotte
run: |
bash .gitea/scripts/pulizia-docker.sh residui 90
bash .gitea/scripts/pulizia-docker.sh esecuzione "$ESECUZIONE"
# Registry: the REGISTRY variable of the Actions, if set, otherwise the host of the server address (ROOT_URL).
# Registro: la variabile REGISTRY delle Actions, se c'è, altrimenti l'host dell'indirizzo del server (ROOT_URL).
- name: Versione, registro e nomi
env:
REGISTRO_SCELTO: ${{ vars.REGISTRY }}
@@ -314,7 +315,7 @@ jobs:
} >> "$GITHUB_ENV"
echo "Immagine $V-ci.$NUMERO del commit ${GITHUB_SHA::12}, provata come $PROVA; registro $REGISTRY/$OWNER/febe"
# A buildx builder of this run (with its cache), which knows that the home registry answers in HTTP.
# Un builder buildx di questa esecuzione (con la sua cache), che sa che il registro di casa risponde in HTTP.
- name: Builder buildx dell'esecuzione
run: bash .gitea/scripts/costruisci-immagine.sh builder "$REGISTRY"
@@ -363,13 +364,13 @@ jobs:
REGISTRO_UTENTE: ${{ gitea.actor }}
GITEA_TOKEN: ${{ gitea.token }}
run: |
# costruisci-immagine.sh pubblica puts the credentials in a client configuration of its own, removed at the
# end: buildx passes them to the builder, the daemon is not involved (and would try HTTPS). Never printed.
# Le credenziali le mette costruisci-immagine.sh pubblica in una configurazione del client solo sua, tolta
# alla fine: buildx le passa al builder, il demone non c'entra (e proverebbe HTTPS). Non si stampano mai.
NOMI=("$IMAGE:sha-${GITHUB_SHA::7}")
# :main only if main is still at this commit: a run that arrives late does not move it back.
# The job token only in git's environment, as for the sources. The step runs with «bash -e -o
# pipefail»: without «|| CIMA=""» an ls-remote error would end the step before the warning, and not even
# the :sha- would come out.
# :main solo se main è ancora a questo commit: un'esecuzione arrivata in ritardo non lo riporta indietro.
# Il gettone del lavoro solo nell'ambiente di git, come per i sorgenti. Il passo gira con «bash -e -o
# pipefail»: senza «|| CIMA=""» un errore di ls-remote chiuderebbe il passo prima dell'avviso, e non
# uscirebbe nemmeno la :sha-.
INTESTAZIONE="Authorization: basic $(printf 'x-access-token:%s' "$GITEA_TOKEN" | base64 -w0)"
CIMA=$(GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=http.extraHeader GIT_CONFIG_VALUE_0="$INTESTAZIONE" \
git ls-remote origin refs/heads/main 2> /dev/null | cut -f1) || CIMA=""
@@ -385,10 +386,10 @@ jobs:
- name: Pulizia (sempre)
if: always()
run: |
# The client configuration with the credentials, if an interruption skipped the trap of whoever wrote it.
# La configurazione del client con le credenziali, se un'interruzione ha saltato la trap di chi l'ha scritta.
rm -rf "${RUNNER_TEMP:-/tmp}/febe-docker-$ESECUZIONE"
if [ -n "${ARCHIVIO:-}" ]; then rm -f "$ARCHIVIO"; fi
bash .gitea/scripts/pulizia-docker.sh esecuzione "$ESECUZIONE"
# Then, for all the daemon's projects, what nobody uses: unnamed images and dangling build cache unused for
# 24 hours. It never fails the job.
# Poi, per tutti i progetti del demone, ciò che nessuno usa: immagini senza nome e cache di costruzione
# penzolante non usata da 24 ore. Non fa mai fallire il lavoro.
bash .gitea/scripts/pulizia-docker.sh penzolanti || echo "::warning::La pulizia di ciò che nessuno usa non è riuscita."
+24 -25
View File
@@ -1,24 +1,24 @@
#!/bin/sh
# Febe: container start (specification §11).
# Febe: avvio del contenitore (specifica §11).
#
# It does only three things and then hands over to the server:
# 1. creates, if missing, the group PGID and the user PUID (on Unraid 99 and 100, «nobody:users»);
# 2. makes /dati owned by that user (the first time, or if PUID/PGID changed) and has it prepare /dati/home;
# 3. execs the server with setpriv, as that user: the server starts and watches Xvfb and Chromium by itself.
# Always exec, never a child process: the server takes the place of this script as process 1 of the container
# (no tini), receives SIGTERM from «docker stop» and, with the .NET runtime, reaps the orphaned processes.
# No watch loop here: that is the job of Febe.Server (no shell script acting as a supervisor).
# /libreria is never changed recursively (it holds Alberto's photos); /importa is read only and is not touched;
# of /esporta (the external copies, specification §4.10) only the root is assigned, never recursively, and only if
# the external copies are declared (FEBE_ESPORTA=1 or --esporta).
# If /dati cannot be fixed (network disk, permissions) it starts anyway: Febe explains the problem on its page,
# instead of a container that restarts without saying why.
# Fa solo tre cose e poi cede il posto al server:
# 1. crea, se mancano, il gruppo PGID e l'utente PUID (su Unraid 99 e 100, «nobody:users»);
# 2. rende /dati di quell'utente (la prima volta, o se PUID/PGID sono cambiati) e gli fa preparare /dati/home;
# 3. exec del server con setpriv, come quell'utente: il server avvia e sorveglia da sé Xvfb e Chromium.
# Sempre exec, mai un processo figlio: il server prende il posto di questo script come processo 1 del contenitore
# (niente tini), riceve SIGTERM da «docker stop» e, con il runtime .NET, raccoglie i processi rimasti orfani.
# Nessun ciclo di sorveglianza qui: è il lavoro di Febe.Server (niente script di shell che facciano da supervisore).
# /libreria non si cambia mai ricorsivamente (sono le foto di Alberto); /importa è in sola lettura e non si tocca;
# di /esporta (le copie esterne, specifica §4.10) si assegna solo la radice, mai ricorsivamente, e solo se le copie
# esterne sono dichiarate (FEBE_ESPORTA=1 o --esporta).
# Se /dati non si può sistemare (disco di rete, permessi) si parte lo stesso: è Febe a spiegare il problema nella sua
# pagina, invece di un contenitore che si riavvia senza dire perché.
set -eu
PUID="${PUID:-99}"
PGID="${PGID:-100}"
# Already started as a normal user (docker run --user ...): nothing to change.
# Già avviato come utente normale (docker run --user ...): niente da cambiare.
if [ "$(id -u)" != "0" ]; then
exec "$@"
fi
@@ -36,13 +36,13 @@ if ! getent passwd "${PUID}" >/dev/null 2>&1; then
useradd -o -u "${PUID}" -g "${PGID}" -M -d /dati/home -s /usr/sbin/nologin febe
fi
# /dati belongs to the PUID user, who can put anything in it, even symbolic links to files of the container: as root
# nothing is written in there. The only thing done as root is the change of owner, recursive and without following
# links (-R without -H/-L: it changes the link, never what it points to). The rest is done by the user itself.
# /dati è dell'utente PUID, che dentro può mettere di tutto, anche collegamenti simbolici verso file del contenitore:
# da root qui dentro non si scrive niente. L'unica cosa fatta da root è il cambio di proprietario, ricorsivo e senza
# seguire i collegamenti (-R senza -H/-L: cambia il collegamento, mai ciò a cui punta). Il resto lo fa l'utente stesso.
if mkdir -p /dati 2>/dev/null; then
da_assegnare=""
[ "$(stat -c '%u:%g' /dati)" = "${PUID}:${PGID}" ] || da_assegnare=1
# A /dati/home with another owner (an earlier start as root): only a real folder counts.
# Una /dati/home di un altro proprietario (un avvio precedente come root): conta solo una cartella vera.
if [ -d /dati/home ] && [ ! -L /dati/home ] && [ "$(stat -c '%u:%g' /dati/home)" != "${PUID}:${PGID}" ]; then
da_assegnare=1
fi
@@ -51,23 +51,22 @@ if mkdir -p /dati 2>/dev/null; then
chown -R "${PUID}:${PGID}" /dati 2>/dev/null || echo "Febe: non riesco ad assegnare /dati a ${PUID}:${PGID}." >&2
fi
chmod 0750 /dati 2>/dev/null || true
# Chromium's HOME is created and locked by the user, with its own permissions.
# La HOME di Chromium la crea e la chiude l'utente, con i suoi permessi.
setpriv --reuid="${PUID}" --regid="${PGID}" --init-groups sh -c 'mkdir -p /dati/home && chmod 0700 /dati/home' 2>/dev/null || true
# The seccomp profile no longer lives in /dati: Docker reads it on the server when the container is created, and in
# /dati the container's user could loosen it. It is kept outside the data volume (docs/docker.md, «Sandbox»).
# Il profilo seccomp non sta più in /dati: Docker lo legge sul server alla creazione del contenitore, e in /dati
# l'utente del contenitore potrebbe allentarlo. Si tiene fuori dal volume dei dati (docs/docker.md, «Sandbox»).
if [ -e /dati/seccomp.json ] || [ -L /dati/seccomp.json ]; then
echo "Febe: /dati/seccomp.json non si aggiorna più. Se --security-opt seccomp= indica quel file, sposta il profilo fuori dalla cartella dei dati (su Unraid /mnt/user/appdata/febe-seccomp.json): vedi docs/docker.md, «Sandbox»." >&2
fi
fi
# A library folder just created by Docker belongs to root: only that folder, without recursion.
# Una cartella della libreria appena creata da Docker appartiene a root: solo quella, senza ricorsione.
if [ -d /libreria ] && [ "$(stat -c '%u' /libreria)" = "0" ]; then
chown "${PUID}:${PGID}" /libreria 2>/dev/null || true
fi
# /esporta: only the root, never recursive, and only if the external copies are declared (SPECIFICA §4.10). Inside
# there are Alberto's files copied by Febe or put there by him: they are never changed. Febe does not create /esporta
# if it is missing.
# /esporta: solo la radice, mai ricorsivo, e solo se le copie esterne sono dichiarate (SPECIFICA §4.10). Dentro ci
# sono file di Alberto copiati da Febe o messi da lui: non si cambiano mai. Febe non crea /esporta se manca.
case "${FEBE_ESPORTA:-}" in 1|true|sì|si|yes) esporta=1 ;; *) esporta= ;; esac
case " $* " in *" --esporta "*) esporta=1 ;; esac
if [ -n "$esporta" ] && [ -d /esporta ] && [ "$(stat -c '%u' /esporta)" = "0" ]; then
-1
View File
@@ -657,4 +657,3 @@ Ogni scelta tecnica presa strada facendo, con data e motivo (specifica §15).
| 2026-11-28 | Seconda revisione della tappa E3, conversione della libreria: il lavoro ricorda il file che l'ha messo in pausa per spazio e quanto serve al suo convertito (riga, SHA-256 dell'originale, byte), e finché il disco non ha posto anche per quello la pausa vale prima di rileggere l'originale (hash, decodifica, rimuxaggio). Non si sottraggono i byte dell'originale in anticipo: un PNG grande che diventa un JPG piccolo resterebbe fermo senza motivo. Il ricordo è del processo: dopo un riavvio l'originale si rilegge una volta. | La pausa per spazio (D17) non deve rileggere lo stesso video di 2 GB a ogni risveglio quando lo spazio libero sta fra la soglia e la soglia più il file. |
| 2026-11-28 | Seconda revisione della tappa E3: un cambio dei formati della libreria si salva in una transazione sola con le chiavi «dal» e la coda svuotata del formato sostituito (`LibraryConversionQueue.SaveSettingsAsync`, `IMediaConversionStore.SaveSettingsAndDeleteQueuesAsync`); «Anche i N» dopo il salvataggio non dipende più dalla richiesta (`CancellationToken.None`). Il gancio della libreria legge formati e chiavi «dal» con una lettura sola. | Una scheda chiusa, un arresto o un file salvato in quel momento non devono vedere il formato nuovo senza la sua chiave «dal» (che metterebbe in coda tutto l'elemento) né lasciare «Non riuscito» del formato vecchio che «Riprova» non tocca più. |
| 2026-11-28 | Seconda revisione della tappa E3, fotogrammi: i tempi di `WriteStall` dello zip passano da un `TimeProvider` della BCL (`FrameService.StallTime`, di serie quello di sistema); la prova del lettore lento usa un `TimeProvider` scritto nella prova che avanza solo quando il collegamento finto manda un pezzo. | La prova dipendeva da orologi veri con 250 ms di margine e poteva cadere su un esecutore carico della CI; ora non dipende dal carico. Nessun pacchetto esterno. |
| 2026-11-29 | Commenti in inglese anche negli script di shell di `.gitea/scripts/` e `installer/`, nei blocchi `run:` dei flussi di `.gitea/workflows/` e in `docker/entrypoint.sh`; restano in italiano i messaggi che una persona legge (`echo`, `::warning::`/`::error::`, nomi dei passi, note della release, istruzioni d'uso), come nel resto del codice. Decisione di Alberto (#43) | La regola «codice e commenti in inglese; interfaccia, documenti e messaggi in italiano» vale per tutto il repository, script compresi: nessuna eccezione per la CI |
+5 -1
View File
@@ -735,7 +735,9 @@ protezione di `main` sono in `docs/processo.md`.
8. Da decidere:
- dopo ogni esecuzione la cache di costruzione si toglie solo se nessuno la usa da 24 ore (`--filter until=24h`).
Senza filtro, a ogni push se ne andrebbe anche quella appena usata dagli altri progetti; per cambiare basta togliere
il filtro in `pulizia-docker.sh penzolanti`.
il filtro in `pulizia-docker.sh penzolanti`;
- gli script di shell di `.gitea/` e `installer/` hanno i commenti in italiano, contro «codice e commenti in
inglese»: o un'eccezione in `docs/decisioni.md`, o una traduzione in un ramo a parte.
## Rilievi aperti (20 ottobre)
@@ -768,6 +770,8 @@ protezione di `main` sono in `docs/processo.md`.
## Rilievi aperti (21 ottobre)
- Le note della release scritte da `rilascio.yml` senza immagine dicono «`:latest` resta sulla versione precedente», ma
sul registro un'immagine precedente non c'è mai stata. Da riformulare per il caso della prima pubblicazione.
- Un solo timeout di `OpenAsync` all'apertura di `/browser` (`AfterHoFinitoLeavingTheBrowserPageChangesNothingMore`) in
migliaia di esecuzioni delle prove d'interfaccia, senza causa trovata. Se ricompare nella CI, va fatto dire a
`OpenAsync` quale condizione mancava.
+11 -11
View File
@@ -1,16 +1,16 @@
#!/usr/bin/env bash
# Febe for Windows: publishes Febe.exe as a single file and makes the installer and the portable zip from it.
# Febe per Windows: pubblica Febe.exe in un file solo e ne fa il programma di installazione e lo zip portabile.
#
# installer/costruisci.sh [versione]
#
# Runs on Linux (CI and release) as on Windows with bash: only the .NET SDK 10 is needed. No other program: the
# installer is our own (src/Febe.Installer) and the same project, built for the system that builds it, makes the
# package, checks it and writes the zip. The version, if not given, is the one in Directory.Build.props (the tag must
# match).
# Result in out/:
# Febe-Setup-<versione>.exe per-user installation, without administrator rights
# Febe-<versione>-portabile.zip Febe.exe and LEGGIMI.txt, to copy wherever you like
# Each must stay under 100 MB (the Gitea attachment limit).
# Gira su Linux (CI e rilascio) come su Windows con bash: serve solo il .NET SDK 10. Nessun altro programma: il
# programma di installazione è nostro (src/Febe.Installer) e lo stesso progetto, compilato per il sistema che lo
# costruisce, fa il pacchetto, lo controlla e scrive lo zip. La versione, se non la si passa, è quella di
# Directory.Build.props (il tag deve coincidere).
# Risultato in out/:
# Febe-Setup-<versione>.exe installazione per l'utente, senza permessi di amministratore
# Febe-<versione>-portabile.zip Febe.exe e LEGGIMI.txt, da copiare dove si vuole
# Ognuno deve restare sotto i 100 MB (limite degli allegati di Gitea).
set -euo pipefail
radice="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -36,7 +36,7 @@ dotnet publish src/Febe.Desktop/Febe.Desktop.csproj -c Release -r win-x64 --self
-p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true \
-p:Version="$versione" -nologo -o "$pubblicazione"
# A single file: nothing next to the executable.
# Un file solo: niente accanto all'eseguibile.
solo_un_file() {
local cartella="$1" nome="$2" altri
altri="$(find "$cartella" -mindepth 1 ! -name "$nome")"
@@ -49,7 +49,7 @@ solo_un_file() {
solo_un_file "$pubblicazione" Febe.exe
echo "== Programma di installazione (win-x64, un file solo, ridotto)"
# The publish properties (self-contained, single file, trimming, compression) are in the project.
# Le proprietà della pubblicazione (autosufficiente, un file solo, trimming, compressione) sono nel progetto.
dotnet publish src/Febe.Installer/Febe.Installer.csproj -c Release -r win-x64 \
-p:Version="$versione" -nologo -o "$installatore"
solo_un_file "$installatore" Febe.Installer.exe
+76 -6
View File
@@ -189,6 +189,17 @@ public sealed class BrowserConnectionService : IConnectionService, IAsyncDisposa
/// </summary>
public TimeSpan PageTurnWait { get; set; } = TimeSpan.FromSeconds(15);
/// <summary>
/// How long Alberto's first navigation waits, at most, for the browser to say which page it shows when it does not
/// answer (real time): right after «Scollega» it has just restarted with an empty profile and may not answer yet.
/// After it the page counts as the rest page, and the start page opens (issue #67, decision of 29 November 2026):
/// never a white window (issue #52). Read at every wait; tests shorten it.
/// </summary>
public TimeSpan AddressWait { get; set; } = TimeSpan.FromSeconds(10);
/// <summary>How often the wait of <see cref="AddressWait"/> asks the browser again.</summary>
private static readonly TimeSpan AddressPoll = TimeSpan.FromMilliseconds(200);
/// <summary>The engine, once it exists (it is built after the browser).</summary>
public void AttachEngine(EngineHost engine) => _engine = engine ?? throw new ArgumentNullException(nameof(engine));
@@ -1083,14 +1094,23 @@ public sealed class BrowserConnectionService : IConnectionService, IAsyncDisposa
/// <summary>
/// Alberto's own first navigation (rule 7: not an engine action, no Governor), under his lease: the login page when
/// asked for, and the start page when the browser rests on the empty page (issue #52). Any other page stays as it is
/// — the one he was using, or the verification page of a stop.
/// — the one he was using, or the verification page of a stop. A browser that does not say its page is waited for,
/// up to <see cref="AddressWait"/>; still silent, its page counts as the rest page (issue #67).
/// </summary>
private async Task OpenForAlbertoAsync(bool openLogin, CancellationToken ct)
{
if (!openLogin && !IsRest(await FullUrlAsync(ct).ConfigureAwait(false)))
// A known address that is not the rest page is a page Alberto uses: never touched. An unknown one (the browser
// still silent after the wait) is the rest page.
var answered = true;
if (!openLogin)
{
_log.Info("collegamento", "Alberto usa il browser.");
return;
var first = await AwaitFullUrlAsync(ct).ConfigureAwait(false);
answered = first is not null;
if (answered && !IsRest(first))
{
_log.Info("collegamento", "Alberto usa il browser.");
return;
}
}
// The engine ends its session when the lease starts; wait for it before taking the page. A search step in
@@ -1104,7 +1124,7 @@ public sealed class BrowserConnectionService : IConnectionService, IAsyncDisposa
target = _loginUrl;
what = "pagina di accesso";
}
else if (IsRest(await FullUrlAsync(ct).ConfigureAwait(false)))
else if (await IsAtRestAsync(wait: answered, ct).ConfigureAwait(false))
{
target = StartPageUrl;
what = target == _loginUrl ? "era a riposo, pagina di accesso" : "era a riposo, pagina iniziale del sito";
@@ -1116,7 +1136,19 @@ public sealed class BrowserConnectionService : IConnectionService, IAsyncDisposa
return;
}
var result = await _browser.Cdp.NavigateAsync(target, ct).ConfigureAwait(false);
// A browser still silent (restarting after «Scollega», issue #67) usually refuses the navigation too: the window
// comes to the front all the same, as when its page was unknown before, never an internal error.
NavigationResult result;
try
{
result = await _browser.Cdp.NavigateAsync(target, ct).ConfigureAwait(false);
}
catch (Exception ex) when (ex is CdpDisconnectedException or BrowserUnavailableException or CdpCommandException or TimeoutException)
{
_log.Info("collegamento", $"Alberto usa il browser: {what} non aperta (il browser non risponde).");
return;
}
_log.Info("collegamento", result.Succeeded
? $"Alberto usa il browser: {what} aperta."
: $"Alberto usa il browser: {what} non aperta (errore di rete del browser).");
@@ -1267,6 +1299,44 @@ public sealed class BrowserConnectionService : IConnectionService, IAsyncDisposa
}
}
/// <summary>
/// The address of the main frame as <see cref="FullUrlAsync"/> gives it, but a browser that does not answer is asked
/// again every <see cref="AddressPoll"/> until it does, for at most <see cref="AddressWait"/> (real time, issue #67);
/// null when it stayed silent. Cancelled with <paramref name="ct"/>.
/// </summary>
private async Task<string?> AwaitFullUrlAsync(CancellationToken ct)
{
using var limit = CancellationTokenSource.CreateLinkedTokenSource(ct);
limit.CancelAfter(AddressWait);
try
{
while (true)
{
if (await FullUrlAsync(limit.Token).ConfigureAwait(false) is { } url)
{
return url;
}
await _clock.Delay(AddressPoll, limit.Token).ConfigureAwait(false);
}
}
catch (OperationCanceledException) when (!ct.IsCancellationRequested)
{
_log.Info("collegamento", "Il browser non ha indicato la pagina in tempo: la pagina conta come quella di riposo.");
return null;
}
}
/// <summary>
/// After the engine's session ended: whether the page is the rest page (or still unknown). A browser that already let
/// <see cref="AddressWait"/> pass is asked once more (<paramref name="wait"/> false), not waited for again.
/// </summary>
private async Task<bool> IsAtRestAsync(bool wait, CancellationToken ct)
{
var url = wait ? await AwaitFullUrlAsync(ct).ConfigureAwait(false) : await FullUrlAsync(ct).ConfigureAwait(false);
return url is null || IsRest(url);
}
private async Task WaitForSessionEndAsync(CancellationToken ct)
{
if (_engine is not { } engine)
@@ -54,6 +54,128 @@ public sealed class BrowserStartPageTests
Assert.IsTrue(status.GetProperty("userIsDriving").GetBoolean());
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task ABrowserThatDoesNotAnswerYetIsWaitedForAndThenOpensTheLogin()
{
var ct = TestContext.CancellationToken;
await using var bed = await DesktopTestBed.StartAsync();
await bed.App.Running.WaitAsync(TimeSpan.FromSeconds(20), ct);
var browser = bed.Browser!;
// Just restarted (after «Scollega», issue #67): the browser does not say its page yet. Febe asks again and waits.
browser.FakeCdp.Silent = true;
var asked = browser.FakeCdp.SilentAnswers;
var begin = BeginAsync(bed, openLogin: false);
await DesktopTestBed.WaitUntilAsync(() => browser.FakeCdp.SilentAnswers >= asked + 3, TimeSpan.FromSeconds(5), "le domande ripetute al browser che non risponde");
Assert.IsFalse(begin.IsCompleted, "still waiting for the browser");
Assert.DoesNotContain(Login, browser.FakeCdp.Visited);
// It answers, on the empty rest page: the login page, never a white window (issue #52).
browser.FakeCdp.Silent = false;
await begin.WaitAsync(TimeSpan.FromSeconds(10), ct);
Assert.AreEqual(Login, browser.FakeCdp.Url);
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task ABrowserSilentBeyondTheWaitCountsAsAtRestAndOpensTheLogin()
{
var ct = TestContext.CancellationToken;
await using var bed = await DesktopTestBed.StartAsync();
await bed.App.Running.WaitAsync(TimeSpan.FromSeconds(20), ct);
var browser = bed.Browser!;
var connection = bed.App.Connection!;
connection.AddressWait = TimeSpan.FromMilliseconds(400);
browser.FakeCdp.Silent = true;
var watch = System.Diagnostics.Stopwatch.StartNew();
await BeginAsync(bed, openLogin: false);
watch.Stop();
Assert.IsGreaterThanOrEqualTo(TimeSpan.FromMilliseconds(350), watch.Elapsed, "it waited for the browser first");
Assert.AreEqual(Login, browser.FakeCdp.Url, "still silent: the rest page, and the login opens");
Assert.AreEqual(1, browser.FakeCdp.Visited.Count(v => v == Login));
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task ABrowserThatAnswersLateWithAPageOfAlbertosLeavesItAlone()
{
var ct = TestContext.CancellationToken;
await using var bed = await DesktopTestBed.StartAsync();
await bed.App.Running.WaitAsync(TimeSpan.FromSeconds(20), ct);
var browser = bed.Browser!;
await BeginAsync(bed, openLogin: false);
browser.FakeCdp.Navigated("https://www.instagram.com/marta.prova/");
var navigations = Navigations(browser);
browser.FakeCdp.Silent = true;
var asked = browser.FakeCdp.SilentAnswers;
var begin = BeginAsync(bed, openLogin: false);
await DesktopTestBed.WaitUntilAsync(() => browser.FakeCdp.SilentAnswers >= asked + 2, TimeSpan.FromSeconds(5), "le domande ripetute al browser che non risponde");
browser.FakeCdp.Silent = false;
await begin.WaitAsync(TimeSpan.FromSeconds(10), ct);
Assert.AreEqual("https://www.instagram.com/marta.prova/", browser.FakeCdp.Url);
Assert.AreEqual(navigations, Navigations(browser), "no navigation of his page");
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task TheWaitForASilentBrowserEndsWithTheRequest()
{
var ct = TestContext.CancellationToken;
await using var bed = await DesktopTestBed.StartAsync();
await bed.App.Running.WaitAsync(TimeSpan.FromSeconds(20), ct);
var browser = bed.Browser!;
var connection = bed.App.Connection!;
var navigations = Navigations(browser);
browser.FakeCdp.Silent = true;
var asked = browser.FakeCdp.SilentAnswers;
using var request = new CancellationTokenSource();
var begin = connection.BeginUserDrivingAsync(openLogin: false, request.Token);
await DesktopTestBed.WaitUntilAsync(() => browser.FakeCdp.SilentAnswers >= asked + 2, TimeSpan.FromSeconds(5), "le domande ripetute al browser che non risponde");
await request.CancelAsync();
await Assert.ThrowsAsync<OperationCanceledException>(() => begin.WaitAsync(TimeSpan.FromSeconds(10), ct));
Assert.AreEqual(navigations, Navigations(browser), "nothing opened after the request went away");
Assert.AreEqual("about:blank", browser.FakeCdp.Url);
// The commands of the connection are free again: the next request, with the browser answering, opens the login.
browser.FakeCdp.Silent = false;
await BeginAsync(bed, openLogin: false);
Assert.AreEqual(Login, browser.FakeCdp.Url);
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task ABrowserThatAnswersNothingStillComesToTheFrontWithoutAnError()
{
var ct = TestContext.CancellationToken;
await using var bed = await DesktopTestBed.StartAsync();
await bed.App.Running.WaitAsync(TimeSpan.FromSeconds(20), ct);
var browser = bed.Browser!;
bed.App.Connection!.AddressWait = TimeSpan.FromMilliseconds(300);
// Still restarting (issue #67): no page and no navigation either. The window comes all the same, never a 500.
browser.FakeCdp.Silent = true;
browser.FakeCdp.RefusesNavigation = true;
var shown = browser.Shown;
await BeginAsync(bed, openLogin: false);
Assert.AreEqual(shown + 1, browser.Shown, "«Usa il browser»: the window came to the front");
var result = await bed.JsonAsync(HttpMethod.Post, "/api/browser/show");
StringAssert.Contains(result.GetProperty("message").GetString(), "primo piano");
Assert.AreEqual(shown + 2, browser.Shown, "«Apri il browser»: the window came to the front");
Assert.AreEqual("about:blank", browser.FakeCdp.Url, "nothing could open");
Assert.DoesNotContain(Login, browser.FakeCdp.Visited);
browser.FakeCdp.Silent = false;
browser.FakeCdp.RefusesNavigation = false;
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task ApriIlBrowserBringsTheWindowWithItsStartPageAndTheLoginAfterADisconnection()
@@ -263,6 +263,9 @@ internal sealed class FakeCdp : ICdpSession
private readonly Dictionary<string, List<Action<JsonElement>>> _handlers = new(StringComparer.Ordinal);
private int _captureReads;
private int _cookieReads;
private bool _silent;
private int _silentAnswers;
private bool _refusesNavigation;
public bool LoggedIn { get; set; }
@@ -313,6 +316,29 @@ internal sealed class FakeCdp : ICdpSession
public string Url { get; private set; } = "about:blank";
/// <summary>
/// While true the page does not say where it is, like a browser that has just restarted and does not answer yet
/// (issue #67): <c>Page.getFrameTree</c> fails as a closed connection, and is counted in <see cref="SilentAnswers"/>.
/// </summary>
public bool Silent
{
get => Volatile.Read(ref _silent);
set => Volatile.Write(ref _silent, value);
}
/// <summary>How many times <c>Page.getFrameTree</c> was asked while <see cref="Silent"/>.</summary>
public int SilentAnswers => Volatile.Read(ref _silentAnswers);
/// <summary>
/// While true <c>Page.navigate</c> fails as a closed connection too, like a browser that has not finished restarting
/// (issue #67): with <see cref="Silent"/>, a browser that answers nothing at all.
/// </summary>
public bool RefusesNavigation
{
get => Volatile.Read(ref _refusesNavigation);
set => Volatile.Write(ref _refusesNavigation, value);
}
public ConcurrentQueue<string> Methods { get; } = new();
/// <summary>Every address a <c>Page.navigate</c> asked for, in order.</summary>
@@ -329,6 +355,17 @@ internal sealed class FakeCdp : ICdpSession
{
CdpCommandPolicy.EnsureAllowed(method);
Methods.Enqueue(method);
if (method == "Page.getFrameTree" && Silent)
{
Interlocked.Increment(ref _silentAnswers);
return Task.FromException<JsonElement>(new CdpDisconnectedException());
}
if (method == "Page.navigate" && RefusesNavigation)
{
return Task.FromException<JsonElement>(new CdpDisconnectedException());
}
JsonNode result = method switch
{
"Page.getFrameTree" => new JsonObject { ["frameTree"] = new JsonObject { ["frame"] = new JsonObject { ["id"] = "F1", ["url"] = Url } } },
@@ -169,10 +169,6 @@ public sealed partial class PackagingTests
StringAssert.Contains(image, "pubblicata: ${{ steps.pubblicazione.outputs.pubblicata }}");
StringAssert.Contains(release, "PUBBLICATA: ${{ needs.immagine.outputs.pubblicata }}");
StringAssert.Contains(release, "non è stata pubblicata");
// The first publication has no earlier image on the registry: the note without an image must not promise one.
var unpublished = release.Split('\n').Single(line => line.Contains("non è stata pubblicata"));
StringAssert.Contains(unpublished, "non aggiorna \\`:latest\\`");
Assert.DoesNotContain("versione precedente", unpublished, "the first publication has no earlier image");
// Without the secret the image is built and tested, and the job still succeeds: the release says so.
var secret = Step(image, "Segreto per il registro");