forked from openlp/openlp
Added script and yml for AppVeyor integration.
bzr-revno: 2707
This commit is contained in:
commit
eb1c63c5ad
133
scripts/appveyor-webhook.py
Executable file
133
scripts/appveyor-webhook.py
Executable file
@ -0,0 +1,133 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2016 OpenLP Developers #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# This program is free software; you can redistribute it and/or modify it #
|
||||||
|
# under the terms of the GNU General Public License as published by the Free #
|
||||||
|
# Software Foundation; version 2 of the License. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||||
|
# more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License along #
|
||||||
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
|
# 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
|
||||||
|
|
||||||
|
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'
|
||||||
|
},
|
||||||
|
'id': None,
|
||||||
|
'message': None,
|
||||||
|
'timestamp': datetime.datetime.now().isoformat()
|
||||||
|
},
|
||||||
|
'config': None,
|
||||||
|
'repository': {
|
||||||
|
'name': 'repo_name',
|
||||||
|
'url': 'repo_url'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_version():
|
||||||
|
"""
|
||||||
|
Get the version of the branch.
|
||||||
|
"""
|
||||||
|
bzr = Popen(('bzr', 'tags'), stdout=PIPE)
|
||||||
|
output = bzr.communicate()[0]
|
||||||
|
code = bzr.wait()
|
||||||
|
if code != 0:
|
||||||
|
raise Exception('Error running bzr tags')
|
||||||
|
lines = output.splitlines()
|
||||||
|
if len(lines) == 0:
|
||||||
|
tag = '0.0.0'
|
||||||
|
revision = '0'
|
||||||
|
else:
|
||||||
|
tag, revision = lines[-1].decode('utf-8').split()
|
||||||
|
bzr = Popen(('bzr', 'log', '--line', '-r', '-1'), stdout=PIPE)
|
||||||
|
output, error = bzr.communicate()
|
||||||
|
code = bzr.wait()
|
||||||
|
if code != 0:
|
||||||
|
raise Exception('Error running bzr log')
|
||||||
|
latest = output.decode('utf-8').split(':')[0]
|
||||||
|
version_string = latest == revision and tag or 'r%s' % latest
|
||||||
|
# Save decimal version in case we need to do a portable build.
|
||||||
|
version = latest == revision and tag or '%s.%s' % (tag, latest)
|
||||||
|
return version_string, version
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
||||||
|
yml_text = yml_text.replace('BRANCHNAME', branch)
|
||||||
|
return yml_text
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
request.add_header('Content-Type', 'application/json;charset=utf-8')
|
||||||
|
responce = urllib.request.urlopen(request, json.dumps(webhook_element).encode('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'))
|
||||||
|
|
||||||
|
|
||||||
|
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 <webhook-url> <branch>' % sys.argv[0])
|
||||||
|
else:
|
||||||
|
webhook_url = sys.argv[1]
|
||||||
|
branch = sys.argv[2]
|
||||||
|
hook(webhook_url, get_yml(branch))
|
||||||
|
get_appveyor_build_url(branch)
|
71
scripts/appveyor.yml
Normal file
71
scripts/appveyor.yml
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
version: OpenLP-win-ci-b{build}
|
||||||
|
|
||||||
|
init:
|
||||||
|
- choco install -y --force bzr
|
||||||
|
- set PATH=C:\Program Files (x86)\Bazaar;%PATH%
|
||||||
|
- bzr --version
|
||||||
|
|
||||||
|
clone_script:
|
||||||
|
- 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 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/)
|
||||||
|
- "%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 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-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-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
|
||||||
|
# - curl -L -O http://downloads.sourceforge.net/project/portableapps/PortableApps.com%20Launcher/PortableApps.comLauncher_2.2.1.paf.exe
|
||||||
|
# - 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
|
||||||
|
# Get the packaging code
|
||||||
|
- bzr checkout --lightweight lp:openlp/packaging packaging
|
||||||
|
# Build the bundle
|
||||||
|
- 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
|
@ -270,6 +270,8 @@ class TestMainDisplay(TestCase, TestMixin):
|
|||||||
service_item = MagicMock()
|
service_item = MagicMock()
|
||||||
service_item.theme_data = MagicMock()
|
service_item.theme_data = MagicMock()
|
||||||
service_item.theme_data.background_type = 'video'
|
service_item.theme_data.background_type = 'video'
|
||||||
|
service_item.theme_data.theme_name = 'name'
|
||||||
|
service_item.theme_data.background_filename = 'background_filename'
|
||||||
mocked_plugin = MagicMock()
|
mocked_plugin = MagicMock()
|
||||||
display.plugin_manager = PluginManager()
|
display.plugin_manager = PluginManager()
|
||||||
display.plugin_manager.plugins = [mocked_plugin]
|
display.plugin_manager.plugins = [mocked_plugin]
|
||||||
|
@ -137,7 +137,7 @@ class TestPowerpointDocument(TestCase, TestMixin):
|
|||||||
instance.goto_slide(42)
|
instance.goto_slide(42)
|
||||||
|
|
||||||
# THEN: mocked_critical_error_message_box should have been called
|
# THEN: mocked_critical_error_message_box should have been called
|
||||||
mocked_critical_error_message_box.assert_called_with('Error', 'An error occurred in the Powerpoint '
|
mocked_critical_error_message_box.assert_called_with('Error', 'An error occurred in the PowerPoint '
|
||||||
'integration and the presentation will be stopped.'
|
'integration and the presentation will be stopped.'
|
||||||
' Restart the presentation if you wish to '
|
' Restart the presentation if you wish to '
|
||||||
'present it.')
|
'present it.')
|
||||||
|
Loading…
Reference in New Issue
Block a user