Files
Chronos/.gitea/workflows/ci.yml
T
Alby96 20d64af4a4
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
feat: single setup, mass-pass progress, per-server homes, Desktop shares its library (owner review 5, v1.1.0) (#68)
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
2026-11-15 18:11:43 +01:00

333 lines
17 KiB
YAML

name: CI
# Gitea Actions (BRIEF §19.1, amended 2026-10-23, R3). The runner is act_runner in Docker mode on the Linux server
# that also runs Gitea: every job runs in a container, one job at a time. The .NET jobs use the SDK image (kept by the
# host after the first pull) and check out with git, because JavaScript actions need Node.js, which that image lacks;
# nothing is uploaded as an artifact or cached. Builds use BUILD_CPUS cores so the host keeps memory for Gitea.
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
env:
DOTNET_NOLOGO: "1"
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1"
TOOLS: src/Chronos.Tools/bin/Release/net10.0/Chronos.Tools.dll
BUILD_CPUS: "4"
# The runner shares its CPU and disks with the server's other services: timed tests get three times their budget
# (Chronos.Testing TestTiming); the performance gates of perf.yml keep theirs.
CHRONOS_TEST_TIME_FACTOR: "3"
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:10.0
timeout-minutes: 90
defaults:
run:
shell: bash
steps:
- name: Checkout
env:
TOKEN: ${{ github.token }}
run: |
git config --global --add safe.directory "$PWD"
git init -q .
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
git -c http.extraheader="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" fetch -q --depth=1 origin "${{ github.sha }}"
git checkout -q FETCH_HEAD
git log -1 --format='%h %s'
# Chronos.Data binds the system SQLite library (BRIEF §6.2), which the SDK image lacks.
- name: System SQLite
run: apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends libsqlite3-0 > /dev/null
- name: .NET info
run: dotnet --info
# The Windows projects compile here too (EnableWindowsTargeting); their tests need Windows (job windows below).
- name: Build (warnings are errors)
run: dotnet build Chronos.slnx -c Release -m:"$BUILD_CPUS"
- name: Zero-package guard
run: dotnet "$TOOLS" package-guard
- name: Localization check
run: dotnet "$TOOLS" i18n check
- name: XAML lint
run: dotnet "$TOOLS" xaml-lint
- name: Format check
run: dotnet format whitespace Chronos.slnx --verify-no-changes
# Missing samples become "RAW fixture missing" warnings in the log; the tests that need them skip.
- name: Fetch CC0 fixtures
run: dotnet "$TOOLS" fixtures --allow-missing
- name: Test · Core
run: dotnet run --project tests/Chronos.Core.Tests -c Release --no-build -- --junit out/junit/core.xml
- name: Test · Data (SQLite)
run: dotnet run --project tests/Chronos.Data.Tests -c Release --no-build -- --junit out/junit/data.xml
- name: Test · Server
run: dotnet run --project tests/Chronos.Server.Tests -c Release --no-build -- --junit out/junit/server.xml
- name: Test · Tools
run: dotnet run --project tests/Chronos.Tools.Tests -c Release --no-build -- --junit out/junit/tools.xml
# The release cross-compiles the Windows programs on Linux (BRIEF §18, amended 2026-10-23, R3): every push checks
# that they still publish with their icon, version and manifest, and that the installer packs. ReadyToRun is
# left out here (only start-up time differs) to keep the run short.
- name: Windows programs (win-x64, cross-compiled)
run: |
common="-c Release -r win-x64 --self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishReadyToRun=false -m:$BUILD_CPUS"
for p in Chronos.App Chronos.Uploader Chronos.Setup; do
dotnet publish "src/$p/$p.csproj" $common -o "out/publish/$p"
done
dotnet "$TOOLS" pack-installer --setup out/publish/Chronos.Setup/Chronos.Setup.exe --product Chronos \
--component "Chronos=out/publish/Chronos.App" --component "Uploader=out/publish/Chronos.Uploader" \
--version 0.0.0 --out out/installers/Chronos-Setup-ci.exe
dotnet "$TOOLS" pe-check out/publish/Chronos.App/Chronos.exe out/publish/Chronos.Uploader/Chronos.Uploader.exe \
out/publish/Chronos.Setup/Chronos.Setup.exe out/installers/Chronos-Setup-ci.exe
# The wire tests of MD5, cleartext, trust and TLS (BRIEF §6.3) run against a service container that postgres-ci
# prepares through SQL; a server that refuses TLS fails them instead of skipping them.
postgres:
name: PostgreSQL ${{ matrix.pg }} integration
needs: build
strategy:
fail-fast: false
matrix:
pg: ["16", "17"]
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:10.0
timeout-minutes: 45
services:
postgres:
image: postgres:${{ matrix.pg }}
env:
POSTGRES_USER: chronos
POSTGRES_PASSWORD: chronos-ci
POSTGRES_DB: chronos_test
defaults:
run:
shell: bash
env:
CHRONOS_TEST_PG: Host=postgres;Port=5432;Database=chronos_test;Username=chronos;Password=chronos-ci;SslMode=disable
CHRONOS_TEST_PG_MD5: Host=postgres;Port=5432;Database=chronos_test;Username=chronos_md5;Password=md5-ci;SslMode=disable
CHRONOS_TEST_PG_CLEARTEXT: Host=postgres;Port=5432;Database=chronos_test;Username=chronos_clear;Password=clear-ci;SslMode=disable
CHRONOS_TEST_PG_TRUST: Host=postgres;Port=5432;Database=chronos_test;Username=chronos_trust;SslMode=disable
CHRONOS_TEST_PG_TLS: "1"
steps:
- name: Checkout
env:
TOKEN: ${{ github.token }}
run: |
git config --global --add safe.directory "$PWD"
git init -q .
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
git -c http.extraheader="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" fetch -q --depth=1 origin "${{ github.sha }}"
git checkout -q FETCH_HEAD
# Chronos.Data binds the system SQLite library (BRIEF §6.2), which the SDK image lacks.
- name: System SQLite
run: apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends libsqlite3-0 > /dev/null
- name: Configure PostgreSQL (MD5, cleartext, trust, TLS)
run: |
dotnet run --project src/Chronos.Tools -c Release -- postgres-ci --connection "$CHRONOS_TEST_PG" --host postgres --certificates "$RUNNER_TEMP/pg-tls"
echo "CHRONOS_TEST_PG_ROOT_CERT=$RUNNER_TEMP/pg-tls/server.crt" >> "$GITHUB_ENV"
- name: Test · Data (PostgreSQL)
run: dotnet run --project tests/Chronos.Data.Tests -c Release -- --junit out/junit/data-pg${{ matrix.pg }}.xml
- name: Test · Server (PostgreSQL)
run: dotnet run --project tests/Chronos.Server.Tests -c Release -- --junit out/junit/server-pg${{ matrix.pg }}.xml
# The runner's own image has the docker CLI and talks to the host's daemon: the image is built there and runs with
# PostgreSQL 17 on a network of this job, which the job container joins to reach it. Everything the job creates is
# labelled with the job container's id: a cancelled or timed-out job skips its clean-up step, so the next job removes
# what a job that no longer exists left on the host.
docker:
name: Docker image
needs: build
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Remove what cancelled jobs left
run: |
echo "NAME=chronos-ci-$(hostname)" >> "$GITHUB_ENV"
for c in $(docker ps -aq --filter label=chronos-ci.job); do
job="$(docker inspect -f '{{index .Config.Labels "chronos-ci.job"}}' "$c")"
docker inspect "$job" > /dev/null 2>&1 || docker rm -f -v "$c"
done
for n in $(docker network ls -q --filter label=chronos-ci.job); do
job="$(docker network inspect -f '{{index .Labels "chronos-ci.job"}}' "$n")"
docker inspect "$job" > /dev/null 2>&1 || docker network rm "$n"
done
for i in $(docker image ls -q --filter label=chronos-ci.job | sort -u); do
job="$(docker image inspect -f '{{index .Config.Labels "chronos-ci.job"}}' "$i")"
docker inspect "$job" > /dev/null 2>&1 || docker image rm -f "$i"
done
- name: Checkout
env:
TOKEN: ${{ github.token }}
run: |
git config --global --add safe.directory "$PWD"
git init -q .
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
git -c http.extraheader="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" fetch -q --depth=1 origin "${{ github.sha }}"
git checkout -q FETCH_HEAD
- name: Build image
run: |
docker buildx version
docker build -f deploy/docker/Dockerfile --build-arg CHRONOS_VERSION=0.0.0-ci --label chronos-ci.job="$(hostname)" -t "$NAME:image" .
- name: Smoke test (/health)
run: |
docker network create --label chronos-ci.job="$(hostname)" "$NAME"
docker network connect "$NAME" "$(hostname)"
docker run -d --name "$NAME-pg" --network "$NAME" --label chronos-ci.job="$(hostname)" \
-e POSTGRES_USER=chronos -e POSTGRES_PASSWORD=chronos-ci -e POSTGRES_DB=chronos postgres:17
for i in $(seq 1 60); do
if docker exec "$NAME-pg" pg_isready -q -U chronos -d chronos; then break; fi
sleep 2
done
docker run -d --name "$NAME-server" --network "$NAME" --label chronos-ci.job="$(hostname)" \
-e CHRONOS_DB_HOST="$NAME-pg" -e CHRONOS_DB_USER=chronos -e CHRONOS_DB_PASSWORD=chronos-ci -e CHRONOS_DB_NAME=chronos \
-e CHRONOS_ADMIN_USER=admin -e CHRONOS_ADMIN_PASSWORD=ci-password-1234 "$NAME:image"
for i in $(seq 1 60); do
if curl -fsS --max-time 10 "http://$NAME-server:8080/health"; then echo; break; fi
sleep 2
done
curl -fsS --max-time 10 "http://$NAME-server:8080/api/v1/server/info"
echo
curl -fsSk --max-time 10 "https://$NAME-server:8443/health"
echo
test "$(docker inspect --format '{{.State.Running}}' "$NAME-server")" = "true"
- name: Container logs and clean-up
if: always()
run: |
docker logs "$NAME-server" || true
docker rm -f -v "$NAME-server" "$NAME-pg" || true
docker network disconnect "$NAME" "$(hostname)" || true
docker network rm "$NAME" || true
docker image rm "$NAME:image" || true
# Gitea fails a workflow that does not parse and offers no issue form that does not. The sources come as an archive:
# the Ruby image has no git.
yaml:
name: YAML check
runs-on: ubuntu-latest
container:
image: ruby:3.3-alpine
timeout-minutes: 15
steps:
- name: Workflows, compose file and public issue forms
env:
TOKEN: ${{ github.token }}
run: |
wget -q --header "Authorization: token $TOKEN" -O /tmp/sources.tar.gz \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/archive/${{ github.sha }}.tar.gz"
mkdir -p /tmp/sources && tar -xzf /tmp/sources.tar.gz -C /tmp/sources
cd /tmp/sources/*/
ruby .gitea/scripts/check-yaml.rb .gitea/workflows/*.yml .gitea/ISSUE_TEMPLATE/*.yml deploy/docker/docker-compose.yml
# Windows-only tests, screenshots and the installer test (BRIEF §18, §20.2) need a Windows runner: register an
# act_runner on a Windows PC in host mode with a label (for example "windows") and set the repository variable
# WINDOWS_RUNNER to that label. Without it the job is skipped. The PC needs the .NET SDK of global.json, Git for
# Windows in its default folder (C:/Program Files/Git) and PowerShell 7.
windows:
name: Windows tests and installer
needs: build
if: ${{ vars.WINDOWS_RUNNER != '' }}
runs-on: ${{ vars.WINDOWS_RUNNER || 'windows' }}
timeout-minutes: 90
permissions:
contents: read
# act finds a shell on PATH, where Git for Windows puts no bash.exe by default (and WSL's launcher may come
# first): Git Bash by its path, whose wrapper also puts its tools (base64, printf) on PATH.
defaults:
run:
shell: '"C:/Program Files/Git/bin/bash.exe" --noprofile --norc -e -o pipefail {0}'
steps:
- name: Checkout
env:
TOKEN: ${{ github.token }}
run: |
# A host-mode runner keeps its work folder between runs: reuse the clone.
git init -q .
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git" 2>/dev/null ||
git remote set-url origin "${{ github.server_url }}/${{ github.repository }}.git"
git -c http.extraheader="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" fetch -q --depth=1 origin "${{ github.sha }}"
git checkout -q -f FETCH_HEAD
git clean -q -fdx
- name: Build
run: dotnet build Chronos.slnx -c Release
- name: Test · Core.Windows
run: dotnet run --project tests/Chronos.Core.Windows.Tests -c Release --no-build -- --junit out/junit/core-windows.xml
- name: Test · App
run: dotnet run --project tests/Chronos.App.Tests -c Release --no-build -- --junit out/junit/app.xml
- name: Screenshots
if: ${{ !cancelled() }}
timeout-minutes: 10
run: |
rm -rf out/screenshots
for exe in src/Chronos.App/bin/Release/net10.0-windows/Chronos.exe src/Chronos.Uploader/bin/Release/net10.0-windows/Chronos.Uploader.exe \
src/Chronos.Setup/bin/Release/net10.0-windows/Chronos.Setup.exe; do
"$exe" --capture out/screenshots &
wait $! || { echo "::error title=Screenshots::$(basename "$exe") --capture exited with $?"; exit 1; }
done
ls out/screenshots
# BRIEF §20.2 visual regression against tests/visual/baselines, captured on the development PC (its README).
- name: Screenshot diff
if: ${{ !cancelled() }}
run: dotnet src/Chronos.Tools/bin/Release/net10.0/Chronos.Tools.dll screenshots diff out/screenshots --baseline tests/visual/baselines --out out/screenshot-diff
- name: Install, run, upgrade and remove
shell: pwsh
run: |
foreach ($p in 'Chronos.App', 'Chronos.Uploader', 'Chronos.Setup') {
dotnet publish "src/$p/$p.csproj" -c Release -r win-x64 --self-contained -p:PublishSingleFile=true `
-p:IncludeNativeLibrariesForSelfExtract=true -p:PublishReadyToRun=false -o "out/publish/$p"
if ($LASTEXITCODE -ne 0) { throw "dotnet publish $p failed" }
}
Remove-Item -Recurse -Force out/app-v1, out/server-v1, out/installers -ErrorAction SilentlyContinue
Copy-Item -Recurse out/publish/Chronos.App out/app-v1
Set-Content -LiteralPath out/app-v1/legacy.txt -Value 'only in version 1'
# Stands in for Chronos Server 1.0 for Windows, which the single setup no longer ships (a program it retains).
New-Item -ItemType Directory -Force -Path out/server-v1 | Out-Null
Copy-Item -LiteralPath out/publish/Chronos.Uploader/Chronos.Uploader.exe -Destination out/server-v1/Chronos.Server.exe
$tools = 'src/Chronos.Tools/bin/Release/net10.0/Chronos.Tools.dll'
$installers = @(
@('--product', 'Chronos', '--version', '1.0.0', '--component', 'Chronos=out/app-v1',
'--component', 'Uploader=out/publish/Chronos.Uploader', '--out', 'out/installers/Chronos-Setup-1.0.0.exe'),
@('--product', 'Chronos', '--version', '1.0.1', '--component', 'Chronos=out/publish/Chronos.App',
'--component', 'Uploader=out/publish/Chronos.Uploader', '--out', 'out/installers/Chronos-Setup-1.0.1.exe'),
@('--product', 'Chronos Uploader', '--version', '1.0.0', '--component', 'Uploader=out/publish/Chronos.Uploader',
'--out', 'out/installers/Chronos-Uploader-Setup-1.0.0.exe'),
@('--product', 'Chronos', '--version', '1.0.0', '--component', 'Chronos=out/app-v1', '--component', 'Server=out/server-v1', '--legacy',
'--out', 'out/installers/Chronos-Server-Setup-1.0.0.exe'))
foreach ($installer in $installers) {
dotnet $tools pack-installer --setup out/publish/Chronos.Setup/Chronos.Setup.exe @installer
if ($LASTEXITCODE -ne 0) { throw "pack-installer $installer failed" }
}
./.gitea/scripts/installer-test.ps1 -Setup1 out/installers/Chronos-Setup-1.0.0.exe -Setup2 out/installers/Chronos-Setup-1.0.1.exe `
-LegacyUploaderSetup out/installers/Chronos-Uploader-Setup-1.0.0.exe -ServerSetup out/installers/Chronos-Server-Setup-1.0.0.exe `
-Version1 1.0.0 -Version2 1.0.1 -Screenshots out/installer-screenshots