Update and move appveyor.yml so that it will work with the new gitlab setup.

This commit is contained in:
Tomas Groth 2019-09-25 18:00:05 +00:00
parent d691b12ab2
commit 81900c7f83
2 changed files with 16 additions and 169 deletions

View File

@ -1,14 +1,11 @@
version: OpenLP-win-ci-b{build}
cache:
- '%LOCALAPPDATA%\pip\Cache'
image:
- Visual Studio 2017
clone_script:
- curl -L https://gitlab.com/openlp/openlp/-/archive/BRANCHPATH/openlp-BRANCHPATH.tar.gz -o sourcecode.tar.gz
- 7z e sourcecode.tar.gz
- 7z x sourcecode.tar
- mv BRANCHPATH openlp-branch
environment:
matrix:
- PYTHON: C:\\Python37-x64
@ -23,7 +20,7 @@ install:
build: off
test_script:
- cd openlp-branch
- cd %APPVEYOR_BUILD_FOLDER%
# Run the tests
- "%PYTHON%\\python.exe -m pytest -v tests"
# Go back to the user root folder
@ -46,27 +43,24 @@ after_test:
# Install VLC
- choco install %CHOCO_VLC%
# Get the packaging code
- appveyor DownloadFile https://gitlab.com/openlp/packaging/-/archive/master/packaging-master.tar.gz -FileName packaging.tar.gz
- 7z e packaging.tar.gz
- 7z x packaging.tar
- mv ~openlp-core/openlp/packaging packaging
- appveyor DownloadFile https://gitlab.com/openlp/packaging/-/archive/master/packaging-master.zip -FileName packaging-master.zip
- 7z x packaging-master.zip
# If this is trunk we should also build the manual
- ps: >-
If (BUILD_DOCS) {
If ($env:APPVEYOR_REPO_TAG -eq $True) {
&"$env:PYTHON\python.exe" -m pip install sphinx
Invoke-WebRequest -Uri "https://gitlab.com/openlp/documentation/-/archive/master/documentation-master.tar.gz" -OutFile documentation.tar.gz
7z e documentation.tar.gz
7z x documentation.tar
mv ~openlp-core/openlp/documentation documentation
cd packaging
&"$env:PYTHON\python.exe" builders/windows-builder.py --skip-update -c windows/config-appveyor.ini -b ../openlp-branch -d ../documentation --portable --tag-override TAG
Invoke-WebRequest -Uri "https://gitlab.com/openlp/documentation/-/archive/master/documentation-master.zip" -OutFile documentation-master.zip
7z x documentation-master.zip
cd packaging-master
&"$env:PYTHON\python.exe" builders/windows-builder.py --release --skip-update -c windows/config-appveyor.ini -b "$env:APPVEYOR_BUILD_FOLDER" -d ../documentation-master --portable
} else {
cd packaging
&"$env:PYTHON\python.exe" builders/windows-builder.py --skip-update --skip-translations -c windows/config-appveyor.ini -b ../openlp-branch --portable --tag-override TAG
cd packaging-master
&"$env:PYTHON\python.exe" builders/windows-builder.py --skip-update --skip-translations -c windows/config-appveyor.ini -b "$env:APPVEYOR_BUILD_FOLDER" --portable
}
artifacts:
- path: openlp-branch\dist\*.exe
- path: dist\*.exe
name: Portable-installer
- path: openlp-branch\dist\*.msi
- path: dist\*.msi
name: Installer

View File

@ -1,147 +0,0 @@
#!/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-2019 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, either version 3 of the License, or #
# (at your option) any later version. #
# #
# 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, see <https://www.gnu.org/licenses/>. #
##########################################################################
"""
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 datetime
import json
import sys
import time
import urllib
import urllib.request
from subprocess import PIPE, Popen
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 = \
{
'commit': {
'author': {
'email': 'contributer@openlp',
'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-bzr%s' % (tag, latest)
return version_string, version
def get_yml(branch, build_type):
"""
Returns the content of appveyor.yml and inserts the branch to be build
"""
f = open('appveyor.yml')
yml_text = f.read()
f.close()
version_string, version = get_version()
yml_text = yml_text.replace('TAG', version)
if build_type in ['openlp', 'trunk']:
yml_text = yml_text.replace('BRANCHPATH', 'master')
yml_text = yml_text.replace('BUILD_DOCS', '$TRUE')
else:
yml_text = yml_text.replace('BRANCHPATH', branch.split(':')[1])
yml_text = yml_text.replace('BUILD_DOCS', '$FALSE')
return yml_text, version_string
def hook(webhook_url, branch, build_type):
"""
Activate the webhook to start the build
"""
yml, version_string = get_yml(branch, build_type)
webhook_element['config'] = yml
webhook_element['commit']['message'] = 'Building ' + branch
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(build_type):
"""
Get the url of the build.
"""
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=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('Invalid number of arguments\nUsage: %s <webhook-url> <branch> <dev|trunk|openlp>' % sys.argv[0])
else:
webhook_url = sys.argv[1]
branch = sys.argv[2]
build_type = sys.argv[3]
if build_type not in ['dev', 'trunk', 'openlp']:
print('Invalid build type\nUsage: %s <webhook-url> <branch> <dev|trunk|openlp>' % sys.argv[0])
exit()
hook(webhook_url, branch, build_type)
# Wait 5 seconds to make sure the hook has been triggered
time.sleep(5)
get_appveyor_build_url(build_type)