Files
Chronos/.github/workflows/ci.yml
T
Claude 8a5f4ab512 ci: screenshot diff, installer test and every PostgreSQL authentication method
- Screenshots: a capture that exits with an error or writes nothing fails the job
  (the pictures it wrote are still published); the new "Screenshot diff" step
  compares them with tests/visual/baselines, fails beyond the tolerance, warns
  once for screens without a baseline and uploads the diff images.
- installer (windows-latest): publishes App, Uploader and Setup (self-contained
  single file, no ReadyToRun), packs Titano 1.0.0 (with an extra legacy.txt),
  Titano 1.0.1 and the Uploader installer, and runs
  .github/scripts/installer-test.ps1: argument and not-installed exit codes,
  silent install into a folder with a space, Add/Remove Programs, shortcuts and
  the .titano file type, the installed programs drawing their screens, upgrade in
  place removing legacy.txt, uninstall removing itself, user data kept, the
  Uploader installer; the setup logs are printed whatever happens. The script
  now resolves its paths from the PowerShell location.
- PostgreSQL 16/17: postgres-ci-setup.sh prepares the service container and the
  job exports the MD5, cleartext, trust, TLS and root-certificate variables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
2026-10-12 10:06:20 +00:00

368 lines
15 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
DOTNET_NOLOGO: "1"
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1"
TOOLS: src/Titano.Tools/bin/Release/net10.0/Titano.Tools.dll
jobs:
build:
name: Build and test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: .NET info
run: dotnet --info
- name: Restore fixtures cache
uses: actions/cache@v4
with:
path: tests/fixtures/external
key: fixtures-${{ hashFiles('tests/fixtures/manifest.json') }}
- name: Build (warnings are errors)
run: dotnet build Titano.slnx -c Release
- 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
if: runner.os == 'Windows'
run: dotnet format whitespace Titano.slnx --verify-no-changes
# GitHub silently skips a workflow or issue form that does not parse; the public issue forms ship with releases.
- name: YAML check (workflows, compose, public issue forms)
if: runner.os == 'Linux'
run: ruby .github/scripts/check-yaml.rb .github/workflows/*.yml deploy/docker/docker-compose.yml deploy/releases-repo/.github/ISSUE_TEMPLATE/*.yml
# Missing samples become "RAW fixture missing" warning annotations; the tests that need them skip.
- name: Fetch CC0 fixtures
run: dotnet "$TOOLS" fixtures --allow-missing
- name: Test · Core
run: dotnet run --project tests/Titano.Core.Tests -c Release --no-build -- --junit out/junit/core.xml
- name: Test · Data (SQLite)
run: dotnet run --project tests/Titano.Data.Tests -c Release --no-build -- --junit out/junit/data.xml
- name: Test · Server
run: dotnet run --project tests/Titano.Server.Tests -c Release --no-build -- --junit out/junit/server.xml
- name: Test · Tools
run: dotnet run --project tests/Titano.Tools.Tests -c Release --no-build -- --junit out/junit/tools.xml
- name: Test · Core.Windows
if: runner.os == 'Windows'
run: dotnet run --project tests/Titano.Core.Windows.Tests -c Release --no-build -- --junit out/junit/core-windows.xml
- name: Test · App
if: runner.os == 'Windows'
run: dotnet run --project tests/Titano.App.Tests -c Release --no-build -- --junit out/junit/app.xml
- name: Screenshots
# Also after a failed test step: the pictures are what explains a failing screen test.
if: runner.os == 'Windows' && !cancelled()
timeout-minutes: 10
run: |
set +e
failed=0
for exe in src/Titano.App/bin/Release/net10.0-windows/Titano.exe src/Titano.Uploader/bin/Release/net10.0-windows/Titano.Uploader.exe \
src/Titano.Setup/bin/Release/net10.0-windows/Titano.Setup.exe; do
name=$(basename "$exe" .exe)
before=$(ls out/screenshots/*.png 2>/dev/null | wc -l)
"$exe" --capture out/screenshots 2> "out/capture-$name.log" &
wait $!
code=$?
cat "out/capture-$name.log"
count=$(( $(ls out/screenshots/*.png 2>/dev/null | wc -l) - before ))
echo "$name capture exit code $code, $count screenshot(s)"
# A capture that crashed or wrote nothing fails the job; the pictures it did write are still published.
if [ "$code" -ne 0 ] || [ "$count" -eq 0 ]; then
echo "::error title=Screenshots::$name --capture failed (exit $code, $count screenshot(s))"
failed=1
fi
done
exit $failed
# BRIEF §20.2 visual regression against tests/visual/baselines: a screen beyond the tolerance fails, one without
# a baseline only warns (the baselines README says how to add them).
- name: Screenshot diff
if: runner.os == 'Windows' && !cancelled() && hashFiles('out/screenshots/*.png') != ''
run: dotnet "$TOOLS" screenshots diff out/screenshots --baseline tests/visual/baselines --out out/screenshot-diff
- name: Upload screenshot diffs
if: runner.os == 'Windows' && !cancelled() && hashFiles('out/screenshot-diff/*.png') != ''
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: screenshot-diff
path: out/screenshot-diff/
retention-days: 7
# Handed to the screenshots job through the cache: it does not count against the artifact storage quota.
- name: Keep screenshots for the screenshots job
if: runner.os == 'Windows' && !cancelled() && hashFiles('out/screenshots/*.png') != ''
continue-on-error: true
uses: actions/cache/save@v4
with:
path: out/screenshots
key: screenshots-${{ github.run_id }}-${{ github.run_attempt }}
enableCrossOsArchive: true
- name: Publish desktop programs (win-x64, self-contained single file)
if: runner.os == 'Windows'
run: |
for p in Titano.App Titano.Uploader; do
dotnet publish "src/$p/$p.csproj" -c Release -r win-x64 --self-contained \
-p:PublishSingleFile=true -p:PublishReadyToRun=true -p:IncludeNativeLibrariesForSelfExtract=true \
-o "out/publish/$p"
done
dotnet publish src/Titano.Server/Titano.Server.csproj -c Release -r win-x64 --self-contained \
-p:PublishSingleFile=true -o out/publish/Titano.Server
# Artifacts are conveniences: a full artifact storage quota must not fail a job whose checks passed, and short
# retention keeps the storage from filling up again.
- name: Upload test results
if: always()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}
path: out/junit/
if-no-files-found: ignore
retention-days: 7
- name: Upload Windows programs
if: runner.os == 'Windows'
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: titano-win-x64-${{ github.sha }}
path: out/publish/
retention-days: 3
screenshots:
name: Screenshots branch
# Same-repository pull requests only: forks never get a writable token.
if: ${{ !cancelled() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Absent when the build broke before the capture step: nothing to publish then.
- uses: actions/cache/restore@v4
with:
path: out/screenshots
key: screenshots-${{ github.run_id }}-${{ github.run_attempt }}
enableCrossOsArchive: true
- name: Publish to the ci-screenshots branch (one commit, overwritten each run)
if: hashFiles('out/screenshots/*.png') != ''
working-directory: out/screenshots
run: |
git init -q -b ci-screenshots
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -q -m "Screenshots of ${{ github.event.pull_request.head.sha }}"
git push -q -f "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git" HEAD:refs/heads/ci-screenshots
# BRIEF §18 on a clean runner: the real installers (published programs, TPK1 payload) installed silently, run,
# upgraded in place, uninstalled; .github/scripts/installer-test.ps1 checks every step.
installer:
name: Installer (windows-latest)
runs-on: windows-latest
timeout-minutes: 45
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
# As release.yml publishes them, without ReadyToRun (only start-up time differs).
- name: Publish App, Uploader and Setup (win-x64, self-contained single file)
run: |
foreach ($p in 'Titano.App', 'Titano.Uploader', 'Titano.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" }
}
- name: Build Titano.Tools
run: |
dotnet build src/Titano.Tools/Titano.Tools.csproj -c Release
if ($LASTEXITCODE -ne 0) { throw 'Titano.Tools did not build' }
# Version 1 ships one more file than version 2: the upgrade must remove it.
- name: Pack the installers
run: |
Copy-Item -Recurse out/publish/Titano.App out/app-v1
Set-Content -LiteralPath out/app-v1/legacy.txt -Value 'only in version 1'
$installers = @(
@('--product', 'Titano', '--version', '1.0.0', '--component', 'Titano=out/app-v1',
'--component', 'Uploader=out/publish/Titano.Uploader', '--out', 'out/installers/Titano-Setup-1.0.0.exe'),
@('--product', 'Titano', '--version', '1.0.1', '--component', 'Titano=out/publish/Titano.App',
'--component', 'Uploader=out/publish/Titano.Uploader', '--out', 'out/installers/Titano-Setup-1.0.1.exe'),
@('--product', 'Titano Uploader', '--version', '1.0.1', '--component', 'Uploader=out/publish/Titano.Uploader',
'--out', 'out/installers/Titano-Uploader-Setup-1.0.1.exe'))
foreach ($installer in $installers) {
dotnet $env:TOOLS pack-installer --setup out/publish/Titano.Setup/Titano.Setup.exe @installer
if ($LASTEXITCODE -ne 0) { throw "pack-installer $installer failed" }
}
- name: Install, run, upgrade and remove
run: |
./.github/scripts/installer-test.ps1 -Setup1 out/installers/Titano-Setup-1.0.0.exe -Setup2 out/installers/Titano-Setup-1.0.1.exe `
-UploaderSetup out/installers/Titano-Uploader-Setup-1.0.1.exe -Version1 1.0.0 -Version2 1.0.1 -Screenshots out/installer-screenshots
- name: Setup logs
if: always()
run: |
$logs = Join-Path ([System.IO.Path]::GetTempPath()) 'Titano Setup'
if (-not (Test-Path -LiteralPath $logs)) { Write-Host "No setup log in '$logs'"; exit 0 }
Get-ChildItem -LiteralPath $logs -Filter *.log -File | Sort-Object Name | ForEach-Object {
Write-Host "::group::$($_.Name)"
Get-Content -LiteralPath $_.FullName
Write-Host '::endgroup::'
}
postgres:
name: PostgreSQL ${{ matrix.pg }} integration
strategy:
fail-fast: false
matrix:
pg: ["16", "17"]
runs-on: ubuntu-latest
services:
postgres:
image: postgres:${{ matrix.pg }}
env:
POSTGRES_USER: titano
POSTGRES_PASSWORD: titano-ci
POSTGRES_DB: titano_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U titano -d titano_test"
--health-interval 5s --health-timeout 5s --health-retries 20
env:
TITANO_TEST_PG: Host=127.0.0.1;Port=5432;Database=titano_test;Username=titano;Password=titano-ci;SslMode=disable
# Roles, pg_hba lines and TLS made by postgres-ci-setup.sh: with these set, the wire tests of MD5, cleartext, trust
# and TLS (BRIEF §6.3) run, and a server that refuses TLS fails them instead of skipping them.
TITANO_TEST_PG_MD5: Host=127.0.0.1;Port=5432;Database=titano_test;Username=titano_md5;Password=md5-ci;SslMode=disable
TITANO_TEST_PG_CLEARTEXT: Host=127.0.0.1;Port=5432;Database=titano_test;Username=titano_clear;Password=clear-ci;SslMode=disable
TITANO_TEST_PG_TRUST: Host=127.0.0.1;Port=5432;Database=titano_test;Username=titano_trust;SslMode=disable
TITANO_TEST_PG_TLS: "1"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
# The image starts with TLS off and SCRAM only.
- name: Configure PostgreSQL (MD5, cleartext, trust, TLS)
run: |
bash .github/scripts/postgres-ci-setup.sh "${{ job.services.postgres.id }}" titano titano_test "$RUNNER_TEMP/pg-tls"
echo "TITANO_TEST_PG_ROOT_CERT=$RUNNER_TEMP/pg-tls/server.crt" >> "$GITHUB_ENV"
- name: Test · Data (PostgreSQL)
run: dotnet run --project tests/Titano.Data.Tests -c Release -- --junit out/junit/data-pg${{ matrix.pg }}.xml
- name: Test · Server (PostgreSQL)
run: dotnet run --project tests/Titano.Server.Tests -c Release -- --junit out/junit/server-pg${{ matrix.pg }}.xml
- name: Upload test results
if: always()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: test-results-pg${{ matrix.pg }}
path: out/junit/
if-no-files-found: ignore
retention-days: 7
docker:
name: Docker image
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: titano
POSTGRES_PASSWORD: titano-ci
POSTGRES_DB: titano
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U titano -d titano"
--health-interval 5s --health-timeout 5s --health-retries 20
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build image
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_RECORD_UPLOAD: "false" # no build-record artifact: nothing reads it
with:
context: .
file: deploy/docker/Dockerfile
platforms: linux/amd64
load: true
push: false
tags: titano-server:ci
build-args: TITANO_VERSION=0.0.0-ci
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke test (/health)
run: |
mkdir -p "$RUNNER_TEMP/archive" "$RUNNER_TEMP/data"
docker run -d --name titano --network host \
-e TITANO_DB_HOST=127.0.0.1 -e TITANO_DB_USER=titano -e TITANO_DB_PASSWORD=titano-ci -e TITANO_DB_NAME=titano \
-e TITANO_ADMIN_USER=admin -e TITANO_ADMIN_PASSWORD=ci-password-1234 \
-e PUID="$(id -u)" -e PGID="$(id -g)" \
-v "$RUNNER_TEMP/archive:/archive" -v "$RUNNER_TEMP/data:/data" titano-server:ci
for i in $(seq 1 60); do
if curl -fsS http://127.0.0.1:8080/health; then echo; break; fi
sleep 2
done
curl -fsS http://127.0.0.1:8080/api/v1/server/info
curl -fsSk https://127.0.0.1:8443/health
test "$(docker inspect --format '{{.State.Running}}' titano)" = "true"
- name: Container logs
if: always()
run: docker logs titano || true