Cleanup CI test (#72)
This commit is contained in:
parent
1140b9b07a
commit
7ad56fbca2
46
.github/workflows/addon-check.yml
vendored
46
.github/workflows/addon-check.yml
vendored
@ -1,39 +1,27 @@
|
|||||||
name: Kodi
|
name: Kodi
|
||||||
on:
|
on:
|
||||||
- pull_request
|
# Run action when pushed to master, or for commits in a pull request.
|
||||||
- push
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
kodi-addon-checker:
|
||||||
name: Addon checker
|
name: Addon checker
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
kodi-branch: [leia, matrix]
|
kodi-version: [ leia, matrix ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Check out ${{ github.sha }} from repository ${{ github.repository }}
|
||||||
with:
|
uses: actions/checkout@v2
|
||||||
path: ${{ github.repository }}
|
|
||||||
- name: Set up Python 3.8
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: 3.8
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get install xmlstarlet
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
# FIXME: Requires changes from xbmc/addon-check#217
|
|
||||||
#pip install kodi-addon-checker
|
|
||||||
pip install git+git://github.com/xbmc/addon-check.git@master
|
|
||||||
- name: Remove unwanted files
|
|
||||||
run: awk '/export-ignore/ { print $1 }' .gitattributes | xargs rm -rf --
|
|
||||||
working-directory: ${{ github.repository }}
|
|
||||||
- name: Rewrite addon.xml for Matrix
|
|
||||||
run: |
|
|
||||||
xmlstarlet ed -L -u '/addon/requires/import[@addon="xbmc.python"]/@version' -v "3.0.0" addon.xml
|
|
||||||
version=$(xmlstarlet sel -t -v 'string(/addon/@version)' addon.xml)
|
|
||||||
xmlstarlet ed -L -u '/addon/@version' -v "${version}+matrix.99" addon.xml
|
|
||||||
working-directory: ${{ github.repository }}
|
|
||||||
if: matrix.kodi-branch == 'matrix'
|
|
||||||
- name: Run kodi-addon-checker
|
- name: Run kodi-addon-checker
|
||||||
run: kodi-addon-checker --branch=${{ matrix.kodi-branch }} ${{ github.repository }}/
|
uses: xbmc/action-kodi-addon-checker@v1.2
|
||||||
|
with:
|
||||||
|
kodi-version: ${{ matrix.kodi-version }}
|
||||||
|
rewrite-for-matrix: true
|
||||||
|
addon-id: ${{ github.event.repository.name }}
|
58
.github/workflows/ci.yml
vendored
58
.github/workflows/ci.yml
vendored
@ -1,26 +1,27 @@
|
|||||||
name: CI
|
name: CI
|
||||||
on:
|
on:
|
||||||
- pull_request
|
# Run action when pushed to master, or for commits in a pull request.
|
||||||
- push
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
name: Add-on testing
|
name: Add-on testing
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
env:
|
|
||||||
PYTHONIOENCODING: utf-8
|
|
||||||
PYTHONPATH: ${{ github.workspace }}/resources/lib
|
|
||||||
KODI_HOME: ${{ github.workspace }}/tests/home
|
|
||||||
KODI_INTERACTIVE: 0
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ ubuntu-latest ]
|
os: [ ubuntu-latest ]
|
||||||
python-version: [ 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 ]
|
python-version: [ 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 ]
|
||||||
include:
|
include:
|
||||||
# Kodi Leia on Windows uses a bundled Python 2.7
|
# Kodi Leia on Windows uses a bundled Python 2.7.
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
python-version: 2.7
|
python-version: 2.7
|
||||||
# Kodi Matrix on Windows uses a bundled Python 3.8
|
|
||||||
|
# Kodi Matrix on Windows uses a bundled Python 3.8, but we test 3.9 also to be sure.
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
python-version: 3.8
|
python-version: 3.8
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
@ -28,36 +29,39 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Check out ${{ github.sha }} from repository ${{ github.repository }}
|
- name: Check out ${{ github.sha }} from repository ${{ github.repository }}
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v1
|
uses: actions/setup-python@v1
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies (linux)
|
|
||||||
if: matrix.os == 'ubuntu-latest'
|
|
||||||
run: |
|
|
||||||
sudo apt-get install gettext
|
|
||||||
sudo pip install coverage --install-option="--install-scripts=/usr/bin"
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: pip install -r requirements.txt
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -r requirements.txt
|
|
||||||
- name: Run pylint
|
- name: Run pylint
|
||||||
run: make check-pylint
|
run: make check-pylint
|
||||||
|
|
||||||
- name: Check translations
|
- name: Check translations
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
|
||||||
run: make check-translations
|
run: sudo apt-get install gettext && make check-translations
|
||||||
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: coverage run -m unittest discover
|
|
||||||
env:
|
env:
|
||||||
ADDON_PASSWORD: ${{ secrets.ADDON_PASSWORD }}
|
|
||||||
ADDON_USERNAME: ${{ secrets.ADDON_USERNAME }}
|
ADDON_USERNAME: ${{ secrets.ADDON_USERNAME }}
|
||||||
- name: Run addon service for 10 seconds
|
|
||||||
if: matrix.os == 'ubuntu-latest'
|
|
||||||
run: timeout --preserve-status -s SIGINT 10 coverage run -a service_entry.py
|
|
||||||
env:
|
|
||||||
ADDON_PASSWORD: ${{ secrets.ADDON_PASSWORD }}
|
ADDON_PASSWORD: ${{ secrets.ADDON_PASSWORD }}
|
||||||
ADDON_USERNAME: ${{ secrets.ADDON_USERNAME }}
|
PYTHONIOENCODING: utf-8
|
||||||
|
KODI_HOME: ${{ github.workspace }}/tests/home
|
||||||
|
KODI_INTERACTIVE: 0
|
||||||
|
KODI_STUB_RPC_RESPONSES: ${{ github.workspace }}/tests/rpc
|
||||||
|
HTTP_PROXY: ${{ secrets.HTTP_PROXY }}
|
||||||
|
run: pytest -v --cov=./ --cov-report=xml tests
|
||||||
|
|
||||||
- name: Upload code coverage to CodeCov
|
- name: Upload code coverage to CodeCov
|
||||||
if: matrix.os == 'ubuntu-latest'
|
|
||||||
uses: codecov/codecov-action@v1
|
uses: codecov/codecov-action@v1
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
env:
|
||||||
|
OS: ${{ matrix.os }}
|
||||||
|
PYTHON: ${{ matrix.python-version }}
|
||||||
|
with:
|
||||||
|
flags: unittests
|
||||||
|
env_vars: OS,PYTHON
|
@ -1,7 +1,8 @@
|
|||||||
coverage
|
|
||||||
polib
|
polib
|
||||||
pylint
|
pylint
|
||||||
pytest
|
pytest
|
||||||
|
pytest-cov
|
||||||
|
pytest-timeout
|
||||||
python-dateutil
|
python-dateutil
|
||||||
requests
|
requests
|
||||||
git+git://github.com/dagwieers/kodi-plugin-routing.git@setup#egg=routing
|
git+git://github.com/dagwieers/kodi-plugin-routing.git@setup#egg=routing
|
||||||
|
@ -9,7 +9,6 @@ from routing import Plugin
|
|||||||
|
|
||||||
from resources.lib import kodilogging
|
from resources.lib import kodilogging
|
||||||
|
|
||||||
kodilogging.config()
|
|
||||||
routing = Plugin() # pylint: disable=invalid-name
|
routing = Plugin() # pylint: disable=invalid-name
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -190,4 +189,5 @@ def iptv_epg():
|
|||||||
|
|
||||||
def run(params):
|
def run(params):
|
||||||
""" Run the routing plugin """
|
""" Run the routing plugin """
|
||||||
|
kodilogging.config()
|
||||||
routing.run(params)
|
routing.run(params)
|
||||||
|
@ -13,7 +13,6 @@ from xbmc import Monitor, Player, getInfoLabel
|
|||||||
from resources.lib import kodilogging, kodiutils
|
from resources.lib import kodilogging, kodiutils
|
||||||
from resources.lib.viervijfzes.auth import AuthApi
|
from resources.lib.viervijfzes.auth import AuthApi
|
||||||
|
|
||||||
kodilogging.config()
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -180,4 +179,5 @@ class KodiPlayer(Player):
|
|||||||
|
|
||||||
def run():
|
def run():
|
||||||
""" Run the BackgroundService """
|
""" Run the BackgroundService """
|
||||||
|
kodilogging.config()
|
||||||
BackgroundService().run()
|
BackgroundService().run()
|
||||||
|
45
tests/test_service.py
Normal file
45
tests/test_service.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
""" Tests for background service """
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name,missing-docstring
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
import os
|
||||||
|
import signal
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from resources.lib import addon, kodiutils
|
||||||
|
from resources.lib.service import BackgroundService
|
||||||
|
|
||||||
|
routing = addon.routing
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(sys.platform.startswith("win"), 'Skipping on Windows.')
|
||||||
|
@unittest.skipUnless(kodiutils.get_setting('username') and kodiutils.get_setting('password'), 'Skipping since we have no credentials.')
|
||||||
|
class TestService(unittest.TestCase):
|
||||||
|
""" Tests for the background service """
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
@pytest.mark.timeout(timeout=10, method='thread')
|
||||||
|
def test_service():
|
||||||
|
""" Run the background service for 5 seconds. It will raise an error when it doesn't stop after 10 seconds. """
|
||||||
|
|
||||||
|
def terminate_service(seconds=5):
|
||||||
|
""" Sleep a bit, and send us a SIGINT signal. """
|
||||||
|
time.sleep(seconds)
|
||||||
|
os.kill(os.getpid(), signal.SIGINT)
|
||||||
|
|
||||||
|
threading.Thread(target=terminate_service).start()
|
||||||
|
|
||||||
|
service = BackgroundService()
|
||||||
|
service.run()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user