Skip to content

dantol29 is testing dantol29/webserver #107

dantol29 is testing dantol29/webserver

dantol29 is testing dantol29/webserver #107

Workflow file for this run

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 }}."