forked from Loqicx/join
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (124 loc) · 4.2 KB
/
main.yml
File metadata and controls
145 lines (124 loc) · 4.2 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Build and Test
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
jobs:
frontend-build:
name: Frontend Build Check
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.14.0"
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
working-directory: ./frontend
run: npm ci
- name: Build Angular project
working-directory: ./frontend
# Note: Using --optimization=false to avoid font inlining network issues in CI
# This ensures reliable builds in restricted network environments
run: npm run build -- --optimization=false
- name: Check build artifacts
working-directory: ./frontend
run: |
if [ ! -d "dist/join" ]; then
echo "Build failed: dist/join directory not found"
exit 1
fi
echo "Frontend build successful!"
backend-test:
name: Backend API Test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: backend/requirements.txt
- name: Install backend dependencies
working-directory: ./backend
run: |
pip install -r requirements.txt
- name: Run database migrations
working-directory: ./backend
run: |
python manage.py migrate
- name: Start Django test server
working-directory: ./backend
run: |
python manage.py runserver 0.0.0.0:8000 &
SERVER_PID=$!
echo "SERVER_PID=$SERVER_PID" >> $GITHUB_ENV
echo "Django server started with PID: $SERVER_PID"
- name: Wait for server to start
run: |
echo "Waiting for Django server to be ready..."
for i in {1..30}; do
if curl -s http://localhost:8000/api/v1/auth/users/ > /dev/null 2>&1; then
echo "Server is ready!"
exit 0
fi
sleep 1
done
echo "Server failed to start within 30 seconds"
exit 1
- name: Test API endpoints
run: |
echo "Testing backend API endpoints..."
# Test admin endpoint (should redirect)
echo "Testing /admin/ endpoint..."
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/admin/)
if [[ "$HTTP_CODE" =~ ^(200|302)$ ]]; then
echo "✓ Admin endpoint accessible (HTTP $HTTP_CODE)"
else
echo "Failed to reach /admin/ (HTTP $HTTP_CODE)"
exit 1
fi
# Test auth endpoints
echo "Testing /api/v1/auth/users/ endpoint..."
if curl -sf http://localhost:8000/api/v1/auth/users/ > /dev/null; then
echo "✓ Auth users endpoint accessible"
else
echo "Failed to reach /api/v1/auth/users/"
exit 1
fi
# Test task endpoint
echo "Testing /api/v1/task/ endpoint..."
if curl -sf http://localhost:8000/api/v1/task/ > /dev/null; then
echo "✓ Task endpoint accessible"
else
echo "Failed to reach /api/v1/task/"
exit 1
fi
# Test contact endpoint
echo "Testing /api/v1/contact/ endpoint..."
if curl -sf http://localhost:8000/api/v1/contact/ > /dev/null; then
echo "✓ Contact endpoint accessible"
else
echo "Failed to reach /api/v1/contact/"
exit 1
fi
echo ""
echo "All endpoint tests passed!"
- name: Stop Django server
if: always()
run: |
if [[ -n "$SERVER_PID" ]]; then
kill "$SERVER_PID" || true
echo "Django server stopped"
fi