[CI/CD] adding tests for backend build #3
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: Backend Build | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Check out the main repository | |
- name: Checkout main repository | |
uses: actions/checkout@v2 | |
with: | |
path: curio | |
# Set up Python environment | |
- name: Set up Python Environment | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
# Backend setup | |
- name: Install backend dependencies | |
working-directory: ./curio/backend | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run backend server | |
working-directory: ./curio/backend | |
run: | | |
nohup python server.py > backend.log 2>&1 & | |
sleep 20 | |
cat backend.log | |
# Python Sandbox setup | |
- name: Install sandbox dependencies | |
working-directory: ./curio/sandbox | |
run: | | |
pip install -r requirements.txt | |
pip install utk-0.8.9.tar.gz | |
- name: Run sandbox server | |
working-directory: ./curio/sandbox | |
run: | | |
nohup python server.py > sandbox.log 2>&1 & | |
sleep 20 | |
cat sandbox.log | |
# Post-build tasks | |
- name: Check for running processes | |
run: | | |
ps aux | grep server.py | |
# Verify backend server (Port 5002) | |
- name: Verify backend server | |
run: | | |
curl http://localhost:5002/liveness || echo "Backend not reachable" | |
# Verify sandbox server (Port 2000) | |
- name: Verify sandbox server | |
run: | | |
curl http://localhost:2000/liveness || echo "Sandbox not reachable" | |
# Run Unit Tests | |
- name: Run Unit Tests | |
working-directory: ./curio | |
run: | | |
python -m unittest discover -p "test_*.py" -v | |
# Stop all servers | |
- name: Stop all servers | |
run: | | |
pkill -f "python server.py" || true |