Update ci.yml #49
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 Pipeline | ||
| on: | ||
| push: | ||
| branches: [ main, develop ] | ||
| pull_request: | ||
| branches: [ main, develop ] | ||
| jobs: | ||
| build-and-test: | ||
| name: 🧪 Build, Lint & Test | ||
| runs-on: ubuntu-latest | ||
| services: | ||
| postgres: | ||
| image: postgres:15 | ||
| env: | ||
| POSTGRES_USER: ${{ secrets.POSTGRES_USER || 'user' }} | ||
| POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD || 'password' }} | ||
| POSTGRES_DB: ${{ secrets.POSTGRES_DB || 'api_workout_db' }} | ||
| ports: | ||
| - 5432:5432 | ||
| options: >- | ||
| --health-cmd="pg_isready -U ${{ secrets.POSTGRES_USER || 'user' }}" | ||
| --health-interval=10s | ||
| --health-timeout=5s | ||
| --health-retries=5 | ||
| env: | ||
| # Variáveis usadas nos testes e na aplicação | ||
| DATABASE_URL: postgresql+psycopg2://${{ secrets.POSTGRES_USER || 'user' }}:${{ secrets.POSTGRES_PASSWORD || 'password' }}@localhost:5432/${{ secrets.POSTGRES_DB || 'api_workout_db' }} | ||
| PYTHONPATH: ./app | ||
| ENVIRONMENT: test | ||
| steps: | ||
| - name: 📥 Checkout do repositório | ||
| uses: actions/checkout@v4 | ||
| - name: 🐍 Configurar Python 3.11 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
| - name: 📦 Instalar dependências | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| - name: 🧹 Rodar Linter (flake8) | ||
| run: | | ||
| pip install flake8 | ||
| flake8 app tests | ||
| - name: 🧪 Rodar Testes com Pytest | ||
| run: | | ||
| pip install pytest pytest-asyncio | ||
| pytest -v --maxfail=1 --disable-warnings | ||
| - name: 🗃️ Verificar Migrations Alembic | ||
| run: | | ||
| alembic upgrade head | ||