Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f185cc9
Configuração inicial do CI com GitHub Actions
Raulkubisds Sep 10, 2025
fcbd284
Delete teste_cicd01.py
Raulkubisds Sep 11, 2025
9b9c819
Tentando usar o Actions
Raulkubisds Sep 14, 2025
06fd4fd
Update python-app.yml
Raulkubisds Sep 14, 2025
3affb25
tentativa de configurar o actions
Raulkubisds Sep 14, 2025
5506ffb
fix: adiciona docstrings e corrige lint
Raulkubisds Sep 14, 2025
1d765f2
fix: adiciona docstrings e corrige lint
Raulkubisds Sep 14, 2025
3ebdbf7
tentativa de configurar o actions
Raulkubisds Sep 15, 2025
3a45847
enviar mensagem para o Discord
Raulkubisds Sep 22, 2025
569cb1a
enviar mensagem para o Discord
Raulkubisds Sep 22, 2025
e4eacc7
Merge branch 'main' into discord
Raulkubisds Sep 22, 2025
0eabb0f
Ajustando CI-CD
Raulkubisds Sep 11, 2025
54dc0c9
Ajustando CI-CD
Raulkubisds Sep 11, 2025
ac956ba
Ajustando CI-CD 01
Raulkubisds Sep 11, 2025
8542380
Ajustando CI-CD 01
Raulkubisds Sep 11, 2025
f36b659
Adicionando workflow para pytest
Raulkubisds Sep 11, 2025
466dd14
Tentativa de correção do Pytest
Raulkubisds Sep 11, 2025
71a8bc0
Update python-app.yml
Raulkubisds Sep 11, 2025
06f9657
Create python-package.yml
Raulkubisds Sep 11, 2025
447a845
Delete .github/workflows directory
Raulkubisds Sep 11, 2025
ed2b8a0
Ajustando CI-CD 01
Raulkubisds Sep 11, 2025
558d9cb
Create pylint.yml
Raulkubisds Sep 13, 2025
35e8d09
Update pylint.yml
Raulkubisds Sep 14, 2025
85476d8
Tentando usar o Actions
Raulkubisds Sep 14, 2025
9c0d0fd
apagando pylint
Raulkubisds Sep 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/Discord.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Discord Alerts

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
discord:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Enviar alerta para o Discord
uses: tsickert/discord-webhook@v7.0.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
content: " Novo commit ou PR criado no repositório!"
38 changes: 38 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
2 changes: 0 additions & 2 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/devops-puc.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3

WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 80

CMD [ "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80" ]
8 changes: 5 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from fastapi import FastAPI
def test_passando():
assert True

app = FastAPI()
def test_read_root():
response = read_root()
assert response == {"hello": "world"}

@app.get("/")
def read_root():
return {"hello": "world"}
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fastapi==0.111.1
uvicorn[standard]

10 changes: 10 additions & 0 deletions test_01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# test_main.py

from main import read_root

def test_passando():
assert True

def test_read_root():
response = read_root()
assert response == {"hello": "world"}
10 changes: 10 additions & 0 deletions test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# test_main.py

from main import read_root

def test_passando():
assert True

def test_read_root():
response = read_root()
assert response == {"hello": "world"}
8 changes: 0 additions & 8 deletions teste_cicd.py

This file was deleted.

8 changes: 0 additions & 8 deletions teste_cicd01.py

This file was deleted.

46 changes: 46 additions & 0 deletions tests/test_01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Testes automatizados para o módulo main."""

from main import read_root


def test_passando():
"""Teste que sempre passa."""
assert True

def test_read_root():
"""Teste da função read_root()."""
response = read_root()
assert response == {"hello": "world"}

# tests/test_app.py

from fastapi.testclient import TestClient
from main import app

client = TestClient(app)

def test_root_message():
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"mensagem": "API funcionando no Docker!"}

def test_soma_positiva():
response = client.get("/soma/2/3")
assert response.status_code == 200
assert "resultado" in response.json()
assert response.json() == {"resultado": 5}

def test_soma_zero():
response = client.get("/soma/0/5")
assert response.status_code == 200
assert response.json()["resultado"] == 5

def test_soma_negativa():
response = client.get("/soma/-2/-3")
assert response.status_code == 200
assert response.json()["resultado"] == -5

def test_soma_valores_mistos():
response = client.get("/soma/-2/3")
assert response.status_code == 200
assert response.json()["resultado"] == 1