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
45 changes: 44 additions & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Ruff
run: pip install ruff

- name: Lint with Ruff
run: ruff check .

test:
name: Run Tests
runs-on: ubuntu-latest
Expand All @@ -28,15 +34,52 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
pip install pytest pytest-cov
pip install -r requirements.txt # If you have one

- name: Run tests with coverage
run: |
pytest --cov=. --cov-fail-under=80

build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [lint, test]
if: github.event_name == 'push' || github.event_name == 'release'
permissions:
contents: read
actions: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ github.event_name == 'release' }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ repos:
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
args: ['--maxkb=150']
- id: check-yaml
exclude: helm
- id: sort-pythom
- id: check-security
- id: detect-private-key
- id: check-style
Empty file added addment.txt
Empty file.
9 changes: 9 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ async def get_item(item_id: int):
"description": f"This is item number {item_id}",
}

@app.post("/api/items")
async def create_item(name: str, description: str):
"""Create a new item."""
return {
"id": 999,
"name": name,
"description": description,
"created": True
}

if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)