Skip to content

Commit

Permalink
Fix tests (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaminister authored Feb 6, 2022
1 parent b21b228 commit c97af21
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
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: ubuntu-latest
runs-on: ${{ matrix.os }}
env:
PYTHONIOENCODING: utf-8
PYTHONPATH: ${{ github.workspace }}/lib:${{ github.workspace }}/tests
strategy:
fail-fast: false
# Set max-parallel to avoid ConnectionRefusedError from Google servers
max-parallel: 2
matrix:
# max-parallel: 2
python-version: [ 2.7, 3.5, 3.6, 3.7, 3.8 ]
os: [ ubuntu-latest ]
python-version: [ 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 ]
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
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[MESSAGES CONTROL]
disable=
bad-option-value,
consider-using-f-string,
duplicate-code, # Integration tests tend to test similar things
fixme, # Allow FIXMEs in code is a useful practice
import-outside-toplevel, # Done on purpose to reduce overhead at startup
Expand Down
2 changes: 1 addition & 1 deletion lib/inputstreamhelper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .kodiutils import (addon_version, delete, exists, get_proxies, get_setting, get_setting_bool, get_setting_float, get_setting_int, jsonrpc,
kodi_to_ascii, kodi_version, listdir, localize, log, notification, ok_dialog, progress_dialog, select_dialog,
set_setting, set_setting_bool, textviewer, translate_path, yesno_dialog)
from .utils import arch, http_download, remove_tree, run_cmd, store, system_os, temp_path, unzip
from .utils import arch, http_download, remove_tree, store, system_os, temp_path, unzip
from .widevine.arm import install_widevine_arm
from .widevine.widevine import (backup_path, has_widevinecdm, ia_cdm_path, install_cdm_from_backup, latest_available_widevine_from_repo,
latest_widevine_version, load_widevine_config, missing_widevine_libs, widevine_config_path, widevine_eula, widevinecdm_path)
Expand Down
2 changes: 1 addition & 1 deletion lib/inputstreamhelper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _http_request(url, headers=None, time_out=10):
req = urlopen(request, timeout=time_out)
log(0, 'Response code: {code}', code=req.getcode())
if 400 <= req.getcode() < 600:
raise HTTPError('HTTP %s Error for url: %s' % (req.getcode(), url), response=req)
raise HTTPError('HTTP {} Error for url: {}'.format(req.getcode(), url), response=req)
except (HTTPError, URLError) as err:
log(2, 'Download failed with error {}'.format(err))
if yesno_dialog(localize(30004), '{line1}\n{line2}'.format(line1=localize(30063), line2=localize(30065))): # Internet down, try again?
Expand Down
18 changes: 13 additions & 5 deletions tests/checkchromeos.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import requests
from lib.inputstreamhelper.config import CHROMEOS_RECOVERY_ARM_HWIDS


def get_devices():
"""Get Chrome OS devices as json object"""
url = 'https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices'
Expand All @@ -30,6 +31,7 @@ def get_devices():
devices.append(device)
return devices


def get_arm_devices():
"""Get Chrome OS ARM devices as json object"""
devices = get_devices()
Expand All @@ -39,6 +41,7 @@ def get_arm_devices():
arm_devices.append(device)
return arm_devices


def get_serves():
"""Get Chrome OS serving updates as json object"""
url = 'https://cros-updates-serving.appspot.com/csv'
Expand All @@ -54,6 +57,7 @@ def get_serves():
serves.append(serve)
return serves


def get_recoveries():
"""Get Chrome OS recovery items as json object"""
url = 'https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.json'
Expand All @@ -62,6 +66,7 @@ def get_recoveries():
recoveries = response.json()
return recoveries


def get_compatibles():
"""Get compatible Chrome OS recovery items"""
arm_devices = get_arm_devices()
Expand All @@ -86,15 +91,16 @@ def get_compatibles():
compatibles.append(recovery)
return compatibles


def get_smallest():
"""Get the Chrome OS recovery item with the smallest filesize"""
compatibles = get_compatibles()
smallest = None
for item in compatibles:
if smallest is None:
smallest = item
if (int(item.get('filesize')) + int(item.get('zipfilesize')) <
int(smallest.get('filesize')) + int(smallest.get('zipfilesize'))):
if (int(item.get('filesize')) + int(item.get('zipfilesize'))
< int(smallest.get('filesize')) + int(smallest.get('zipfilesize'))):
smallest = item
return smallest

Expand All @@ -111,20 +117,22 @@ def check_hwids():

for item in CHROMEOS_RECOVERY_ARM_HWIDS:
if item not in hwids:
messages.append('%s is not available, please remove it from inputstreamhelper config' % item)
messages.append('{} is end-of-life, consider removing it from inputstreamhelper config'.format(item))
for item in hwids:
if item not in CHROMEOS_RECOVERY_ARM_HWIDS:
messages.append('%s is missing, please add it to inputstreamhelper config' % item)
messages.append('{} is missing, please add it to inputstreamhelper config'.format(item))
if messages:
raise Exception(messages)

smallest = get_smallest()
hwid = smallest.get('hwidmatch').strip('^.*-').split(' ')[0]
print('Chrome OS hardware id\'s are up to date, current smallest recovery image is %s' % hwid)
print('Chrome OS hardware id\'s are up to date, current smallest recovery image is {}'.format(hwid))


def run():
"""Main function"""
check_hwids()


if __name__ == '__main__':
run()

0 comments on commit c97af21

Please sign in to comment.