From 00adb6c6584bc533b661fd3b7cdc7e9d97d806a8 Mon Sep 17 00:00:00 2001 From: 14655837 Date: Tue, 24 Feb 2026 20:31:36 +0100 Subject: [PATCH 1/2] Add amazing feature --- addment.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 addment.txt diff --git a/addment.txt b/addment.txt new file mode 100644 index 0000000..e69de29 From e37a2e779b1ddddbfcb5d2d27a570b6cea0e0b13 Mon Sep 17 00:00:00 2001 From: 14655837 Date: Fri, 6 Mar 2026 16:28:46 +0100 Subject: [PATCH 2/2] exercises --- .github/workflows/ci-cd.yml | 45 ++++++++++++++++++++++++++++++++++++- .pre-commit-config.yaml | 8 +++++++ app/main.py | 9 ++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a98b15e..39d360c 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -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 @@ -28,6 +34,20 @@ 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 @@ -35,8 +55,31 @@ jobs: 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 }} \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d337d10..5b162e9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 \ No newline at end of file diff --git a/app/main.py b/app/main.py index ae8adc6..aa0cbba 100644 --- a/app/main.py +++ b/app/main.py @@ -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)