#!/usr/bin/env bash set -euo pipefail mkdir -p artifacts/tests artifacts/security : "${DATABASE_URL:?A disposable PostgreSQL database is required}" dotnet --info > artifacts/dotnet-info.txt if [[ -f scripts/ci/validate-compose.sh ]]; then bash scripts/ci/validate-compose.sh else docker compose --env-file .env.example -f docker/docker-compose.yml config --quiet fi bash docker/scripts/test-backup-restore.sh dotnet restore Heimdall.slnx --locked-mode dotnet build Heimdall.slnx -c Release --no-restore -m:2 # NuGet advisory report is kept separate from compiler warning suppressions. # Each test project gets an independent disposable database. Run sequentially: # several fixtures truncate shared tables and must never race other assemblies. status=0 for project in tests/*/*.csproj; do name=$(basename "${project%.csproj}") [[ "$name" == Heimdall.TestCommon || "$name" == Heimdall.E2E.Tests ]] && continue dbname="ci_${name//./_}" psql --no-password -v ON_ERROR_STOP=1 -c "CREATE DATABASE \"$dbname\"" >/dev/null DATABASE_URL="$DATABASE_URL;Database=$dbname" \ dotnet test "$project" -c Release --no-build --no-restore \ --logger 'trx;LogFileName=results.trx' --results-directory "artifacts/tests/$name" || status=1 done dotnet run scripts/ci/install-chromium.cs -- install --with-deps chromium psql --no-password -v ON_ERROR_STOP=1 -c "CREATE DATABASE ci_e2e" >/dev/null DATABASE_URL="$DATABASE_URL;Database=ci_e2e" \ dotnet test tests/Heimdall.E2E.Tests -c Release --no-build --no-restore \ --logger 'trx;LogFileName=results.trx' --results-directory artifacts/tests/e2e || status=1 exit "$status"