From 105edf36c36092c98a3e5e602b43ffe8c2cce148 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Wed, 30 Nov 2016 21:54:06 +0100 Subject: [PATCH] More appveyor adjustments --- scripts/appveyor-webhook.py | 79 ++++++++++++++++++++++++++----------- scripts/appveyor.yml | 66 +++++++++++++++++-------------- 2 files changed, 92 insertions(+), 53 deletions(-) diff --git a/scripts/appveyor-webhook.py b/scripts/appveyor-webhook.py index e28fac6b3..573aa1045 100755 --- a/scripts/appveyor-webhook.py +++ b/scripts/appveyor-webhook.py @@ -21,34 +21,40 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +""" +This script is used to trigger a build at appveyor. Since the code is not hosted +on github the normal triggering mechanisms can't be use. The project is +registered as subversion repository. A webhook is used to trigger new builds. +The appveyor.yml used for the build is send to appveyor when calling the hook. +""" import json import urllib import urllib.request import datetime import sys +import time from subprocess import Popen, PIPE -token = 'xx' -webhook_url = 'https://ci.appveyor.com/api/subversion/webhook?id=x' -branch = 'lp:openlp' +appveyor_build_url = 'https://ci.appveyor.com/project/TomasGroth/openlp/build' +appveyor_api_url = 'https://ci.appveyor.com/api/projects/TomasGroth/openlp' webhook_element = \ -{ - "commit": { - "author": { - "email": "open@contributer", - "name": "OpenLP Contributor" + { + 'commit': { + 'author': { + 'email': 'open@contributer', + 'name': 'OpenLP Contributor' + }, + 'id': None, + 'message': None, + 'timestamp': datetime.datetime.now().isoformat() }, - "id": None, - "message": "Building " + branch, - "timestamp": datetime.datetime.now().isoformat() - }, - "config": None, - "repository": { - "name": "repo_name", - "url": "repo_url" + 'config': None, + 'repository': { + 'name': 'repo_name', + 'url': 'repo_url' + } } -} def get_version(): @@ -78,7 +84,10 @@ def get_version(): return version_string, version -def get_yml(): +def get_yml(branch): + """ + Returns the content of appveyor.yml and inserts the branch to be build + """ f = open('appveyor.yml') yml_text = f.read() f.close() @@ -86,17 +95,39 @@ def get_yml(): return yml_text -def hook(token, webhook_url): - webhook_element['config'] = get_yml() +def hook(webhook_url, yml): + """ + Activate the webhook to start the build + """ + webhook_element['config'] = yml webhook_element['commit']['message'] = 'Building ' + branch version_string, version = get_version() webhook_element['commit']['id'] = version_string request = urllib.request.Request(webhook_url) - print(json.dumps(webhook_element)) request.add_header('Content-Type', 'application/json;charset=utf-8') - request.add_header('Authorization', 'Bearer ' + token) responce = urllib.request.urlopen(request, json.dumps(webhook_element).encode('utf-8')) - print(responce.read().decode('utf-8')) + if responce.getcode() != 204: + print('An error happened when calling the webhook! Return code: %d' % responce.getcode()) + print(responce.read().decode('utf-8')) -hook(token, webhook_url) +def get_appveyor_build_url(branch): + """ + Get the url of the build. + """ + # Wait 10 seconds to make sure the hook has been triggered + time.sleep(10) + responce = urllib.request.urlopen(appveyor_api_url) + json_str = responce.read().decode('utf-8') + build_json = json.loads(json_str) + build_url = '%s/%s' % (appveyor_build_url, build_json['build']['version']) + print('Check this URL for build status: %s' % build_url) + + +if len(sys.argv) != 3: + print('Usage: %s ' % sys.argv[0]) +else: + webhook_url = sys.argv[1] + branch = sys.argv[2] + hook(webhook_url, get_yml(branch)) + get_appveyor_build_url(branch) diff --git a/scripts/appveyor.yml b/scripts/appveyor.yml index 490464044..4784ed50d 100644 --- a/scripts/appveyor.yml +++ b/scripts/appveyor.yml @@ -1,4 +1,4 @@ -version: 2.5.0.{build} +version: OpenLP-win-ci-b{build} init: - choco install -y --force bzr @@ -6,39 +6,54 @@ init: - bzr --version clone_script: - - bzr checkout --lightweight BRANCHNAME openlp + - bzr checkout --lightweight BRANCHNAME openlp-branch environment: PYTHON: C:\\Python34 install: # Install dependencies from pypi - - "%PYTHON%\\python.exe -m pip install sqlalchemy alembic chardet beautifulsoup4 Mako nose mock pyodbc==3.0.10 psycopg2 pypiwin32 pyenchant" + - "%PYTHON%\\python.exe -m pip install sqlalchemy alembic chardet beautifulsoup4 Mako nose mock pyodbc psycopg2 pypiwin32 pyenchant" # Install mysql dependency - "%PYTHON%\\python.exe -m pip install http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip#md5=3df394d89300db95163f17c843ef49df" # Download and install lxml and pyicu (originally from http://www.lfd.uci.edu/~gohlke/pythonlibs/) - - curl -L "https://www.dropbox.com/s/7dwwna459j6qvbp/lxml-3.6.4-cp34-cp34m-win32.whl?dl=1" -o lxml-3.6.4-cp34-cp34m-win32.whl - - "%PYTHON%\\python.exe -m pip install lxml-3.6.4-cp34-cp34m-win32.whl" - - curl -L "https://www.dropbox.com/s/ib1yq4xq7o1dma7/PyICU-1.9.5-cp34-cp34m-win32.whl?dl=1" -o PyICU-1.9.5-cp34-cp34m-win32.whl - - "%PYTHON%\\python.exe -m pip install PyICU-1.9.5-cp34-cp34m-win32.whl" + - "%PYTHON%\\python.exe -m pip install https://get.openlp.org/win-sdk/lxml-3.6.4-cp34-cp34m-win32.whl" + - "%PYTHON%\\python.exe -m pip install https://get.openlp.org/win-sdk/PyICU-1.9.5-cp34-cp34m-win32.whl" # Download and install PyQt5 - curl -L -O http://downloads.sourceforge.net/project/pyqt/PyQt5/PyQt-5.5.1/PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x32.exe - PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x32.exe /S - # Download and install Inno Setup - used for packaging - - curl -L -O http://www.jrsoftware.org/download.php/is-unicode.exe - - is-unicode.exe /VERYSILENT /SUPPRESSMSGBOXES /SP- - # Download and unpack portable-bundle - - curl -L "https://www.dropbox.com/s/omr8mw9kamnml3l/portable-setup.7z?dl=1" -o portable-setup.7z - - 7z x portable-setup.7z # Download and unpack mupdf - curl -O http://mupdf.com/downloads/archive/mupdf-1.9a-windows.zip - 7z x mupdf-1.9a-windows.zip - - cp mupdf-1.9a-windows/mupdf.exe openlp/mupdf.exe + - cp mupdf-1.9a-windows/mupdf.exe openlp-branch/mupdf.exe # Download and unpack mediainfo - curl -O https://mediaarea.net/download/binary/mediainfo/0.7.90/MediaInfo_CLI_0.7.90_Windows_i386.zip - mkdir MediaInfo - 7z x -oMediaInfo MediaInfo_CLI_0.7.90_Windows_i386.zip - - cp MediaInfo\\MediaInfo.exe openlp\\MediaInfo.exe + - cp MediaInfo\\MediaInfo.exe openlp-branch\\MediaInfo.exe + + +build: off + +test_script: + - cd openlp-branch + - "%PYTHON%\\python.exe -m nose -v tests" + # Go back to the user root folder + - cd.. + +after_test: + # This is where we create a package using PyInstaller + # First get PyInstaller + - curl -L -O https://github.com/pyinstaller/pyinstaller/archive/develop.zip + - 7z x develop.zip + # Install PyInstaller dependencies + - "%PYTHON%\\python.exe -m pip install future" + # Download and install Inno Setup - used for packaging + - curl -L -O http://www.jrsoftware.org/download.php/is-unicode.exe + - is-unicode.exe /VERYSILENT /SUPPRESSMSGBOXES /SP- + # Download and unpack portable-bundle + - curl -O https://get.openlp.org/win-sdk/portable-setup.7z + - 7z x portable-setup.7z # Disabled portable installers - can't figure out how to make them silent # - curl -L -O http://downloads.sourceforge.net/project/portableapps/PortableApps.com%20Installer/PortableApps.comInstaller_3.4.4.paf.exe # - PortableApps.comInstaller_3.4.4.paf.exe /S @@ -46,18 +61,11 @@ install: # - PortableApps.comLauncher_2.2.1.paf.exe /S # - curl -L -O http://downloads.sourceforge.net/project/portableapps/NSIS%20Portable/NSISPortable_3.0_English.paf.exe # - NSISPortable_3.0_English.paf.exe /S - - -build: off - -test_script: - - cd openlp - - "%PYTHON%\\python.exe -m nose -v tests" - -after_test: - # This is where we create a package using PyInstaller - # First get PyInstaller - - curl -O https://github.com/pyinstaller/pyinstaller/archive/develop.zip - - 7z x develop.zip + # Get the packaging code + - bzr checkout --lightweight lp:~tomasgroth/openlp/packaging-appveyor packaging # Build the bundle - - "%PYTHON%\\python.exe windows/windows-builder.py -v -u -t -c windows/config-appveyor.ini -b ../openlp" + - cd packaging + - "%PYTHON%\\python.exe windows/windows-builder.py -v -u -t -c windows/config-appveyor.ini -b ../openlp-branch" + +artifacts: + - path: openlp-branch\dist\*.exe