From 0bffdae0d4eb57c3f1cc3446e2012f9d1ac31cce Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Mon, 30 Oct 2023 18:56:32 +0100 Subject: [PATCH] add code coverage test --- .coveragerc | 2 +- .github/workflows/coverage.yml | 46 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.coveragerc b/.coveragerc index bab7141..849afb5 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,7 +2,7 @@ plugins = Cython.Coverage source = src omit = - src/cpp_common.pxd + src/rapidfuzz/cpp_common.pxd [precision] show_missing = true diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..2ca01ee --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,46 @@ +name: Coverage of Test Build + +on: + push: + paths-ignore: + - 'docs/**' + +jobs: + tests: + name: "Generate coverage report for tests" + runs-on: ubuntu-latest + steps: + - uses: "actions/checkout@v3" + with: + submodules: 'true' + - uses: "actions/setup-python@v4" + with: + python-version: "3.11" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest hypothesis pandas coverage cython + + - name: Generate cython + run: | + chmod +x ./src/rapidfuzz/generate.sh + ./src/rapidfuzz/generate.sh + + # for cython tests inplace installation is required + - name: build + run: CXXFLAGS=-DCYTHON_TRACE_NOGIL=1 pip install -e . -v + + - name: Test with pytest and generate coverage info + run: | + PYTHONPATH=$(pwd)/src coverage run -m pytest tests + coverage xml + coverage report + + - uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.xml + flags: unittests + fail_ci_if_error: true + verbose: true