@@ -10,75 +10,80 @@ jobs:
1010 build-and-test :
1111 name : Build and Test
1212 runs-on : ubuntu-latest
13-
13+
1414 strategy :
1515 matrix :
1616 compiler : [gcc, clang]
17-
17+
1818 steps :
1919 - name : Checkout code
2020 uses : actions/checkout@v4
21-
21+
2222 - name : Set up environment
2323 run : |
2424 if [ "${{ matrix.compiler }}" = "gcc" ]; then
2525 echo "CC=gcc" >> $GITHUB_ENV
2626 else
2727 echo "CC=clang" >> $GITHUB_ENV
2828 fi
29-
29+
3030 - name : Install dependencies
3131 run : |
3232 sudo apt-get update
3333 sudo apt-get install -y valgrind python3 python3-pip
3434 pip3 install requests
35-
35+
3636 - name : Build server
3737 run : |
3838 make clean
3939 make
40-
40+
4141 - name : Check for compilation warnings
4242 run : |
4343 make clean
4444 make CFLAGS="-Wall -Wextra -Werror"
45-
45+
4646 - name : Run unit tests
4747 run : |
4848 gcc -o tests/test_main tests/test_main.c main.c httpd.c -I. -DTESTING
4949 ./tests/test_main
50-
50+
5151 - name : Run integration tests
5252 run : |
5353 python3 tests/integration_test.py
54-
54+
5555 - name : Memory leak check
5656 run : |
5757 # Start server with valgrind
5858 valgrind --leak-check=full --error-exitcode=1 --log-file=valgrind.log \
5959 ./server 9999 &
6060 SERVER_PID=$!
61-
61+
6262 # Wait for server
6363 sleep 2
64-
64+
6565 # Send test request
6666 curl -s http://localhost:9999/ || true
67-
67+
6868 # Stop server
6969 kill -INT $SERVER_PID
7070 wait $SERVER_PID || true
71-
71+
7272 # Check results
73- if grep -q "definitely lost: 0 bytes" valgrind.log && \
74- grep -q "indirectly lost: 0 bytes" valgrind.log; then
75- echo "✓ No memory leaks detected"
73+ echo "=== Valgrind Report ==="
74+ cat valgrind.log
75+ echo ""
76+
77+ # Check for memory leaks (multiple possible formats)
78+ if grep -q "All heap blocks were freed -- no leaks are possible" valgrind.log || \
79+ (grep -q "definitely lost: 0 bytes" valgrind.log && \
80+ grep -q "indirectly lost: 0 bytes" valgrind.log); then
81+ echo "✅ No memory leaks detected"
7682 else
77- echo "⚠ Memory leaks detected:"
78- cat valgrind.log
83+ echo "❌ Memory leaks detected"
7984 exit 1
8085 fi
81-
86+
8287 - name : Static analysis with compiler
8388 run : |
8489 $CC -Wall -Wextra -pedantic -fsyntax-only main.c httpd.c 2>&1 | tee static-analysis.log
8893 else
8994 echo "✓ No static analysis warnings"
9095 fi
91-
96+
9297 - name : Upload artifacts on failure
9398 if : failure()
9499 uses : actions/upload-artifact@v4
@@ -102,38 +107,38 @@ jobs:
102107 security-scan :
103108 name : Security Scan
104109 runs-on : ubuntu-latest
105-
110+
106111 steps :
107112 - name : Checkout code
108113 uses : actions/checkout@v4
109-
114+
110115 - name : Run cppcheck
111116 run : |
112117 sudo apt-get update
113118 sudo apt-get install -y cppcheck
114119 cppcheck --enable=all --error-exitcode=1 --suppress=missingIncludeSystem \
115120 main.c httpd.c httpd.h 2>&1 | tee cppcheck.log || true
116-
121+
117122 # Show results but don't fail build on warnings
118123 if [ -s cppcheck.log ]; then
119124 echo "⚠ Cppcheck found issues:"
120125 cat cppcheck.log
121126 else
122127 echo "✓ No cppcheck issues found"
123128 fi
124-
129+
125130 - name : Check for common vulnerabilities
126131 run : |
127132 echo "Checking for common security issues..."
128-
133+
129134 # Check for unsafe functions
130135 if grep -r "gets\|sprintf\|strcpy\|strcat\|scanf" *.c *.h; then
131136 echo "❌ Found usage of unsafe functions"
132137 exit 1
133138 else
134139 echo "✓ No unsafe function usage found"
135140 fi
136-
141+
137142 # Check for TODO/FIXME related to security
138143 if grep -ri "TODO.*security\|FIXME.*security\|XXX.*security" *.c *.h; then
139144 echo "⚠ Found security-related TODOs"
@@ -144,31 +149,31 @@ jobs:
144149 documentation :
145150 name : Documentation Check
146151 runs-on : ubuntu-latest
147-
152+
148153 steps :
149154 - name : Checkout code
150155 uses : actions/checkout@v4
151-
156+
152157 - name : Check for required documentation
153158 run : |
154159 echo "Checking documentation..."
155-
160+
156161 files="README.md CONTRIBUTING.md SECURITY.md CHANGELOG.md"
157162 missing=""
158-
163+
159164 for file in $files; do
160165 if [ ! -f "$file" ]; then
161166 missing="$missing $file"
162167 fi
163168 done
164-
169+
165170 if [ -n "$missing" ]; then
166171 echo "❌ Missing documentation files:$missing"
167172 exit 1
168173 else
169174 echo "✓ All required documentation files present"
170175 fi
171-
176+
172177 - name : Validate markdown
173178 run : |
174179 echo "Checking markdown files..."
@@ -188,7 +193,7 @@ jobs:
188193 runs-on : ubuntu-latest
189194 needs : [build-and-test, security-scan, documentation]
190195 if : always()
191-
196+
192197 steps :
193198 - name : Check build status
194199 run : |
0 commit comments