-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (58 loc) · 1.61 KB
/
Copy pathc-cpp.yml
File metadata and controls
70 lines (58 loc) · 1.61 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
name: Make and Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
make-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential netcat-openbsd
- name: Build (make)
run: make
- name: Start webserv
run: |
chmod +x ./tester ./cgi_tester
./webserv conf/default.conf > server_output.txt 2>&1 &
echo $! > server.pid
echo "Waiting for webserv to start on port 8080..."
for i in {1..10}; do
if nc -z localhost 8080; then
echo "webserv is up and listening on port 8080."
exit 0
fi
sleep 1
done
echo "::error::webserv did not start listening on port 8080 within 10 seconds."
echo "----- server_output.txt -----"
cat server_output.txt || true
exit 1
- name: Run tester
run: |
./tester http://localhost:8080 > tester_output.txt 2>&1
TEST_EXIT_CODE=$?
cat tester_output.txt
exit $TEST_EXIT_CODE
- name: Stop webserv
if: always()
run: |
if [ -f server.pid ]; then
kill "$(cat server.pid)" 2>/dev/null || true
fi
- name: Upload debug artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: webserv-test-logs
path: |
server_output.txt
tester_output.txt
if-no-files-found: ignore
retention-days: 1