Skip to content

122

122 #361

Workflow file for this run

name: Python CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
PIPENV_VENV_IN_PROJECT: 1
PIPENV_IGNORE_VIRTUALENVS: 1
DATABASE_URL: postgres://postgres:postgres@localhost:5432/testdb
strategy:
matrix:
python-version: ['3.10']
steps:
- name: Checkout do repositório
uses: actions/checkout@v3
- name: Configurar Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Instalar pipenv e dependências
run: |
pip install --quiet pipenv
pipenv sync -d
pipenv run pip install --quiet pytest pytest-cov codecov gunicorn
cp contrib/env-sample .env
- name: Esperar o PostgreSQL subir e criar o banco
run: |
sudo apt-get install -y postgresql-client
until pg_isready -h localhost -U postgres; do sleep 1; done
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE DATABASE testdb;"
- name: Rodar Flake8 e Pytest
run: |
pipenv run flake8 .
- name: Rodar Pytest com cobertura
run: |
export PYTHONPATH=$PYTHONPATH:$(pwd)
pipenv run pytest --cov=pypro --cov-report=xml
- name: Enviar cobertura para Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml