This commit is contained in:
rabeeafaraj 2025-08-10 13:18:46 +03:00
parent 57e080e917
commit 0aa101cac0

View file

@ -1,52 +1,35 @@
name: API Tests (pytest) name: Run Tests
on: on:
push:
branches: [ main ]
pull_request: pull_request:
branches: [ main ] branches:
- main
jobs: jobs:
test-api: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - uses: actions/checkout@v4
uses: actions/checkout@v4
- name: Set up Python - name: Set up Python 3.12
uses: actions/setup-python@v5 uses: actions/setup-python@v4
with: with:
python-version: "3.11" python-version: '3.12'
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip pip install -r requirements.txt
pip install requests pytest pip install pytest pytest-cov
- name: Start API server (Docker) - name: Run pytest with coverage
run: | env:
docker compose up -d WEKAN_URL: http://${{ secrets.HOST }}:80
sleep 10 run: |
pytest --cov=API_Testing --cov-report=xml API_Testing/
- name: Wait for API /users/login to be ready - name: Upload coverage reports to Codecov
run: | uses: codecov/codecov-action@v5
echo "Checking /users/login endpoint readiness..." with:
for i in {1..15}; do token: ${{ secrets.CODECOV_TOKEN }}
status_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:80/users/login) slug: RabeeaFaraj/wekan_rabeea
if [ "$status_code" = "400" ] || [ "$status_code" = "200" ]; then
echo "API /users/login responded with status $status_code"
exit 0
fi
echo "Retry $i: API not ready yet, status $status_code"
sleep 3
done
echo "API /users/login did not become ready in time."
exit 1
- name: Seed DB with test user
run: |
docker exec wekan-db python3 seed_users.py
- name: Run pytest
run: pytest tests_r/ --maxfail=1 --disable-warnings -v