Skip to content

Commit a6a2c26

Browse files
committed
configuramento no ci
1 parent 1e5bb8a commit a6a2c26

File tree

14 files changed

+60
-25
lines changed

14 files changed

+60
-25
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ jobs:
2727
--health-retries=5
2828
2929
steps:
30-
3130
- name: Checkout código
3231
uses: actions/checkout@v4
3332

@@ -41,22 +40,22 @@ jobs:
4140
run: |
4241
pip install --upgrade pip
4342
pip install -r requirements.txt
44-
pip install flake8
43+
pip install flake8 pytest
4544
4645
- name: Rodar flake8 (lint)
4746
working-directory: backend
4847
run: |
4948
flake8 . --max-line-length=120
5049
5150
- name: Rodar testes (pytest)
52-
working-directory: backend
5351
env:
52+
PYTHONPATH: ${{ github.workspace }}/backend
5453
DATABASE_URL: postgresql://postgres:123@localhost:5432/listacompras_test
5554
TEST_DATABASE_URL: postgresql://postgres:123@localhost:5432/listacompras_test
5655
SECRET_KEY: "testingkey"
5756
run: |
58-
pytest -q --disable-warnings --maxfail=1
57+
python -m pytest backend/tests/ -q --disable-warnings --maxfail=1
5958
6059
- name: Testar build do Docker (backend e frontend)
6160
run: |
62-
docker compose -f docker-compose.yml build
61+
docker compose -f docker-compose.yml build

backend/Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# backend/Dockerfile
21
FROM python:3.12-slim
32

43
WORKDIR /app
@@ -9,17 +8,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
98
gcc \
109
&& rm -rf /var/lib/apt/lists/*
1110

12-
# Copy correct backend requirements
1311
COPY backend/requirements.txt /app/requirements.txt
1412

1513
RUN pip install --no-cache-dir --upgrade pip \
1614
&& pip install --no-cache-dir -r /app/requirements.txt
1715

18-
# Copy backend source
1916
COPY backend /app
2017

2118
EXPOSE 8000
2219
ENV PYTHONUNBUFFERED=1
2320
ENV PYTHONPATH=/app
2421

25-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
22+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
-32 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

backend/docker.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# backend/Dockerfile
2+
FROM python:3.12-slim
3+
4+
WORKDIR /app
5+
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
build-essential \
8+
libpq-dev \
9+
gcc \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Copy correct backend requirements
13+
COPY backend/requirements.txt /app/requirements.txt
14+
15+
RUN pip install --no-cache-dir --upgrade pip \
16+
&& pip install --no-cache-dir -r /app/requirements.txt
17+
18+
# Copy backend source
19+
COPY backend /app
20+
21+
EXPOSE 8000
22+
ENV PYTHONUNBUFFERED=1
23+
24+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
25+

backend/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import os
33
from fastapi import FastAPI
44
from fastapi.middleware.cors import CORSMiddleware
5-
from backend.models import Base
6-
from backend.database import engine
7-
from backend.routes.auth import router as auth_router
8-
from backend.routes.carts import router as cart_router
5+
from models import Base
6+
from database import engine
7+
from routes.auth import router as auth_router
8+
from routes.carts import router as cart_router
99

1010
backend_dir = os.path.dirname(os.path.abspath(__file__))
1111
if backend_dir not in sys.path:
0 Bytes
Binary file not shown.
-14 Bytes
Binary file not shown.

backend/routes/auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from fastapi import APIRouter, Depends, HTTPException
33
from sqlalchemy.orm import Session
44
from pydantic import BaseModel
5-
from backend.models import User
6-
from backend.database import get_db
7-
from backend.security import create_access_token
5+
from models import User
6+
from database import get_db
7+
from security import create_access_token
88

99

1010
router = APIRouter(tags=["Auth"])

backend/routes/carts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from fastapi import APIRouter, Depends, HTTPException
22
from sqlalchemy.orm import Session
33
from pydantic import BaseModel
4-
from backend.models import Cart, Item, User
5-
from backend.database import get_db
6-
from backend.security import get_current_user
4+
from models import Cart, Item, User
5+
from database import get_db
6+
from security import get_current_user
77

88

99
router = APIRouter(tags=["Carrinhos"])

0 commit comments

Comments
 (0)