diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..f9e95f3 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,35 @@ +name: Code coverage + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Setup Python + uses: actions/setup-python@master + with: + python-version: 3.7 + - name: Generate coverage report + env: + HEADERS_AUTH: ${{ secrets.HEADERS_AUTH }} + TEST_CFG: ${{ secrets.TEST_CFG }} + run: | + pip install -e . + pip install coverage + cd tests + curl -o test.mp3 https://www.kozco.com/tech/piano2-CoolEdit.mp3 + cat <<< "$HEADERS_AUTH" > headers_auth.json + cat <<< "$TEST_CFG" > test.cfg + coverage run --source=../ytmusicapi -m unittest test.py + coverage xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + file: tests/coverage.xml + flags: unittests + fail_ci_if_error: true diff --git a/README.rst b/README.rst index 49678e6..7c4736d 100644 --- a/README.rst +++ b/README.rst @@ -5,9 +5,9 @@ ytmusicapi: Unofficial API for YouTube Music :alt: PyPI Downloads :target: https://pypi.org/project/ytmusicapi/ -.. image:: https://raw.githubusercontent.com/sigma67/ytmusicapi/master/tests/coverage.svg +.. image:: https://img.shields.io/codecov/c/github/sigma67/ytmusicapi?style=flat-square :alt: Code coverage - :target: https://github.com/dbrgn/coverage-badge + :target: https://codecov.io/gh/sigma67/ytmusicapi .. image:: https://img.shields.io/github/v/release/sigma67/ytmusicapi?style=flat-square :alt: Latest release diff --git a/tests/coverage.svg b/tests/coverage.svg deleted file mode 100644 index ee07d4c..0000000 --- a/tests/coverage.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - coverage - coverage - 96% - 96% - - diff --git a/tests/test.py b/tests/test.py index 5495e38..e22b614 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,5 +1,7 @@ import unittest import configparser +import sys +sys.path.insert(0, '..') from ytmusicapi.ytmusic import YTMusic config = configparser.RawConfigParser() diff --git a/ytmusicapi/setup.py b/ytmusicapi/setup.py index e8ab731..23a5f43 100644 --- a/ytmusicapi/setup.py +++ b/ytmusicapi/setup.py @@ -18,7 +18,7 @@ def setup(filepath=None, headers_raw=None): break contents.append(line) else: - contents = input.split('\n') + contents = headers_raw.split('\n') required_headers = ["Cookie"] try: