From 25be06684eb0a6ee6b3c3056034d9d94954919f0 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Thu, 11 Apr 2024 20:02:46 +0200 Subject: [PATCH] Tests coverage --- .github/workflows/test.yaml | 23 ++++++++++++++++++++++- README.md | 4 ++-- requirements.dev.txt | 2 ++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3efce56..b1f7d50 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 # required for codecov - name: Login to Docker Hub uses: docker/login-action@v3 @@ -21,5 +22,25 @@ jobs: - name: Pull Docker image run: docker pull mjbourgeon/fastdocx-api:latest + - name: Run container in detached mode + run: docker run -d --name fastdocxapi mjbourgeon/fastdocx-api sleep infinity + + - name: Install dependencies + run: docker exec $(docker ps -aqf "name=fastdocxapi") pip install -r requirements.dev.txt + - name: Run tests - run: docker run --rm mjbourgeon/fastdocx-api /bin/bash -c "pip install -r requirements.dev.txt ; pytest -v app/" \ No newline at end of file + run: docker exec $(docker ps -aqf "name=fastdocxapi") pytest --cov=app/ app/ --cov-report=xml + + - name: Copy coverage file before upload + run: docker cp $(docker ps -aqf "name=fastdocxapi"):/coverage.xml . + + - name: Cleanup + run: docker stop fastdocxapi && docker rm fastdocxapi + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.xml + disable_search: true + verbose: true diff --git a/README.md b/README.md index a77e874..cb93413 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/) [![typedlib_mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://www.mypy-lang.org) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) +![GitHub Actions Workflow Status](https://github.com/mbging/fastdocx-api/actions/workflows/lint.yaml/badge.svg) ![GitHub Actions Workflow Status](https://github.com/mbging/fastdocx-api/actions/workflows/docker-hub.yaml/badge.svg) ![GitHub Actions Workflow Status](https://github.com/mbging/fastdocx-api/actions/workflows/test.yaml/badge.svg) -![GitHub Actions Workflow Status](https://github.com/mbging/fastdocx-api/actions/workflows/lint.yaml/badge.svg) - +[![codecov](https://codecov.io/gh/mbging/fastdocx-api/graph/badge.svg?token=3FSG83E16C)](https://codecov.io/gh/mbging/fastdocx-api) A FastAPI based project to generate DOCX and PDF documents from a DOCX template, JSON data and images. diff --git a/requirements.dev.txt b/requirements.dev.txt index df5fc2e..1f8af6e 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -1,5 +1,6 @@ certifi==2024.2.2 click==8.1.7 +coverage==7.4.4 h11==0.14.0 httpcore==1.0.5 httpx==0.27.0 @@ -10,6 +11,7 @@ packaging==24.0 pluggy==1.4.0 pytest==8.1.1 pytest-asyncio==0.23.6 +pytest-cov==5.0.0 python-dotenv==1.0.1 python-multipart==0.0.9 ruff==0.3.5