From 5a75caaa0e8d7531e2128d9a0d054389826cfa2a Mon Sep 17 00:00:00 2001 From: kikomiguelmendes Date: Sat, 7 Mar 2026 15:36:32 +0100 Subject: [PATCH 1/4] Add amazing feature --- .idea/.gitignore | 10 +++++++++ .idea/fastapi-gitops.iml | 21 +++++++++++++++++++ .../inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 7 +++++++ .idea/modules.xml | 8 +++++++ .idea/vcs.xml | 6 ++++++ app/main.py | 1 + 7 files changed, 59 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/fastapi-gitops.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/fastapi-gitops.iml b/.idea/fastapi-gitops.iml new file mode 100644 index 0000000..763b4f3 --- /dev/null +++ b/.idea/fastapi-gitops.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6341f53 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f954136 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/main.py b/app/main.py index ae8adc6..6da7e4b 100644 --- a/app/main.py +++ b/app/main.py @@ -51,3 +51,4 @@ async def get_item(item_id: int): if __name__ == "__main__": uvicorn.run(app, host="0.0.0.0", port=8000) + # comment for the commit From c2d4a07b1f9aa878e032438149b52174ad8a21bd Mon Sep 17 00:00:00 2001 From: kikomiguelmendes Date: Sat, 7 Mar 2026 15:54:46 +0100 Subject: [PATCH 2/4] 3.3 --- .github/workflows/ci-cd.yml | 47 +++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 23 ++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a98b15e..61e2748 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -19,6 +19,17 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install Ruff + run: pip install ruff + + - name: Lint with Ruff + run: ruff check . + test: name: Run Tests runs-on: ubuntu-latest @@ -28,6 +39,17 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Run tests with coverage + run: pytest --cov=app --cov-fail-under=80 + build: name: Build Docker Image runs-on: ubuntu-latest @@ -40,3 +62,28 @@ jobs: 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 metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=latest,enable=${{ github.event_name == 'release' }} + type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }} + type=sha,enable=${{ github.event_name == 'push' }} + + - name: Build Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: docker/Dockerfile + push: ${{ github.event_name == 'release' }} + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d337d10..2e58bfc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,3 +3,26 @@ repos: rev: v5.0.0 hooks: - id: trailing-whitespace + - id: check-added-large-files # Prevent committing large files + - id: check-yaml # Check YAML syntax (excluding Helm charts) + exclude: ^helm/ + + - repo: https://github.com/pycqa/isort # Sort imports in Python files + rev: 5.13.2 + hooks: + - id: isort + + - repo: https://github.com/PyCQA/bandit # Check for security issues + rev: 1.7.10 + hooks: + - id: bandit + + - repo: https://github.com/Yelp/detect-secrets # Prevent committing secrets + rev: v1.5.0 + hooks: + - id: detect-secrets + + - repo: https://github.com/astral-sh/ruff-pre-commit # Check code style + rev: v0.8.6 + hooks: + - id: ruff \ No newline at end of file From fb774883b398dab16febf69cf10b1f61f75159f1 Mon Sep 17 00:00:00 2001 From: kikomiguelmendes Date: Sat, 7 Mar 2026 16:05:48 +0100 Subject: [PATCH 3/4] test --- .pre-commit-config.yaml | 1 + app/main.py | 11 ++++++++++- tests/test_main.py | 9 +++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e58bfc..971d7a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,7 @@ repos: rev: 1.7.10 hooks: - id: bandit + args: ["--exclude", "tests"] - repo: https://github.com/Yelp/detect-secrets # Prevent committing secrets rev: v1.5.0 diff --git a/app/main.py b/app/main.py index 6da7e4b..4294526 100644 --- a/app/main.py +++ b/app/main.py @@ -48,7 +48,16 @@ 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) + uvicorn.run(app, host="0.0.0.0", port=8000) # nosec B104 # comment for the commit diff --git a/tests/test_main.py b/tests/test_main.py index db89e2f..dd6b519 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -41,3 +41,12 @@ def test_get_item(): assert data["id"] == 5 assert data["name"] == "Item 5" assert "item number 5" in data["description"] + +def test_create_item(): + response = client.post("/api/items?name=TestItem&description=TestDescription") + assert response.status_code == 200 + data = response.json() + assert data["name"] == "TestItem" + assert data["description"] == "TestDescription" + assert data["created"] is True + assert "id" in data From 80095ddfd5b3710ca9c431179c6e217817e41e79 Mon Sep 17 00:00:00 2001 From: kikomiguelmendes Date: Sat, 7 Mar 2026 17:45:09 +0100 Subject: [PATCH 4/4] 3.4 --- .idea/jsonSchemas.xml | 27 +++++++++++++++++++ .pre-commit-config.yaml | 12 ++++----- .../fastapi-gitops-starter/custom-values.yaml | 24 +++++++++++++++++ 3 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 .idea/jsonSchemas.xml create mode 100644 helm/fastapi-gitops-starter/custom-values.yaml diff --git a/.idea/jsonSchemas.xml b/.idea/jsonSchemas.xml new file mode 100644 index 0000000..b7636c2 --- /dev/null +++ b/.idea/jsonSchemas.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 971d7a5..db556b9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,27 +3,27 @@ repos: rev: v5.0.0 hooks: - id: trailing-whitespace - - id: check-added-large-files # Prevent committing large files - - id: check-yaml # Check YAML syntax (excluding Helm charts) + - id: check-added-large-files + - id: check-yaml exclude: ^helm/ - - repo: https://github.com/pycqa/isort # Sort imports in Python files + - repo: https://github.com/pycqa/isort rev: 5.13.2 hooks: - id: isort - - repo: https://github.com/PyCQA/bandit # Check for security issues + - repo: https://github.com/PyCQA/bandit rev: 1.7.10 hooks: - id: bandit args: ["--exclude", "tests"] - - repo: https://github.com/Yelp/detect-secrets # Prevent committing secrets + - repo: https://github.com/Yelp/detect-secrets rev: v1.5.0 hooks: - id: detect-secrets - - repo: https://github.com/astral-sh/ruff-pre-commit # Check code style + - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.8.6 hooks: - id: ruff \ No newline at end of file diff --git a/helm/fastapi-gitops-starter/custom-values.yaml b/helm/fastapi-gitops-starter/custom-values.yaml new file mode 100644 index 0000000..7bdb34f --- /dev/null +++ b/helm/fastapi-gitops-starter/custom-values.yaml @@ -0,0 +1,24 @@ +image: + repository: ghcr.io/kikomiguelmendes/do_2_f + tag: "latest" + pullPolicy: IfNotPresent + +imagePullSecrets: [] + +registry: + createImagePullSecret: false + +ingress: + enabled: true + className: nginx + hosts: + - host: minikube.test + paths: + - path: /GitOps-Starter + pathType: Prefix + +autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 10 + targetCPUUtilizationPercentage: 10 \ No newline at end of file