-
Notifications
You must be signed in to change notification settings - Fork 1
158 lines (155 loc) Β· 5.86 KB
/
webserv.yml
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
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Webserv Testing Workflow
run-name: ${{ github.actor }} is testing ${{ github.repository }}
on:
push: # Trigger on push events
pull_request: # Trigger on pull request events
types: [opened, synchronize] # Trigger on PR opened and PR synchronize events
workflow_dispatch: # Allows the workflow to be manually triggered
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- name: Clear cache
uses: actions/github-script@v6
with:
script: |
console.log("About to clear")
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (const cache of caches.data.actions_caches) {
console.log(cache)
await github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
}
console.log("Clear completed")
- run: echo "π The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "π The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "π‘ The ${{ github.repository }} repository has been cloned to the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- name: Compile webserv
run: make re
- name: Install Python dependencies
run: |
python3 -m pip install aiohttp asyncio aiofiles
- name: Start webserv in background
run: ./webserv &
- name: Install needed dependencies
run: sudo apt-get update && sudo apt-get install -y lsof curl
- name: Run Config file tests
if: always()
working-directory: tests/config
run: |
./config_test.sh
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "β Config file tests failed. Marking run as incorrect."
echo "::set-output name=config_tests_correct::false"
else
echo "β
Config file tests passed."
echo "::set-output name=config_tests_correct::true"
fi
- name: Check if webserv is running
run: |
if ps aux | grep -q '[w]ebserv'; then
echo "webserv is running."
else
echo "webserv is not running."
fi
- name: Run Python tests
if: always()
working-directory: tests # Set working directory to 'tests'
run: |
python3 general_tests.py
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "β Tests failed. Exiting with status code $exit_code."
exit $exit_code
fi
- name: Run Error codes tests
if: always()
working-directory: tests # Set working directory to 'tests'
run: |
./error_codes.sh
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "β Tests failed. Exiting with status code $exit_code."
exit $exit_code
fi
- name: Run C++ parser tests
if: always()
working-directory: tests # Set working directory to 'tests'
run: |
c++ parser.cpp -o parse && ./parse
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "β Tests failed. Exiting with status code $exit_code."
exit $exit_code
fi
- name: Run C++ router and CGI tests
if: always()
working-directory: tests
run: |
c++ router.cpp -o router && ./router
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "β Tests failed. Exiting with status code $exit_code."
exit $exit_code
fi
- name: Make parallel_cgi/duration_ts.sh executable
run: chmod +x tests/parallel_cgi/duration_ts.sh
- name: Run parallel CGIs Test
run: |
./tests/parallel_cgi/duration_ts.sh
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "β Parallel CGI tests failed. Exiting with status code $exit_code."
exit $exit_code
else
echo "β
Parallel CGI tests passed."
fi
- name: Check for Zombie Processes
run: |
zombies=$(ps aux | awk '$8=="Z" {print $2}')
if [ -n "$zombies" ]; then
echo " β Zombie processes found:"
echo "$zombies"
ps aux | awk '$8=="Z"'
for pid in $zombies; do
parent_pid=$(ps -o ppid= -p $pid)
echo "Sending SIGCHLD to parent process PID $parent_pid"
kill -SIGCHLD $parent_pid || echo "Failed to signal parent PID $parent_pid"
done
else
echo "β
No zombie processes found."
fi
- name: Check for open listening sockets
run: |
listening_sockets=$(lsof -iTCP -sTCP:LISTEN -nP | grep 'webserv')
if [ -z "$listening_sockets" ]; then
echo "Expected listening sockets are not open."
else
echo "Listening sockets are correctly open:"
echo "$listening_sockets"
fi
- name: Stop webserv
run: pkill -f webserv
- name: Verify no lingering sockets
run: |
sleep 5 # Give some time for sockets to close properly
lingering_sockets=$(lsof -iTCP -sTCP:LISTEN -nP | grep 'webserv' || true)
if [ -n "$lingering_sockets" ]; then
echo "Unexpected lingering sockets found:"
echo "$lingering_sockets"
else
echo "No lingering sockets found."
fi
- run: echo "π This job's status is ${{ job.status }}."