feat: bootstrap solution, Docker image and Gitea pipelines (M0)
CI / Build and test (SQLite) (pull_request) Successful in 43s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / YAML check (pull_request) Successful in 15s
CI / Docker image (pull_request) Successful in 59s

Start development with the skeleton every later milestone builds on, so
that code, image and release path exist and are verified from day one.

- Khaemhat.sln with the ten projects of SPEC section 3 and six MSTest
  projects; shared build rules with warnings as errors, analyzers and
  Central Package Management restricted to the allowlist.
- Architecture tests and scripts/check-packages.sh fail on any project
  reference or package that SPEC does not allow.
- Khaemhat.Web serves an Italian "under construction" page with the
  official icons and version, plus /health/live, /health/ready and
  /health (ADR 0012); honours KHAEMHAT_URLS and KHAEMHAT_LOG_LEVEL.
- docker/Dockerfile (non-root app user aligned to PUID/PGID by the
  entrypoint, pg_dump 17, healthcheck, OCI and Unraid labels) and
  compose files for PostgreSQL and a standalone SQLite demo.
- Gitea Actions: ci.yml (build, tests, image smoke test, PostgreSQL
  16/17 on tags, YAML check), release.yml (image and release from a
  vX.Y.Z tag, skipping versions already published) and wiki.yml.
- Development scripts, VS Code launch/tasks for debugging, and ADR
  0012-0017 deciding the M0 open points of docs/STATUS.md.

Closes #1, #2, #3, #4, #5, #114

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-11 11:53:39 +01:00
1 parent 88de272b3e
commit 12277733f5
101 files changed
+3245 -67

No files matched your search

+180
View File
@@ -0,0 +1,180 @@
name: CI
# Gitea Actions (ADR 0009). The runner is act_runner in Docker mode on the server that also runs Gitea: one job at a
# time, so the triggers are frugal. The .NET jobs use the SDK image and check out with git (the image has no Node.js
# for JavaScript actions); nothing is cached or uploaded. Builds use BUILD_CPUS cores so the host keeps room for Gitea.
on:
pull_request:
branches: [main]
push:
branches: [main]
tags: ["v*"]
paths-ignore: ["docs/**", "*.md", "assets/**", "deploy/**"]
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
DOTNET_NOLOGO: "1"
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1"
BUILD_CPUS: "4"
KHAEMHAT_LICENSE_MODE: test
jobs:
build:
name: Build and test (SQLite)
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:10.0
timeout-minutes: 30
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'
- name: Package allowlist
run: bash scripts/check-packages.sh
- name: Build (warnings are errors)
run: dotnet build Khaemhat.sln -c Release -warnaserror -m:"$BUILD_CPUS"
- name: Test
run: dotnet test Khaemhat.sln -c Release --no-build
# PostgreSQL integration (SPEC §20): only on release tags and manual runs, against the two supported servers.
postgres:
name: PostgreSQL ${{ matrix.pg }} integration
needs: build
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
strategy:
fail-fast: false
matrix:
pg: ["16", "17"]
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:10.0
timeout-minutes: 30
services:
postgres:
image: postgres:${{ matrix.pg }}
env:
POSTGRES_USER: khaemhat
POSTGRES_PASSWORD: khaemhat-ci
POSTGRES_DB: khaemhat_test
defaults:
run:
shell: bash
env:
KHAEMHAT_TEST_PG: postgres://khaemhat:khaemhat-ci@postgres:5432/khaemhat_test
steps:
- name: Checkout
env:
TOKEN: ${{ github.token }}
run: |
git config --global --add safe.directory "$PWD"
git init -q .
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
git -c http.extraheader="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" fetch -q --depth=1 origin "${{ github.sha }}"
git checkout -q FETCH_HEAD
- name: Test · Data (PostgreSQL)
run: dotnet test tests/Khaemhat.Data.Tests -c Release -m:"$BUILD_CPUS"
# The image builds and answers /health/live (issue #2). The runner's own image has the docker CLI and talks to the
# host's daemon; the job joins a network of its own to reach the container. Everything is labelled with the job
# container's id: a cancelled job skips its clean-up, so the next one removes what a vanished job left on the host.
# Release tags skip it: release.yml builds and tests the same image.
docker:
name: Docker image
needs: build
if: "!startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Remove what cancelled jobs left
run: |
echo "NAME=khaemhat-ci-$(hostname)" >> "$GITHUB_ENV"
for c in $(docker ps -aq --filter label=khaemhat-ci.job); do
job="$(docker inspect -f '{{index .Config.Labels "khaemhat-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=khaemhat-ci.job); do
job="$(docker network inspect -f '{{index .Labels "khaemhat-ci.job"}}' "$n")"
docker inspect "$job" > /dev/null 2>&1 || docker network rm "$n"
done
for i in $(docker image ls -q --filter label=khaemhat-ci.job | sort -u); do
job="$(docker image inspect -f '{{index .Config.Labels "khaemhat-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 build -f docker/Dockerfile --build-arg VERSION=0.0.0-ci --build-arg GIT_SHA="$(git rev-parse --short HEAD)" \
--label khaemhat-ci.job="$(hostname)" -t "$NAME:image" .
- name: Smoke test (/health/live, non-root user, PUID/PGID)
run: |
docker network create --label khaemhat-ci.job="$(hostname)" "$NAME"
docker network connect "$NAME" "$(hostname)"
docker run -d --name "$NAME-app" --network "$NAME" --label khaemhat-ci.job="$(hostname)" \
-e KHAEMHAT_SYSTEM_DB=sqlite:///data/system.db -e KHAEMHAT_LICENSE_MODE=test -e PUID=99 -e PGID=100 "$NAME:image"
for i in $(seq 1 30); do
if curl -fsS --max-time 5 "http://$NAME-app:8080/health/live"; then echo; break; fi
sleep 2
done
curl -fsS --max-time 5 "http://$NAME-app:8080/health"
echo
curl -fsS --max-time 5 "http://$NAME-app:8080/" | grep -q "in costruzione"
test "$(docker exec "$NAME-app" sh -c 'stat -c %u:%g /proc/1')" = "99:100"
test "$(docker exec "$NAME-app" stat -c %u:%g /data)" = "99:100"
docker exec "$NAME-app" pg_dump --version
- name: Container logs and clean-up
if: always()
run: |
docker logs "$NAME-app" || true
docker rm -f -v "$NAME-app" || 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. The Ruby image has no git: the sources come as an archive.
yaml:
name: YAML check
runs-on: ubuntu-latest
container:
image: ruby:3.3-alpine
timeout-minutes: 10
steps:
- name: Workflows and compose files
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 deploy/*.yml