Merge branch 'master' into modulesrefactor

This commit is contained in:
Andrei Yankovich 2019-12-26 16:55:32 +03:00
commit 201e18ce1c
7 changed files with 184 additions and 5 deletions

3
.gitignore vendored
View File

@ -9,3 +9,6 @@ gitpoller-workdir/
*.user
*__pycache__*
*.pyc
*.pyproject.user.*
*~

View File

@ -20,7 +20,7 @@
"qtUpdater.py",
"secretManager.py",
"NPM.py",
"git/gitBin.sh"
"git/gitBin.sh",
"asssetsinstaller.py"
]
}

View File

@ -0,0 +1,164 @@
# This Python file uses the following encoding: utf-8
import BuildBotLib.basemodule as base
from buildbot.plugins import util, steps
import os
from pathlib import Path
LAST_FORMAT = [""]
AndroidBaseDir = str(Path.home()) + "/Android"
MULTIPLE_SH_COMMAND = ["/bin/bash", "-c"]
def isInit(step):
return step.getProperty('module') == 'init'
@util.renderer
def RemoveOldData(props):
cmd = "mkdir -p " + AndroidBaseDir
if os.path.exists(AndroidBaseDir):
cmd = "rm -rdf " + AndroidBaseDir + " ; " + cmd
return MULTIPLE_SH_COMMAND + [cmd]
@util.renderer
def NDKDownloadCMD(props):
link = props.getProperty("link")
format = link[link.rfind('.'):].lower()
LAST_FORMAT[0] = format
return ["curl", link, "--output", AndroidBaseDir + "/temp" + format]
@util.renderer
def ExtractCMD(props):
format = LAST_FORMAT[0]
res = ["echo", "format '" + format + "' not supported"]
if format == ".zip":
res = ["unzip", AndroidBaseDir + "/temp" + format,
"-d", AndroidBaseDir]
return res
@util.renderer
def InstallCMD(props):
module = props.getProperty("module")
version = props.getProperty("version")
unit_to_multiplier = {
'SDK': 'platform-tools;tools;platforms;android-'+version,
'NDK': 'ndk-bundle'
}
return ["sdkmanager", unit_to_multiplier.get(module, "--list")]
@util.renderer
def ConfigureCMD(props):
format = LAST_FORMAT[0]
res = ["echo", "Configure failed"]
if format == ".zip":
all_subdirs = base.allSubdirsOf(AndroidBaseDir)
latest_subdir = max(all_subdirs, key=os.path.getmtime)
res = "mv " + latest_subdir + " " + AndroidBaseDir + "/tools"
res += " ; ln -sf " + AndroidBaseDir + "/tools/bin/sdkmanager "
res += str(Path.home()) + "/.local/bin/sdkmanager"
res += " ; yes | sdkmanager --licenses"
return MULTIPLE_SH_COMMAND + [res]
def getFactory():
factory = base.getFactory()
factory.addStep(
steps.ShellCommand(
command=RemoveOldData,
name='rm old item',
doStepIf=isInit,
description='rm old',
haltOnFailure=True,
)
)
factory.addStep(
steps.ShellCommand(
command=NDKDownloadCMD,
name='download new item',
doStepIf=isInit,
description='download new item',
haltOnFailure=True,
)
)
factory.addStep(
steps.ShellCommand(
command=ExtractCMD,
name='extract new item',
doStepIf=isInit,
description='extract new item',
haltOnFailure=True,
)
)
factory.addStep(
steps.ShellCommand(
command=ConfigureCMD,
name='configure new item',
doStepIf=isInit,
description='configure new item',
haltOnFailure=True,
)
)
factory.addStep(
steps.ShellCommand(
command=InstallCMD,
name='install module',
doStepIf=lambda step: not isInit(step),
description='configure new item',
haltOnFailure=True,
)
)
return factory
def getRepo():
return ""
def getPropertyes():
return [
util.ChoiceStringParameter(
name='module',
choices=["init", "SDK", "NDK"],
default="init"
),
util.StringParameter(
name='link',
label="url to download item",
default=""
),
util.StringParameter(
name='version',
label="Version",
default=""
),
]

View File

@ -1,3 +1,4 @@
import os
from buildbot.plugins import util
import multiprocessing
import glob
@ -62,6 +63,15 @@ class BaseModule:
return res
def allSubdirsOf(b='.'):
result = []
for d in os.listdir(b):
bd = os.path.join(b, d)
if os.path.isdir(bd):
result.append(bd)
return result
@util.renderer
def makeCommand(self, props):
command = ['make']

View File

@ -18,7 +18,8 @@ class BuildBotWorkers(BuildBotModule):
worker.Worker("github-worker", "pass"),
worker.Worker("Tester", "pass"),
worker.Worker("qtBuilder", "pass"),
worker.Worker("NPM", "pass")
worker.Worker("NPM", "pass"),
worker.Worker("assets-builder", "pass")
]

View File

@ -285,5 +285,6 @@ class QtUpdater(Make):
default=False
)
return list;
]

View File

@ -19,13 +19,13 @@ from BuildBotLib.qtUpdater import QtUpdater
bot = BuildBot();
qmake = QMake();
npm = NPM();
asssetsinstaller = Asssetsinstaller();
qtUpdater = QtUpdater();
bot.addBuilder("github-worker", qmake);
bot.addBuilder("Tester", qmake);
bot.addBuilder("qtBuilder", qtUpdater);
bot.addBuilder("NPM", npm);
bot.addBuilder("assets-builder", asssetsinstaller);
c = BuildmasterConfig = bot.getMaster()