Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
215 lines
6.8 KiB
YAML
215 lines
6.8 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
|
|
|
|
- name: Fetch CC0 fixtures
|
|
continue-on-error: true
|
|
run: |
|
|
if dotnet "$TOOLS" --help | grep -q '^ fixtures'; then dotnet "$TOOLS" fixtures; fi
|
|
|
|
- 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 · 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
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
src/Titano.App/bin/Release/net10.0-windows/Titano.exe --capture out/screenshots &
|
|
wait $!
|
|
ls -la out/screenshots
|
|
|
|
- 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
|
|
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results-${{ matrix.os }}
|
|
path: out/junit/
|
|
if-no-files-found: ignore
|
|
|
|
- name: Upload screenshots
|
|
if: runner.os == 'Windows' && always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: screenshots
|
|
path: out/screenshots/
|
|
if-no-files-found: ignore
|
|
|
|
- name: Upload Windows programs
|
|
if: runner.os == 'Windows'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: titano-win-x64-${{ github.sha }}
|
|
path: out/publish/
|
|
retention-days: 14
|
|
|
|
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
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-dotnet@v4
|
|
with:
|
|
global-json-file: global.json
|
|
- name: Test · Data (PostgreSQL)
|
|
run: dotnet run --project tests/Titano.Data.Tests -c Release -- --junit out/junit/data-pg${{ matrix.pg }}.xml
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-results-pg${{ matrix.pg }}
|
|
path: out/junit/
|
|
if-no-files-found: ignore
|
|
|
|
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
|
|
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
|