From 14bcaa24e6ff88045f7e3f1fbe21128b232579bb Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Tue, 19 Jan 2021 00:21:50 +0000 Subject: [PATCH 1/2] tweak actions and add coverage --- .coveragerc | 9 +++++++++ .github/workflows/testing.yml | 28 ++++++++++++++++++++++++---- Makefile | 4 ++-- requirements.txt | 7 +++++++ 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 .coveragerc create mode 100644 requirements.txt diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..c25bdcf --- /dev/null +++ b/.coveragerc @@ -0,0 +1,9 @@ + +# Docs: https://coverage.readthedocs.org/en/latest/config.html + +[run] +branch = False + +# If True, stores relative file paths in data file (needed for Github Actions). +# Using this parameter requires coverage>=5.0 +relative_files = True diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index a1a1435..12d3309 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -32,16 +32,36 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Python Env - uses: actions/setup-python@v2.1.4 # FIXME: Use "v2" tag once https://github.com/actions/setup-python/issues/171 is resolved. + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Display Python version run: python -c "import sys; print(sys.version)" - name: Install dependencies run: | - pip install pytest==3.2.1 pytest-cov==2.5.1 + make init - name: Run Tests + run: | + make test + - name: Upload to Coveralls env: - PYTHONHASHSEED: "0" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_PARALLEL: true + COVERALLS_FLAG_NAME: "${{ matrix.os }}_${{ matrix.python-version }}" run: | - pytest --cov=vpk tests + coveralls --service=github + + coveralls: + name: Finish Coveralls + needs: test + runs-on: ubuntu-latest + container: python:3-slim + steps: + - name: Install coveralls + run: | + pip3 install --upgrade coveralls + - name: Send coverage finish to coveralls.io + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + coveralls --finish diff --git a/Makefile b/Makefile index 92cfb21..702c277 100644 --- a/Makefile +++ b/Makefile @@ -16,11 +16,11 @@ help: @echo "$$HELPBODY" init: - pip install pytest==3.2.1 pytest-cov==2.5.1 + pip install -r requirements.txt test: rm -f .coverage vpk/*.pyc tests/*.pyc - PYTHONHASHSEED=0 pytest --cov=vpk tests + PYTHONHASHSEED=0 pytest --tb=short --cov-config .coveragerc --cov=vpk tests pylint: pylint -r n -f colorized vpk || true diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..236b8e0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ + +coverage>=5.0; python_version == '2.7' or python_version >= '3.5' +pytest-cov>=2.7.0; python_version == '2.7' or python_version >= '3.5' + +# coveralls 2.0 has removed support for Python 2.7 and 3.4 +git+https://github.com/andy-maier/coveralls-python.git@andy/add-py27#egg=coveralls; python_version == '2.7' +coveralls>=2.1.2; python_version >= '3.5' From a5a47bf83ef9142992e80b97a99c64f2a6b064f1 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Tue, 19 Jan 2021 00:27:30 +0000 Subject: [PATCH 2/2] add coverage badge --- README.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index e0d171e..5a975b3 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -| |pypi| |license| |master_build| +| |pypi| |license| |coverage| |master_build| | |sonar_maintainability| |sonar_reliability| |sonar_security| VPK is Valve's file format for storing game assets. @@ -124,6 +124,10 @@ Check out https://github.com/SteamDatabase/ValveResourceFormat/ :target: https://pypi.python.org/pypi/vpk :alt: MIT License +.. |coverage| image:: https://img.shields.io/coveralls/ValvePython/vpk/master.svg?style=flat + :target: https://coveralls.io/r/ValvePython/vpk?branch=master + :alt: Test coverage + .. |master_build| image:: https://github.com/ValvePython/vpk/workflows/Tests/badge.svg?branch=master :target: https://github.com/ValvePython/vpk/actions?query=workflow%3A%22Tests%22+branch%3Amaster :alt: Build status of master branch