From 8294fbabab995e3adb615aa724ff600da349a840 Mon Sep 17 00:00:00 2001 From: Prince D Rusweka Rwabongoya Date: Wed, 23 Apr 2025 20:32:01 -0400 Subject: [PATCH] Update backend-ci.yml --- backend/.github/workflows/backend-ci.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/backend/.github/workflows/backend-ci.yml b/backend/.github/workflows/backend-ci.yml index e387e6b..4effa39 100644 --- a/backend/.github/workflows/backend-ci.yml +++ b/backend/.github/workflows/backend-ci.yml @@ -36,7 +36,7 @@ jobs: test: runs-on: self-hosted - needs: lint + needs: lint # Ensure this job runs after linting steps: - name: Checkout repository @@ -53,15 +53,22 @@ jobs: source venv/bin/activate pip install -r backend/requirements.txt - - name: Start API server in background + - name: Start the API server run: | - source venv/bin/activate - nohup python backend/main.py > server.log 2>&1 & - sleep 5 + nohup python backend/main.py & # Start the API server in the background + # Wait for the server to be ready + for i in {1..10}; do + if curl --silent --fail http://127.0.0.1:5000/; then + echo "Server is up and running." + break + fi + echo "Waiting for server to start... Attempt $i/10" + sleep 3 + done - name: Run tests with pytest env: - BASE_URL: http://127.0.0.1:5000 + BASE_URL: http://127.0.0.1:5000 # Assuming your API is running on this address run: | source venv/bin/activate pytest backend/tests --maxfail=1 --disable-warnings -q