chore: run Bruno server collection in .NET GitHub workflow

pull/76/head
VinPropane 2026-05-10 19:27:25 -04:00
parent 371d2d17cc
commit 596b319493
1 changed files with 47 additions and 2 deletions

View File

@ -1,4 +1,5 @@
# Build and test the C# solution (server + tests). Targets repo root NeonSprawl.sln.
# Build and test the C# solution (server + tests), then run the Bruno server collection
# against a live `dotnet run` host (same Postgres service as tests). Targets repo root NeonSprawl.sln.
# PRs: workflow always runs (so ".NET / build" can be a required check). Path-sensitive
# work uses step-level `if` — skipped steps still leave the job successful (unlike a
# workflow skipped via `on.paths`, which leaves the required check missing/pending).
@ -11,6 +12,7 @@ on:
paths:
- "NeonSprawl.sln"
- "server/**"
- "bruno/neon-sprawl-server/**"
- ".github/workflows/dotnet.yml"
pull_request:
branches: [main]
@ -51,11 +53,12 @@ jobs:
server:
- "NeonSprawl.sln"
- "server/**"
- "bruno/neon-sprawl-server/**"
- ".github/workflows/dotnet.yml"
- name: Skip .NET build (no server-side paths in this PR)
if: github.event_name == 'pull_request' && steps.paths.outputs.server != 'true'
run: echo "Skipping .NET restore, build, and tests."
run: echo "Skipping .NET restore, build, tests, and Bruno collection."
- name: Setup .NET
if: github.event_name == 'push' || steps.paths.outputs.server == 'true'
@ -77,3 +80,45 @@ jobs:
ConnectionStrings__NeonSprawl: >-
Host=localhost;Port=5432;Database=neon_sprawl;Username=neon_sprawl;Password=neon_sprawl_dev
run: dotnet test NeonSprawl.sln --no-build --configuration Release --verbosity normal
- name: Setup Node (Bruno CLI)
if: github.event_name == 'push' || steps.paths.outputs.server == 'true'
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Bruno (server API collection)
if: github.event_name == 'push' || steps.paths.outputs.server == 'true'
env:
ConnectionStrings__NeonSprawl: >-
Host=localhost;Port=5432;Database=neon_sprawl;Username=neon_sprawl;Password=neon_sprawl_dev
run: |
set -euo pipefail
dotnet run --project server/NeonSprawl.Server/NeonSprawl.Server.csproj \
--configuration Release --no-build \
--urls "http://127.0.0.1:5253" &
SERVER_PID=$!
cleanup() {
kill "${SERVER_PID}" 2>/dev/null || true
wait "${SERVER_PID}" 2>/dev/null || true
}
trap cleanup EXIT
for i in $(seq 1 90); do
if curl -sfS "http://127.0.0.1:5253/health" >/dev/null; then
echo "Server ready (${i}s)"
break
fi
if ! kill -0 "${SERVER_PID}" 2>/dev/null; then
echo "Server process exited before /health succeeded" >&2
wait "${SERVER_PID}" || true
exit 1
fi
sleep 1
if [ "${i}" -eq 90 ]; then
echo "Timed out waiting for http://127.0.0.1:5253/health" >&2
exit 1
fi
done
cd bruno/neon-sprawl-server
# v3 defaults to Safe Mode; pre-request scripts use require("axios").
npx --yes @usebruno/cli@3.3.0 run --env Local --sandbox=developer --bail