From 790c9b842991284cb99d86275430937a55897476 Mon Sep 17 00:00:00 2001 From: Aditya Ghyar Date: Mon, 29 Jun 2026 16:15:12 +0530 Subject: [PATCH 1/3] ci: add GitHub Actions workflow --- .dockerignore | 11 +++++++ .github/workflows/ci.yml | 66 ++++++++++++++++++++++++++++++++++++++++ Dockerfile | 21 +++++++++++++ docker-compose.yml | 26 ++++++++++++++++ docs/pipeline.md | 24 +++++++++++++++ requirements-dev.txt | 5 +++ requirements.txt | 12 +++----- 7 files changed, 157 insertions(+), 8 deletions(-) create mode 100644 .dockerignore create mode 100644 docs/pipeline.md create mode 100644 requirements-dev.txt diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..76bfd39 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.git +.github +venv +__pycache__ +.pytest_cache +tests +htmlcov +.coverage +.env +docs +*.pyc \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e69de29..12029b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -0,0 +1,66 @@ +name: TaskTracker CI + +on: + push: + branches: + - main + - develop + - feature/** + pull_request: + branches: + - main + - develop + +jobs: + test: + + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:16 + + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: tasktracker + + ports: + - 5432:5432 + + options: >- + --health-cmd="pg_isready -U postgres" + --health-interval=10s + --health-timeout=5s + --health-retries=5 + + env: + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/tasktracker + APP_PORT: 8000 + LOG_LEVEL: INFO + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run Tests + run: | + pytest -v + + - name: Generate Coverage Report + run: | + pytest --cov=app --cov-report=term-missing + + - name: Build Docker Image + run: | + docker build -t tasktracker:latest . \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e69de29..a6bbfa5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.12.10-slim-bookworm AS builder + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir --prefix=/install -r requirements.txt + +FROM python:3.12.10-slim-bookworm + +RUN useradd -m app + +WORKDIR /app + +COPY --from=builder /install /usr/local +COPY app ./app + +USER app + +EXPOSE 8000 + +CMD ["uvicorn","app.main:app","--host","0.0.0.0","--port","8000"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e69de29..e96c888 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -0,0 +1,26 @@ +version: "3.9" + +services: + + postgres: + image: postgres:16 + container_name: tasktracker-postgres + restart: always + environment: + POSTGRES_DB: tasktracker + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - "5432:5432" + + api: + build: . + container_name: tasktracker-api + depends_on: + - postgres + environment: + DATABASE_URL: postgresql://postgres:postgres@postgres:5432/tasktracker + APP_PORT: 8000 + LOG_LEVEL: INFO + ports: + - "8000:8000" \ No newline at end of file diff --git a/docs/pipeline.md b/docs/pipeline.md new file mode 100644 index 0000000..dae6608 --- /dev/null +++ b/docs/pipeline.md @@ -0,0 +1,24 @@ +# CI/CD Pipeline Documentation + +## Overview + +The TaskTracker project uses GitHub Actions for Continuous Integration. + +Pipeline executes automatically on: + +- Push to feature branches +- Push to develop +- Push to main +- Pull Requests + +--- + +## Pipeline Stages + +### 1. Checkout + +Downloads repository source code. + +```yaml +uses: actions/checkout@v4 +``` \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..ecb310f --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,5 @@ +-r requirements.txt + +pytest +pytest-cov +httpx \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index bd51310..379c7e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,9 @@ -fastapi -uvicorn -sqlalchemy +fastapi==0.116.1 +uvicorn==0.35.0 +sqlalchemy==2.0.41 psycopg2-binary pydantic pydantic-settings python-dotenv email-validator -pytest -pytest-cov -alembic -pytest -httpx \ No newline at end of file +alembic \ No newline at end of file From 75252e0c4808cdc06b63cbdd04cbccf54ccd51c1 Mon Sep 17 00:00:00 2001 From: Aditya Ghyar Date: Tue, 7 Jul 2026 16:47:33 +0530 Subject: [PATCH 2/3] ci: update requirement.txt --- requirements.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 379c7e8..4bcdcb3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,6 @@ pydantic pydantic-settings python-dotenv email-validator -alembic \ No newline at end of file +alembic +pytest-cov +pytest \ No newline at end of file From b8b91fbde1b472228e5b7f803ccc11e5d8d46f2d Mon Sep 17 00:00:00 2001 From: Aditya Ghyar Date: Tue, 7 Jul 2026 16:49:24 +0530 Subject: [PATCH 3/3] ci: update requirement.txt --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4bcdcb3..c72d4a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,5 @@ python-dotenv email-validator alembic pytest-cov -pytest \ No newline at end of file +pytest +httpx \ No newline at end of file