File tree Expand file tree Collapse file tree
src/Analysim.Web/Controllers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Backend Smoke Test
2+
3+ on :
4+ pull_request :
5+ branches : [develop]
6+ push :
7+ branches : [develop]
8+
9+ jobs :
10+ backend-smoke-test :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout repository
15+ uses : actions/checkout@v4
16+
17+ - name : Setup .NET
18+ uses : actions/setup-dotnet@v4
19+ with :
20+ dotnet-version : 6.0.x
21+
22+ - name : Restore dependencies
23+ run : dotnet restore
24+
25+ - name : Create appsettings.json
26+ run : |
27+ cat <<EOF > src/Analysim.Web/appsettings.json
28+ {
29+ "JwtSettings": {
30+ "Issuer": "AnalySim",
31+ "Secret": "very_hard_secret",
32+ "ExpireTime": 60,
33+ "Audience": "https://www.analysim.tech/"
34+ },
35+ "Logging": {
36+ "LogLevel": {
37+ "Default": "Information",
38+ "Microsoft": "Warning"
39+ }
40+ },
41+ "AllowedHosts": "*"
42+ }
43+ EOF
44+
45+ - name : Build backend
46+ run : dotnet build --no-restore --configuration Release
47+
48+ - name : Start backend
49+ run : |
50+ cd src/Analysim.Web
51+ dotnet run --no-launch-profile > ../../backend.log 2>&1 &
52+ echo $! > ../../backend.pid
53+
54+ - name : Wait for backend to be ready
55+ run : |
56+ for i in {1..15}; do
57+ RESPONSE=$(curl -k -s https://localhost:5001/api/health || true)
58+
59+ if [[ "$RESPONSE" == *Healthy* ]]; then
60+ echo "Backend is healthy"
61+ exit 0
62+ fi
63+
64+ echo "Attempt $i/30: backend not ready yet"
65+ sleep 6
66+ done
67+
68+ echo "Backend failed to become ready"
69+ echo "===== Backend log ====="
70+ cat backend.log
71+ exit 1
72+
73+ - name : Stop backend
74+ if : always()
75+ run : |
76+ if [ -f backend.pid ]; then
77+ kill $(cat backend.pid) || true
78+ fi
Original file line number Diff line number Diff line change 1+ using Microsoft . AspNetCore . Mvc ;
2+
3+ namespace Analysim . Web . Controllers ;
4+
5+ [ ApiController ]
6+ [ Route ( "api/[controller]" ) ]
7+ public class HealthController : ControllerBase
8+ {
9+ [ HttpGet ]
10+ public IActionResult get ( )
11+ {
12+ return Ok ( "Healthy" ) ;
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments