Skip to content

refactor(ci): Simplify and correct coverage command #22

refactor(ci): Simplify and correct coverage command

refactor(ci): Simplify and correct coverage command #22

Workflow file for this run

name: CI/CD
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.13"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install ruff
- name: Run Ruff Linter
uses: astral-sh/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Ruff Formatter Check
run: ruff format --check
test:
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Create .env file for Docker
run: |
cat <<'EOF' >> .env
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0
DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }}
POSTGRES_DATABASE=${{ secrets.POSTGRES_DB }}
POSTGRES_USERNAME=${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_HOST=db
ANTIFRAUD_INTERNAL_PORT=9090
ANTIFRAUD_EXTERNAL_PORT=9090
ANTIFRAUD_CACHE_MS=5000
ANTIFRAUD_ADDRESS=http://antifraud:9090
EOF
- name: Build and run Docker containers
run: docker compose up -d --build
- name: Wait for services to be healthy
run: |
echo "Waiting for PostgreSQL..."
sleep 20
- name: Run tests and generate coverage report 🛡️
run: >
docker compose exec -T web sh -c
"coverage run --source='.' promo_code/manage.py test business core user && coverage xml -o promo_code/coverage.xml"
- name: Copy coverage report from container 📂
run: docker compose cp web:/usr/src/app/promo_code/coverage.xml ./coverage.xml
- name: Upload coverage to Codecov 🚀
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: promo_code
fail_ci_if_error: true