-
-
Notifications
You must be signed in to change notification settings - Fork 100
126 lines (109 loc) · 3.48 KB
/
reverse-proxy-test.yml
File metadata and controls
126 lines (109 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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