Add workflow for code coverage

This commit is contained in:
sigma67 2020-05-19 17:40:15 +02:00
commit b94f5f02e3
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0
5 changed files with 40 additions and 24 deletions

35
.github/workflows/coverage.yml vendored Normal file
View file

@ -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

View file

@ -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

View file

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="99" height="20">
<linearGradient id="b" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<mask id="a">
<rect width="99" height="20" rx="3" fill="#fff"/>
</mask>
<g mask="url(#a)">
<path fill="#555" d="M0 0h63v20H0z"/>
<path fill="#4c1" d="M63 0h36v20H63z"/>
<path fill="url(#b)" d="M0 0h99v20H0z"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
<text x="31.5" y="14">coverage</text>
<text x="80" y="15" fill="#010101" fill-opacity=".3">96%</text>
<text x="80" y="14">96%</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 901 B

View file

@ -1,5 +1,7 @@
import unittest
import configparser
import sys
sys.path.insert(0, '..')
from ytmusicapi.ytmusic import YTMusic
config = configparser.RawConfigParser()

View file

@ -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: