Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy
run-name: Running Deploy for ${{ github.ref }} on ${{ github.event_name }} event
on:
push:
branches:
- main
jobs:

push-to-registry:
runs-on: ubuntu-latest
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ vars.DOCKERHUB_USERNAME }}/simple-service:latest

deploy:
needs: push-to-registry
runs-on: ubuntu-latest
steps:
- name: Deploy latest image tag in Render
run: curl "${{ secrets.DEPLOY_WEBHOOK_URL }}&imgURL=docker.io%2F${{ vars.DOCKERHUB_USERNAME }}%2Fsimple-service%3Alatest"
44 changes: 44 additions & 0 deletions .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Formatter
run-name: Running formatter check for ${{ github.ref }} on ${{ github.event_name }} event

on:
push:
branches:
- main
- "feature/**"
pull_request:
branches:
- main

jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install dependencies
run: uv sync

- name: Check code formatting with Ruff
run: uv run ruff format --check

- name: Format code with Ruff
if: failure()
run: uv run ruff format

- name: Commit formatted changes (if needed)
if: failure()
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "style: format code with Ruff"
commit_options: "--no-verify"
file_pattern: "**/*.py"
31 changes: 31 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Unit_Testing_Check
run-name: Testing branch ${{ github.ref_name }}

on:
pull_request:
branches:
- main
workflow_call:

jobs:
run-tests:
name: Execute Pytest
runs-on: ubuntu-latest

steps:
- name: Checkout del código
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install dependencies
run: uv sync

- name: Ejecutar Pruebas Unitarias
run: uv run pytest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ ipython_config.py
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
uv.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
Expand Down
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.6
hooks:
- id: ruff
name: ruff lint
args: [--fix]
- id: ruff-format
name: ruff format

- repo: local
hooks:
- id: pyright
name: pyright
language: system
entry: uv run pyright
types: [python]
pass_filenames: false

- id: pytest
name: pytest
language: system
entry: uv run pytest
types: [python]
pass_filenames: false
22 changes: 7 additions & 15 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,19 @@
from app.application.get_dice_roll import get_dice_roll












def create_app() -> FastAPI:
app = FastAPI()

app.add_api_route(path="/", endpoint=lambda: RedirectResponse(app.url_path_for(get_dice_roll.__name__)), methods=["GET"], include_in_schema=False,)

app.add_api_route(
path="/dice/roll",
endpoint=get_dice_roll
path="/",
endpoint=lambda: RedirectResponse(app.url_path_for(get_dice_roll.__name__)),
methods=["GET"],
include_in_schema=False,
)

app.add_api_route(path="/dice/roll", endpoint=get_dice_roll)

return app


app = create_app()
app = create_app()
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies = [

[dependency-groups]
dev = [
"pre-commit>=4.5.1",
"pyright>=1.1.394",
"pytest>=8.3.4",
"ruff>=0.9.6",
Expand Down
Loading