552020 is testing dantol29/webserver #26
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." | |
exit 1 | |
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') | |
if [ -n "$lingering_sockets" ]; then | |
echo "Unexpected lingering sockets found:" | |
echo "$lingering_sockets" | |
exit 1 | |
else | |
echo "No lingering sockets found." | |
- run: echo "π This job's status is ${{ job.status }}." |