Align CI/CD with shared infra/ci-workflows and drop compose-based CI.
CI / changes (push) Successful in 1m4s
CI / backend (push) Failing after 0s
CI / frontend (push) Failing after 0s

Replace hand-rolled jobs with @v1 callers, capped bake/migrate CD, and remove the docker-compose.ci.yml bridge workaround.
This commit is contained in:
2026-10-06 19:10:58 +08:00
parent 1124c1f079
commit 5a175e3fba
12 changed files with 397 additions and 197 deletions
+83 -102
View File
@@ -1,118 +1,99 @@
# Build and test on every push/PR. Fixtures read ConnectionStrings__* /
# Redis__* directly from environment (see VigilCareRecordsAPI.Tests/Fixtures/
# ApiFixture.cs) against the ports published by docker-compose.yml; object
# storage is pgsty/silo (MinIO-compatible) from docker-compose.yml defaults
# (localhost:9012, minioadmin/minioadmin; bucket auto-created on first upload
# by DocumentStorageService).
# Thin caller — pipelines live in infra/ci-workflows@v1.
# Pin @v1 (never a branch). Path filter + changes job stay local (repo-specific).
#
# Prerequisite: infra/ci-workflows Settings → Actions → collaborative owners
# must list this repo's owner.
name: CI
on:
push:
branches: [master]
branches: [main, master]
paths:
- "VigilCareRecordsAPI/**"
- "VigilCareRecordsAPI.Tests/**"
- "vigilcare-records-web/**"
- "VigilCareRecords.sln"
- ".gitea/workflows/**"
pull_request:
branches: [master]
branches: [main, master]
paths:
- "VigilCareRecordsAPI/**"
- "VigilCareRecordsAPI.Tests/**"
- "vigilcare-records-web/**"
- "VigilCareRecords.sln"
- ".gitea/workflows/**"
workflow_dispatch:
jobs:
backend:
# Stays local: repo-specific path map; needs fetch-depth: 0.
# Keep actions/checkout@v4 here until builtin:checkout is proven with fetch-depth: 0.
changes:
runs-on: ubuntu-latest
# Isolated compose project + CI override (docker-compose.ci.yml) so jobs do
# not steal Docker address-pool subnets from each other / from prod.
env:
COMPOSE_PROJECT_NAME: vigilcare-ci
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml
# act_runner's docker executor runs steps inside their own job container — a
# sibling of the "docker compose" containers below — so "localhost" from inside
# the job container is NOT the Docker host and can't reach the published
# Postgres/Redis ports (this is what "Connection refused" on 127.0.0.1:5437
# in the Test step means). The Test step below points at host.docker.internal
# instead; that hostname must resolve inside the job container, which on Linux
# requires the runner itself (not this workflow) to add
# `--add-host=host.docker.internal:host-gateway` — set
# `container: { options: "--add-host=host.docker.internal:host-gateway" }` in the
# act_runner's config.yaml. Docker Desktop runners already resolve this hostname
# out of the box. See docs/25-gitea-cicd-docker-deploy.md ("Runner requirement
# for Compose-based tests").
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
steps:
- uses: actions/checkout@v4
- name: Start dependency stack
run: |
docker network prune -f || true
docker compose down --remove-orphans -v || true
docker compose up -d --remove-orphans postgres redis minio
- name: Wait for Postgres
run: |
for i in $(seq 1 60); do
docker compose exec -T postgres pg_isready -U postgres && break
sleep 2
done
docker compose exec -T postgres pg_isready -U postgres
- name: Wait for Redis / MinIO
run: |
for i in $(seq 1 60); do
docker compose exec -T redis redis-cli ping 2>/dev/null | grep -q PONG \
&& docker compose exec -T minio curl -sf http://localhost:9000/minio/health/live >/dev/null \
&& echo "Redis and MinIO are ready" && exit 0
echo "waiting for dependencies ($i)..."
sleep 2
done
echo "Dependencies failed to become ready" >&2
docker compose ps
docker compose logs --tail=50 redis minio
exit 1
- name: Create test database
run: |
docker compose exec -T postgres psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname='vigilcare_records_test'" \
| grep -q 1 \
|| docker compose exec -T postgres psql -U postgres -c "CREATE DATABASE vigilcare_records_test"
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
fetch-depth: 0
- name: Restore
run: dotnet restore VigilCareRecords.sln
- name: Build
run: dotnet build VigilCareRecords.sln -c Release --no-restore
- name: Test
env:
ASPNETCORE_ENVIRONMENT: "Testing"
CONNECTIONSTRINGS__DEFAULTCONNECTION: "Host=host.docker.internal;Port=5437;Database=vigilcare_records_test;Username=postgres;Password=password"
REDIS__CONNECTIONSTRING: "host.docker.internal:6383,defaultDatabase=1,allowAdmin=true"
- id: filter
name: Detect stack changes
run: |
dotnet test VigilCareRecords.sln -c Release --no-build \
--logger "trx;LogFileName=test-results.trx" \
--results-directory ./TestResults
set -euo pipefail
backend=false
frontend=false
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
backend=true
frontend=true
else
if [ "${{ github.event_name }}" = "pull_request" ]; then
base="${{ github.event.pull_request.base.sha }}"
else
base="${{ github.event.before }}"
fi
if [ -z "${base:-}" ] || [ "$base" = "0000000000000000000000000000000000000000" ]; then
backend=true
frontend=true
else
files="$(git diff --name-only "$base" "${{ github.sha }}")"
printf '%s\n' "$files"
if printf '%s\n' "$files" | grep -qE '^(VigilCareRecordsAPI/|VigilCareRecordsAPI\.Tests/|VigilCareRecords\.sln|\.gitea/workflows/)'; then
backend=true
fi
if printf '%s\n' "$files" | grep -qE '^(vigilcare-records-web/|\.gitea/workflows/)'; then
frontend=true
fi
fi
fi
echo "backend=${backend}" >> "$GITHUB_OUTPUT"
echo "frontend=${frontend}" >> "$GITHUB_OUTPUT"
- name: Publish test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
path: ./TestResults
- name: Tear down stack
if: always()
run: docker compose down --remove-orphans -v
backend:
needs: changes
if: needs.changes.outputs.backend == 'true'
uses: infra/ci-workflows/.gitea/workflows/dotnet8-ci.yml@v1
with:
working_directory: .
solution: VigilCareRecords.sln
postgres_db: vigilcare_records_test
# Single test project (service-backed). No isolated/InMemory split today.
test_projects: |
VigilCareRecordsAPI.Tests/VigilCareRecordsAPI.Tests.csproj
# ApiFixture reads CONNECTIONSTRINGS__DEFAULTCONNECTION / REDIS__CONNECTIONSTRING
# (not the shared workflow's ConnectionStrings__Postgres / ConnectionStrings__Redis).
test_env: |
CONNECTIONSTRINGS__DEFAULTCONNECTION=Host=postgres;Port=5432;Database=vigilcare_records_test;Username=postgres;Password=postgres;SSL Mode=Disable
REDIS__CONNECTIONSTRING=redis:6379,defaultDatabase=1,allowAdmin=true
frontend:
runs-on: ubuntu-latest
container:
image: node:22-alpine
steps:
- uses: actions/checkout@v4
- name: Install
working-directory: vigilcare-records-web
run: npm ci
- name: Test
working-directory: vigilcare-records-web
run: npm run test:run
- name: Build
working-directory: vigilcare-records-web
run: npm run build
needs: changes
if: needs.changes.outputs.frontend == 'true'
uses: infra/ci-workflows/.gitea/workflows/node-ci.yml@v1
with:
working_directory: vigilcare-records-web
node_version: "22"
# Typecheck once here; build must not re-run vue-tsc.
lint_command: npm run typecheck
extra_check_command: npm run test:run
build_command: npx vite build