1- name : CI
2- on : [push]
1+ name : CI Pipeline
2+
3+ on :
4+ push :
5+ branches : ["main"]
6+ pull_request :
7+ branches : ["main"]
8+
39jobs :
4- test :
10+ test-backend :
11+ name : Test Backend + Lint + Build
512 runs-on : ubuntu-latest
13+
14+ services :
15+ postgres :
16+ image : postgres:15
17+ env :
18+ POSTGRES_USER : postgres
19+ POSTGRES_PASSWORD : 123
20+ POSTGRES_DB : listacompras_test
21+ ports :
22+ - 5432:5432
23+ options : >-
24+ --health-cmd="pg_isready -U postgres"
25+ --health-interval=5s
26+ --health-timeout=5s
27+ --health-retries=5
28+
629 steps :
7- - uses : actions/checkout@v4
8- - uses : actions/setup-python@v5
30+
31+ - name : Checkout código
32+ uses : actions/checkout@v4
33+
34+ - name : Configurar Python
35+ uses : actions/setup-python@v5
936 with :
10- python-version : ' 3.11'
11- - run : pip install -r backend/requirements.txt
12- - run : pytest backend/tests/
37+ python-version : ' 3.12'
38+
39+ - name : Instalar dependências do backend
40+ working-directory : backend
41+ run : |
42+ pip install --upgrade pip
43+ pip install -r requirements.txt
44+ pip install flake8
45+
46+ - name : Rodar flake8 (lint)
47+ working-directory : backend
48+ run : |
49+ flake8 . --max-line-length=120
50+
51+ - name : Rodar testes (pytest)
52+ working-directory : backend
53+ env :
54+ DATABASE_URL : postgresql://postgres:123@localhost:5432/listacompras_test
55+ TEST_DATABASE_URL : postgresql://postgres:123@localhost:5432/listacompras_test
56+ SECRET_KEY : " testingkey"
57+ run : |
58+ pytest -q --disable-warnings --maxfail=1
59+
60+ - name : Testar build do Docker (backend e frontend)
61+ run : |
62+ docker compose -f docker-compose.yml build
0 commit comments