From 80909676aed5ab0c5df01caa18c073a6f49c3394 Mon Sep 17 00:00:00 2001 From: Suren Khorenyan Date: Thu, 18 Jan 2024 11:37:52 +0300 Subject: [PATCH] Codecov --- .github/workflows/testing.yml | 35 +++++++++++++++++++++++++++++------ README.md | 1 + codecov.yaml | 24 ++++++++++++++++++++++++ docs/index.rst | 4 ++++ 4 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 codecov.yaml diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 4d3c27a8..cd8a7706 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -2,12 +2,23 @@ name: Python testing on: push: -# pull_request: + branches: + - main + paths: + - ".github/workflows/testing.yml" + - "fastapi_jsonapi/**" + - "tests/**" + - "codecov.yaml" + - "pyproject.toml" + pull_request: + branches: + - main + paths: + - ".github/workflows/testing.yml" + - "fastapi_jsonapi/**" + - "tests/**" + - "pyproject.toml" -# is there a way to fix doubled pipelines? -# only XXX -# https://github.com/orgs/community/discussions/25654 -# https://github.com/orgs/community/discussions/26276 jobs: lint: @@ -16,6 +27,7 @@ jobs: matrix: python-version: - "3.9" + - "3.10" - "3.11" steps: @@ -79,6 +91,17 @@ jobs: - name: Install dependencies run: poetry install --all-extras - name: Test with pytest - run: pytest -s -vv tests/ + run: | + flags="-s -vv --cov=fastapi_jsonapi --cov-config .coveragerc --cov-report=xml" + pytest $flags tests/ env: TESTING_DB_URL: ${{ matrix.db-url }} + + - name: Upload coverage data to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.xml + flags: unittests + name: py-${{ matrix.python-version }}-db-${{ startsWith(matrix.db-url, 'sqlite') && 'sqlite' || startsWith(matrix.db-url, 'postgres') && 'postgres' || 'unknown' }} }} + fail_ci_if_error: true diff --git a/README.md b/README.md index 05075d5c..d53722cc 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![](https://img.shields.io/pypi/pyversions/FastAPI-JSONAPI?style=for-the-badge)](https://pypi.org/project/FastAPI-JSONAPI/) [![](https://img.shields.io/github/license/ycd/manage-fastapi?style=for-the-badge)](https://pypi.org/project/FastAPI-JSONAPI/) ![GitHub Actions](https://img.shields.io/github/actions/workflow/status/mts-ai/FastAPI-JSONAPI/testing.yml?style=for-the-badge) +[![codecov](https://codecov.io/gh/mts-ai/FastAPI-JSONAPI/graph/badge.svg?token=6K39IP2L0Z)](https://codecov.io/gh/mts-ai/FastAPI-JSONAPI) [![Read the Docs](https://img.shields.io/readthedocs/fastapi-jsonapi?style=for-the-badge)](https://fastapi-jsonapi.readthedocs.io/en/latest/) [![📖 Docs (gh-pages)](https://github.com/mts-ai/FastAPI-JSONAPI/actions/workflows/documentation.yaml/badge.svg)](https://mts-ai.github.io/FastAPI-JSONAPI/) diff --git a/codecov.yaml b/codecov.yaml new file mode 100644 index 00000000..fcde1e46 --- /dev/null +++ b/codecov.yaml @@ -0,0 +1,24 @@ +codecov: + require_ci_to_pass: yes + branch: main + +coverage: + precision: 2 + round: down + range: "90..100" + +parsers: + gcov: + branch_detection: + conditional: yes + loop: yes + method: no + macro: no + +comment: + layout: "reach,diff,flags,tree" + behavior: default + require_changes: no + branches: + - main + after_n_builds: 6 # 3 python versions by 2 dbs diff --git a/docs/index.rst b/docs/index.rst index d4566fd0..04d59490 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,6 +12,10 @@ FastAPI-JSONAPI :alt: GitHub :target: https://github.com/mts-ai/FastAPI-JSONAPI +.. image:: https://codecov.io/gh/mts-ai/FastAPI-JSONAPI/graph/badge.svg?token=6K39IP2L0Z + :alt: Codecov + :target: https://codecov.io/gh/mts-ai/FastAPI-JSONAPI + **FastAPI-JSONAPI** is an extension for FastAPI that adds support for quickly building REST APIs with huge flexibility around the JSON:API 1.0 specification.