ci: Replace Docker Compose action with manual installation #3
This file contains hidden or 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: 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: | | |
echo "DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0" >> .env | |
echo "DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }}" >> .env | |
echo "POSTGRES_DATABASE=${{ secrets.POSTGRES_DATABASE }}" >> .env | |
echo "POSTGRES_USERNAME=${{ secrets.POSTGRES_USERNAME }}" >> .env | |
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> .env | |
echo "ANTIFRAUD_INTERNAL_PORT=8081" >> .env | |
echo "ANTIFRAUD_EXTERNAL_PORT=8081" >> .env | |
echo "ANTIFRAUD_CACHE_MS=1000" >> .env | |
- name: Install Docker Compose v1 | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y docker-compose-plugin | |
docker-compose version | |
- 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 manage.py test && coverage xml" | |
- name: Upload coverage to Codecov 🚀 | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true |