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
|
||||
on:
|
||||
- pull_request
|
||||
- push
|
||||
# Run action when pushed to master, or for commits in a pull request.
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
tests:
|
||||
kodi-addon-checker:
|
||||
name: Addon checker
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
kodi-branch: [leia, matrix]
|
||||
kodi-version: [ leia, matrix ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
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: Check out ${{ github.sha }} from repository ${{ github.repository }}
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- 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 }}
|
62
.github/workflows/ci.yml
vendored
62
.github/workflows/ci.yml
vendored
@ -1,26 +1,27 @@
|
||||
name: CI
|
||||
on:
|
||||
- pull_request
|
||||
- push
|
||||
# Run action when pushed to master, or for commits in a pull request.
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
tests:
|
||||
name: Add-on testing
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
PYTHONIOENCODING: utf-8
|
||||
PYTHONPATH: ${{ github.workspace }}/resources/lib
|
||||
KODI_HOME: ${{ github.workspace }}/tests/home
|
||||
KODI_INTERACTIVE: 0
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
|
||||
os: [ ubuntu-latest ]
|
||||
python-version: [ 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 ]
|
||||
include:
|
||||
# Kodi Leia on Windows uses a bundled Python 2.7
|
||||
# Kodi Leia on Windows uses a bundled Python 2.7.
|
||||
- os: windows-latest
|
||||
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
|
||||
python-version: 3.8
|
||||
- os: windows-latest
|
||||
@ -28,36 +29,39 @@ jobs:
|
||||
steps:
|
||||
- name: Check out ${{ github.sha }} from repository ${{ github.repository }}
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
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
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
run: pip install -r requirements.txt
|
||||
|
||||
- name: Run pylint
|
||||
run: make check-pylint
|
||||
|
||||
- name: Check translations
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: make check-translations
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
|
||||
run: sudo apt-get install gettext && make check-translations
|
||||
|
||||
- name: Run unit tests
|
||||
run: coverage run -m unittest discover
|
||||
env:
|
||||
ADDON_PASSWORD: ${{ secrets.ADDON_PASSWORD }}
|
||||
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_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
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
uses: codecov/codecov-action@v1
|
||||
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
|
||||
pylint
|
||||
pytest
|
||||
pytest-cov
|
||||
pytest-timeout
|
||||
python-dateutil
|
||||
requests
|
||||
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
|
||||
|
||||
kodilogging.config()
|
||||
routing = Plugin() # pylint: disable=invalid-name
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -190,4 +189,5 @@ def iptv_epg():
|
||||
|
||||
def run(params):
|
||||
""" Run the routing plugin """
|
||||
kodilogging.config()
|
||||
routing.run(params)
|
||||
|
@ -13,7 +13,6 @@ from xbmc import Monitor, Player, getInfoLabel
|
||||
from resources.lib import kodilogging, kodiutils
|
||||
from resources.lib.viervijfzes.auth import AuthApi
|
||||
|
||||
kodilogging.config()
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -180,4 +179,5 @@ class KodiPlayer(Player):
|
||||
|
||||
def run():
|
||||
""" Run the BackgroundService """
|
||||
kodilogging.config()
|
||||
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