Skip to content

feat(api): add audio source listing endpoints (#2913) #1392

feat(api): add audio source listing endpoints (#2913)

feat(api): add audio source listing endpoints (#2913) #1392

name: Reverse Proxy Tests
on:
push:
branches: [main]
paths:
- 'frontend/**'
- 'internal/api/**'
- '.github/workflows/reverse-proxy-test.yml'
pull_request:
paths:
- 'frontend/**'
- 'internal/api/**'
- '.github/workflows/reverse-proxy-test.yml'
concurrency:
group: reverse-proxy-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
reverse-proxy-tests:
name: Nginx Reverse Proxy Route Validation
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v6
# --- Go backend setup ---
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Setup TensorFlow Lite
uses: ./.github/actions/setup-tensorflow
# --- Node.js setup ---
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: 'frontend/package-lock.json'
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
# --- Build frontend (needed for backend dev mode serving) ---
- name: Build frontend
working-directory: frontend
run: npm run build
# --- Build backend (skipfrontend tag: uses stub embed, serves from disk) ---
- name: Build backend
run: |
go build -trimpath -tags skipfrontend \
-ldflags "-s -w" \
-o bin/birdnet-go
# --- Start backend ---
- name: Start backend
run: |
# Start backend in background
./bin/birdnet-go realtime &
BACKEND_PID=$!
echo "BACKEND_PID=$BACKEND_PID" >> $GITHUB_ENV
# Wait for backend to be ready
echo "Waiting for backend health endpoint..."
for i in $(seq 1 60); do
if curl -sf http://localhost:8080/api/v2/health > /dev/null 2>&1; then
echo "Backend is ready (attempt $i)"
break
fi
if [ $i -eq 60 ]; then
echo "Backend failed to start within 60 seconds"
exit 1
fi
sleep 1
done
# --- Ensure Docker is available ---
- name: Wait for Docker daemon
run: |
echo "Waiting for Docker daemon to be ready..."
for i in $(seq 1 30); do
if docker info > /dev/null 2>&1; then
echo "Docker is ready (attempt $i)"
break
fi
if [ $i -eq 30 ]; then
echo "Docker failed to become available after 30 attempts"
docker info || true
exit 1
fi
echo "Docker not ready yet (attempt $i/30), waiting..."
sleep 2
done
# --- Pull nginx image ---
- name: Pull nginx image
run: docker pull nginx:1.27-alpine
# --- Run reverse proxy tests ---
- name: Run reverse proxy tests
working-directory: frontend
env:
BACKEND_URL: http://localhost:8080
run: npm run test:reverse-proxy
# --- Cleanup ---
- name: Stop backend
if: always()
run: |
if [ -n "$BACKEND_PID" ]; then
kill $BACKEND_PID 2>/dev/null || true
fi
# Clean up any nginx test containers
docker rm -f birdnet-test-root-proxy birdnet-test-subpath-proxy 2>/dev/null || true