Skip to content

Commit

Permalink
Merge pull request #177 from dagwieers/github-ci
Browse files Browse the repository at this point in the history
Migrate from Travis CI to GitHub CI
  • Loading branch information
im85288 authored Mar 30, 2020
2 parents c66d732 + 777f5c4 commit 5804512
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 64 deletions.
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.github/ export-ignore
tests/ export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.pylintrc export-ignore
Makefile export-ignore
requirements.txt export-ignore
tox.ini export-ignore
36 changes: 36 additions & 0 deletions .github/workflows/addon-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Kodi
on:
- pull_request
- push
jobs:
tests:
name: Addon checker
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
kodi-branch: [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 libxml2-utils xmlstarlet
python -m pip install --upgrade pip packaging
# 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
working-directory: ${{ github.repository }}
if: matrix.kodi-branch == 'matrix'
- name: Run kodi-addon-checker
run: kodi-addon-checker --branch=${{ matrix.kodi-branch }} ${{ github.repository }}/
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI
on:
- pull_request
- push
jobs:
tests:
name: Add-on testing
runs-on: ubuntu-latest
env:
PYTHONIOENCODING: utf-8
PYTHONPATH: ${{ github.workspace }}/resources/lib:${{ github.workspace }}/tests
strategy:
fail-fast: false
matrix:
python-version: [ 2.7, 3.5, 3.6, 3.7, 3.8 ]
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
run: |
sudo apt-get install gettext
sudo pip install coverage --install-option="--install-scripts=/usr/bin"
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tox
run: python -m tox -q -e flake8,py
- name: Run pylint
run: python -m pylint resources/lib/ tests/
- name: Compare translations
run: make check-translations
- name: Run unit tests
run: coverage run -m unittest discover
- name: Run script entry
run: coverage run -a resources/lib/script_entry.py
- name: Run service entry
run: coverage run -a resources/lib/service_entry.py &
- name: Upload code coverage to CodeCov
uses: codecov/codecov-action@v1
continue-on-error: true
# FIXME: Requires changes from SonarSource/sonarcloud-github-action#9
- name: Analyze with SonarCloud
uses: dagwieers/sonarcloud-github-action@more-options
with:
organization: add-ons
projectKey: add-ons_plugin.video.vrt.nu
sources: resources/lib/
tests: tests/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
continue-on-error: true
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

39 changes: 19 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export PYTHONPATH := $(CURDIR)/resources/lib/:$(CURDIR)/test/
export PYTHONPATH := $(CURDIR)/resources/lib/:$(CURDIR)/tests/
PYTHON := python

name = $(shell xmllint --xpath 'string(/addon/@id)' addon.xml)
Expand All @@ -18,49 +18,48 @@ blue = \e[1;34m
white = \e[1;37m
reset = \e[0;39m

.PHONY: test
all: check test build
zip: build
test: check test-unit test-service test-run

all: test zip
check: check-tox check-pylint check-translations

package: zip

test: sanity unit run

sanity: tox pylint language

tox:
check-tox:
@echo -e "$(white)=$(blue) Starting sanity tox test$(reset)"
$(PYTHON) -m tox -q

pylint:
check-pylint:
@echo -e "$(white)=$(blue) Starting sanity pylint test$(reset)"
$(PYTHON) -m pylint -e useless-suppression resources/lib/ test/
$(PYTHON) -m pylint -e useless-suppression resources/lib/ tests/

language:
check-translations:
@echo -e "$(white)=$(blue) Starting language test$(reset)"
@-$(foreach lang,$(languages), \
msgcmp resources/language/resource.language.$(lang)/strings.po resources/language/resource.language.en_gb/strings.po; \
)

addon: clean
check-addon: clean
@echo -e "$(white)=$(blue) Starting sanity addon tests$(reset)"
kodi-addon-checker . --branch=leia

unit: clean
unit: test-unit
run: test-run

test-unit: clean
@echo -e "$(white)=$(blue) Starting unit tests$(reset)"
$(PYTHON) -m unittest discover

run:
test-run:
@echo -e "$(white)=$(blue) Run CLI$(reset)"
$(PYTHON) resources/lib/script_entry.py
@-pkill -ef '$(PYTHON) resources/lib/service_entry.py'
$(PYTHON) resources/lib/service_entry.py &
@sleep 10
# $(PYTHON) test/run.py
# $(PYTHON) tests/run.py
@sleep 5
@-pkill -ef -INT '$(PYTHON) resources/lib/service_entry.py'

zip: clean
build: clean
@echo -e "$(white)=$(blue) Building new package$(reset)"
@rm -f ../$(zip_name)
cd ..; zip -r $(zip_name) $(include_paths) -x $(exclude_files)
Expand All @@ -71,8 +70,8 @@ codecov:
curl --data-binary @.codecov.yml https://codecov.io/validate

clean:
find . -name '*.pyc' -type f -delete
find . -name '*.pyo' -type f -delete
@echo -e "$(white)=$(blue) Cleaning up$(reset)"
find . -name '*.py[cod]' -type f -delete
find . -name '__pycache__' -type d -delete
rm -rf .pytest_cache/ .tox/
rm -f *.log
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![GitHub release](https://img.shields.io/github/release/im85288/service.upnext.svg)](https://github.com/im85288/service.upnext/releases)
[![CI](https://github.com/im85288/service.upnext/workflows/CI/badge.svg)](https://github.com/im85288/service.upnext/actions?query=workflow:CI)
[![Build Status](https://travis-ci.org/im85288/service.upnext.svg?branch=master)](https://travis-ci.org/im85288/service.upnext)
[![Codecov status](https://img.shields.io/codecov/c/github/im85288/service.upnext/master)](https://codecov.io/gh/im85288/service.upnext/branch/master)
[![License: GPLv3](https://img.shields.io/badge/License-GPLv2-yellow.svg)](https://opensource.org/licenses/GPL-2.0)
Expand Down
2 changes: 1 addition & 1 deletion .codecov.yml → codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ coverage:
patch: false
comment: false
ignore:
- test/
- tests/
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions test/xbmc.py → tests/xbmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ def sleep(seconds):
def translatePath(path):
''' A stub implementation of the xbmc translatePath() function '''
if path.startswith('special://home'):
return path.replace('special://home', os.path.join(os.getcwd(), 'test/'))
return path.replace('special://home', os.path.join(os.getcwd(), 'tests/'))
if path.startswith('special://masterprofile'):
return path.replace('special://masterprofile', os.path.join(os.getcwd(), 'test/userdata/'))
return path.replace('special://masterprofile', os.path.join(os.getcwd(), 'tests/userdata/'))
if path.startswith('special://profile'):
return path.replace('special://profile', os.path.join(os.getcwd(), 'test/userdata/'))
return path.replace('special://profile', os.path.join(os.getcwd(), 'tests/userdata/'))
if path.startswith('special://userdata'):
return path.replace('special://userdata', os.path.join(os.getcwd(), 'test/userdata/'))
return path.replace('special://userdata', os.path.join(os.getcwd(), 'tests/userdata/'))
return path
2 changes: 1 addition & 1 deletion test/xbmcaddon.py → tests/xbmcaddon.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ def setSetting(self, key, value):
ADDON_SETTINGS[self.id] = dict()
ADDON_SETTINGS[self.id][key] = value
# NOTE: Disable actual writing as it is no longer needed for testing
# with open('test/userdata/addon_settings.json', 'w') as fd:
# with open('tests/userdata/addon_settings.json', 'w') as fd:
# json.dump(filtered_settings, fd, sort_keys=True, indent=4)
8 changes: 4 additions & 4 deletions test/xbmcextra.py → tests/xbmcextra.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ def global_settings():
''' Use the global_settings file '''
import json
try:
with open('test/userdata/global_settings.json') as f:
with open('tests/userdata/global_settings.json') as f:
settings = json.load(f)
except OSError as e:
print("Error: Cannot use 'test/userdata/global_settings.json' : %s" % e)
print("Error: Cannot use 'tests/userdata/global_settings.json' : %s" % e)
settings = {
'locale.language': 'resource.language.en_gb',
'network.bandwidth': 0,
Expand All @@ -104,10 +104,10 @@ def addon_settings():
''' Use the addon_settings file '''
import json
try:
with open('test/userdata/addon_settings.json') as f:
with open('tests/userdata/addon_settings.json') as f:
settings = json.load(f)
except OSError as e:
print("Error: Cannot use 'test/userdata/addon_settings.json' : %s" % e)
print("Error: Cannot use 'tests/userdata/addon_settings.json' : %s" % e)
settings = {}

return settings
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 5804512

Please sign in to comment.