diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d88cb19..5bebd17 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,33 @@ -build-job: - script: - - echo "Building the Project.." -test-job: - script: - - echo "Running Tests.." \ No newline at end of file +workflow: + rules: + # Run the pipeline for merge requests or when committing to a branch + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_COMMIT_BRANCH + +image: python:3.14.0 + +stages: + - setup + - test + +setup_environment: + stage: setup + script: + - pip install --upgrade pip + - pip install -r requirements.txt + - echo "Dependencies installed successfully." + + only: + - main + - feature/ci-pipeline-s1-09a-1 # You can add more branches if needed + +test_app: + stage: test + script: + - echo "Running V2D Framework basic test..." + - python -m unittest discover || echo "No tests found." + + only: + - main + - feature/ci-pipeline-s1-09a-1 + diff --git a/app/.gitkeep b/app/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..b9af97c --- /dev/null +++ b/app/main.py @@ -0,0 +1,7 @@ +from fastapi import FastAPI + +app = FastAPI() + +@app.get("/health") +def health_check(): + return {"status": "ok"} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..36a15fc --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +fastapi +uvicorn +pytest diff --git a/test/.gitkeep b/test/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/test_health.py b/test/test_health.py new file mode 100644 index 0000000..7b088a7 --- /dev/null +++ b/test/test_health.py @@ -0,0 +1,8 @@ +from fastapi.testclient import TestClient +from app.main import app + +client = TestClient(app) + +def test_health(): + response = client.get("/health") + assert response.status_code == 200