From b98468e4ddd62625e29c570b5fb511380a4a5672 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Wed, 3 May 2017 22:16:52 +0200 Subject: [PATCH] More fixes for appveyor scripts. --- scripts/appveyor-webhook.py | 29 +++++++++++++++-------------- scripts/appveyor.yml | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/scripts/appveyor-webhook.py b/scripts/appveyor-webhook.py index 976745a35..630c404d7 100755 --- a/scripts/appveyor-webhook.py +++ b/scripts/appveyor-webhook.py @@ -37,6 +37,7 @@ from subprocess import Popen, PIPE appveyor_build_url = 'https://ci.appveyor.com/project/OpenLP/{project}/build' appveyor_api_url = 'https://ci.appveyor.com/api/projects/OpenLP/{project}' +appveyor_log_url = 'https://ci.appveyor.com/api/buildjobs/{buildid}/log' webhook_element = \ { @@ -84,7 +85,7 @@ def get_version(): return version_string, version -def get_yml(branch, build_docs): +def get_yml(branch, build_type): """ Returns the content of appveyor.yml and inserts the branch to be build """ @@ -92,7 +93,7 @@ def get_yml(branch, build_docs): yml_text = f.read() f.close() yml_text = yml_text.replace('BRANCHNAME', branch) - if build_docs: + if build_type in ['openlp', 'trunk']: yml_text = yml_text.replace('BUILD_DOCS', '$TRUE') else: yml_text = yml_text.replace('BUILD_DOCS', '$FALSE') @@ -115,28 +116,28 @@ def hook(webhook_url, yml): print(responce.read().decode('utf-8')) -def get_appveyor_build_url(branch): +def get_appveyor_build_url(build_type): """ Get the url of the build. """ - if 'openlp-core/openlp/trunk' in branch: - project = 'trunk' - else: - project = 'dev' - responce = urllib.request.urlopen(appveyor_api_url.format(project=project)) + responce = urllib.request.urlopen(appveyor_api_url.format(project=build_type)) json_str = responce.read().decode('utf-8') build_json = json.loads(json_str) - build_url = '%s/%s' % (appveyor_build_url.format(project=project), build_json['build']['version']) - print('Check this URL for build status: %s' % build_url.format(project=project)) + build_url = '%s/%s' % (appveyor_build_url.format(project=build_type), build_json['build']['version']) + print(build_url.format(project=build_type)) + print(appveyor_log_url.format(buildid=build_json['build']['jobs'][0]['jobId'])) if len(sys.argv) != 4: - print('Usage: %s ' % sys.argv[0]) + print('Invalid number of arguments\nUsage: %s ' % sys.argv[0]) else: webhook_url = sys.argv[1] branch = sys.argv[2] - build_docs = sys.argv[3].upper() == 'TRUE' - hook(webhook_url, get_yml(branch, build_docs)) + build_type = sys.argv[3] + if build_type not in ['dev', 'trunk', 'openlp']: + print('Invalid build type\nUsage: %s ' % sys.argv[0]) + exit() + hook(webhook_url, get_yml(branch, build_type)) # Wait 5 seconds to make sure the hook has been triggered time.sleep(5) - get_appveyor_build_url(branch) + get_appveyor_build_url(build_type) diff --git a/scripts/appveyor.yml b/scripts/appveyor.yml index 109eca8e5..3d2ceda21 100644 --- a/scripts/appveyor.yml +++ b/scripts/appveyor.yml @@ -36,7 +36,7 @@ build: off test_script: - cd openlp-branch # Run the tests - #- "%PYTHON%\\python.exe -m nose -v tests" + - "%PYTHON%\\python.exe -m nose -v tests" # Go back to the user root folder - cd..