4
0
mirror of https://github.com/QuasarApp/QuasarAppCI.git synced 2025-05-08 03:09:35 +00:00

fix warnings

This commit is contained in:
Andrei Yankovich 2019-12-26 11:29:22 +03:00
parent 6d25ea08ce
commit d010fce05f
3 changed files with 127 additions and 266 deletions

@ -1,24 +1,24 @@
import sys
from buildbot.plugins import util
import multiprocessing
import glob
import shutil
class BaseModule:
MULTIPLE_SH_COMMAND = ["/bin/bash", "-c"]
def generateCmd(bashString) :
return MULTIPLE_SH_COMMAND + [bashString]
def __init__(self):
self;
self
def generateCmd(self, bashString):
return self.MULTIPLE_SH_COMMAND + [bashString]
def getFactory(self):
return util.BuildFactory()
def getRepo(self):
return "";
return ""
def getPropertyes(self):
return []
@ -31,7 +31,7 @@ class BaseModule:
res.append(file)
shutil.copy(file, dist)
return res;
return res
@util.renderer
def makeCommand(self, props):

@ -2,56 +2,53 @@
from BuildBotLib.basemodule import BaseModule
from buildbot.plugins import secrets, util, steps
from buildbot.plugins import util, steps
from pathlib import Path
import datetime
import os
import subprocess
from BuildBotLib.secretManager import *
from BuildBotLib.secretManager import SecretManager
class Make(BaseModule):
def __init__(self):
BaseModule.__init__(self);
BaseModule.__init__(self)
def isClean(self, step):
return step.getProperty('clean');
return step.getProperty('clean')
def isDeploy(self, step):
return step.getProperty('deploy');
return step.getProperty('deploy')
def isRelease(self, step):
return step.getProperty('release');
return step.getProperty('release')
def isTest(self, step):
return step.getProperty('test');
return step.getProperty('test')
def isWin(self, step):
return step.getProperty('Windows');
return step.getProperty('Windows')
def isLinux(self, step):
return step.getProperty('Linux');
return step.getProperty('Linux')
def isAndroid(self, step):
return step.getProperty('Android');
return step.getProperty('Android')
def destDirPrivate(self, props):
repo = str(props.getProperty('repository'));
repo = str(props.getProperty('repository'))
now = datetime.datetime.now().strftime("(%H_%M)_%m-%d-%Y")
return repo[repo.rfind('/'): len(repo) - 4] + "/" + now;
return repo[repo.rfind('/'): len(repo) - 4] + "/" + now
@util.renderer
def destDir(self, props):
home = str(Path.home())
return home + '/shared/' + destDirPrivate(props);
return home + '/shared/' + self.destDirPrivate(props)
@util.renderer
def destDirUrl(self, props):
path = destDirPrivate(props);
return "http://quasarapp.ddns.net:3031" + path;
path = self.destDirPrivate(props)
return "http://quasarapp.ddns.net:3031" + path
@util.renderer
def permission(self, props):
@ -65,9 +62,9 @@ class Make(BaseModule):
"-r",
"CONFIG+=qtquickcompiler",
'ONLINE="~/repo"'
];
]
return command;
return command
@util.renderer
def windowsXmakeCmd(self, props):
@ -77,9 +74,9 @@ class Make(BaseModule):
"-r",
"CONFIG+=qtquickcompiler",
'ONLINE="~/repo"'
];
]
return command;
return command
@util.renderer
def androidXmakeCmd(self, props):
@ -94,323 +91,187 @@ class Make(BaseModule):
'SIGN_ALIES="quasarapp"',
'SIGN_STORE_PASSWORD="' + secret.getValue('SIGPASS') + '"'
];
]
return command;
return command
@util.renderer
def androidXmakeEnv:
def androidXmakeEnv(self, props):
return {}
@util.renderer
def windowsXmakeEnv:
def windowsXmakeEnv(self, props):
return {}
@util.renderer
def linuxXmakeEnv:
def linuxXmakeEnv(self, props):
return {}
def makePrefix():
def makePrefix(self):
return ""
def generateStep(cmd, platform, desc, checkFunc) :
def generateStep(self, cmd, platform, desc, checkFunc):
platformCgek = {
'linux': isLinux,
'windows': isWin,
'android': isAndroid,
'linux': self.isLinux,
'windows': self.isWin,
'android': self.isAndroid,
}
platformEnv = {
'linux': linuxXmakeEnv,
'windows': windowsXmakeEnv,
'android': androidXmakeEnv,
'linux': self.linuxXmakeEnv,
'windows': self.windowsXmakeEnv,
'android': self.androidXmakeEnv,
}
def dustepIf(step):
return checkFunc(step) and platformCgek[platform](step)
res = steps.ShellCommand(
command = cmd,
haltOnFailure = True,
doStepIf = lambda step : checkFunc(step) and platformCgek[platform](step),
hideStepIf = lambda step : not (checkFunc(step) and platformCgek[platform](step)),
name = makePrefix + 'Make ' + platform,
command=cmd,
haltOnFailure=True,
doStepIf=lambda step: dustepIf(step),
hideStepIf=lambda step: not dustepIf(step),
name=self.makePrefix() + 'Make ' + platform,
env=platformEnv[platform],
description = desc,
description=desc,
)
return res;
return res
def generatePlatformSteps(platform) :
def generatePlatformSteps(self, platform):
platformXcmd = {
'linux': linuxXmakeCmd,
'windows': windowsXmakeCmd,
'android': androidXmakeCmd,
'linux': self.linuxXmakeCmd,
'windows': self.windowsXmakeCmd,
'android': self.androidXmakeCmd,
}
res = []
res += [generateStep(platformXcmd[platform],
platform,
'generate make files for build the project',
lambda step: return True)]
res += [self.generateStep(platformXcmd[platform],
platform,
'generate make files for build the project',
lambda step: True)]
res += [generateStep('make clean',
platform,
'clean old data',
self.isClean)]
res += [self.generateStep('make clean',
platform,
'clean old data',
self.isClean)]
res += [generateStep()]
res += [generateStep()]
res += [generateStep()]
res += [generateStep()]
res += [generateStep()]
res += [self.generateStep(self.makeCommand,
platform,
'build project',
lambda step: True)]
def LinuxSteps(self) :
list = [
steps.ShellCommand(
command = self.linuxXmakeCmd ,
haltOnFailure = True,
doStepIf = lambda step : isLinux(step),
name = 'QMake Linux',
env=linuxXmakeEnv,
description = 'create a make files for projects',
),
steps.ShellCommand(
command = ['make', 'clean'],
doStepIf = lambda step : self.isClean(step) and self.isLinux(step),
name = 'clean Linux',
description = 'clean old build data',
),
steps.Compile(
command = self.makeCommand,
name = 'Build Linux',
doStepIf = lambda step : self.isLinux(step),
res += [self.generateStep('make deploy',
platform,
'deploy project',
self.isDeploy)]
haltOnFailure = True,
description = 'run make for project',
),
steps.ShellCommand(
command= ['make', 'deploy'],
doStepIf = lambda step : self.isDeploy(step) and self.isLinux(step),
name = 'deploy Linux',
haltOnFailure = True,
description = 'deploy project ',
),
steps.Compile(
command= ['make', 'test'],
doStepIf = lambda step : self.isTest(step) and self.isLinux(step),
name = 'tests ',
haltOnFailure = True,
description = 'run autotests of project',
),
steps.ShellCommand(
command= ['make', 'release'],
doStepIf = lambda step : self.isRelease(step) and self.isLinux(step),
name = 'release Linux',
haltOnFailure = True,
description = 'release project, like push to store or online repository',
),
steps.ShellCommand(
command = ['make', 'distclean'],
doStepIf = lambda step : self.isLinux(step),
name = 'clean Linux makefiles',
description = 'clean old makefiles ',
),
res += [self.generateStep('make test',
platform,
'test project',
self.isTest)]
res += [self.generateStep('make release',
platform,
'release project',
self.isRelease)]
]
return list;
def AndroidSteps(self) :
list = [
steps.ShellCommand(
command = androidQmake,
haltOnFailure = True,
doStepIf = lambda step : self.isAndroid(step),
env=androidXmakeEnv,
name = 'QMake Android',
description = 'create a make files for projects',
),
steps.ShellCommand(
command = ['make', 'clean'],
doStepIf = lambda step : self.isClean(step) and self.isAndroid(step),
name = 'clean Android',
description = 'clean old build data',
),
steps.Compile(
command = self.makeCommand,
name = 'Build Android',
doStepIf = lambda step : self.isAndroid(step),
haltOnFailure = True,
description = 'run make for project',
),
steps.ShellCommand(
command= ['make', 'deploy'],
doStepIf = lambda step : self.isDeploy(step) and self.isAndroid(step),
name = 'deploy Android',
haltOnFailure = True,
description = 'deploy project ',
),
steps.ShellCommand(
command= ['make', 'release'],
doStepIf = lambda step : self.isRelease(step) and self.isAndroid(step),
name = 'release Android',
haltOnFailure = True,
description = 'release project, like push to store or online repository',
),
steps.ShellCommand(
command = ['make', 'distclean'],
doStepIf = lambda step : self.isAndroid(step),
name = 'clean Android makefiles',
description = 'clean old makefiles ',
),
]
return list;
def WinSteps(self) :
list = [
steps.ShellCommand(
command = self.windowsXmakeCmd,
name = 'QMake Windows',
haltOnFailure = True,
env=windowsXmakeEnv,
doStepIf = lambda step : isWin(step),
description = 'create a make files for projects',
),
steps.ShellCommand(
command = ['make', 'clean'],
doStepIf = lambda step : self.isClean(step) and self.isWin(step),
name = 'clean Windows',
description = 'clean old build data',
),
steps.Compile(
command = self.makeCommand,
name = 'Build Windows',
haltOnFailure = True,
doStepIf = lambda step : self.isWin(step),
description = 'run make for project',
),
steps.ShellCommand(
command= ['make', 'deploy'],
doStepIf = lambda step : self.isDeploy(step) and self.isWin(step),
name = 'deploy Windows',
haltOnFailure = True,
description = 'deploy project ',
),
steps.ShellCommand(
command= ['make', 'release'],
doStepIf = lambda step : self.isRelease(step) and self.isWin(step),
name = 'release Windows',
haltOnFailure = True,
description = 'release project, like push to store or online repository',
),
steps.ShellCommand(
command = ['make', 'distclean'],
doStepIf = lambda step : self.isWin(step),
name = 'clean Windows makefiles',
description = 'clean old makefiles ',
),
]
return list;
res += [self.generateStep('make distclean',
platform,
'release project',
lambda step: True)]
return res
def getFactory(self):
factory = self.getFactory();
factory = super().getFactory()
factory.addStep(
steps.Git(
repourl=util.Interpolate('%(prop:repository)s'),
branch=util.Interpolate('%(prop:branch)s'),
mode='full',
method = 'fresh',
method='fresh',
submodules=True,
name = 'git operations',
description = 'operations of git like pull clone fetch',
name='git operations',
description='operations of git like pull clone fetch',
)
);
)
factory.addSteps(self.LinuxSteps());
factory.addSteps(self.WinSteps());
factory.addSteps(self.AndroidSteps());
factory.addSteps(self.generatePlatformSteps('linux'))
factory.addSteps(self.generatePlatformSteps('windows'))
factory.addSteps(self.generatePlatformSteps('android'))
factory.addStep(
steps.DirectoryUpload(
workersrc = util.Interpolate('%(prop:copyFolder)s'),
masterdest = destDir,
url = destDirUrl,
doStepIf = lambda step : self.isDeploy(step),
name = 'copy buildet files',
description = 'copy buildet files to shared folder',
workersrc=util.Interpolate('%(prop:copyFolder)s'),
masterdest=self.destDir,
url=self.destDirUrl,
doStepIf=lambda step: self.isDeploy(step),
name='copy buildet files',
description='copy buildet files to shared folder',
)
);
)
factory.addStep(
steps.ShellCommand(
command= self.permission,
name = 'set permission',
haltOnFailure = True,
command=self.permission,
name='set permission',
haltOnFailure=True,
description = 'set permission for shared folder',
description='set permission for shared folder',
)
);
)
return factory
def getPropertyes():
return [
util.BooleanParameter(
name = 'Windows',
label = 'Windows version project',
default = True
name='Windows',
label='Windows version project',
default=True
),
util.BooleanParameter(
name = 'Linux',
label = 'Linux version project',
default = True
name='Linux',
label='Linux version project',
default=True
),
util.BooleanParameter(
name = 'Android',
label = 'Android version project',
default = True
name='Android',
label='Android version project',
default=True
),
util.BooleanParameter(
name = 'clean',
label = 'clean old build ',
default = True
name='clean',
label='clean old build ',
default=True
),
util.BooleanParameter(
name = 'deploy',
label = 'deploy project',
default = True
name='deploy',
label='deploy project',
default=True
),
util.BooleanParameter(
name = 'test',
label = 'test project ',
default = True
name='test',
label='test project ',
default=True
),
util.BooleanParameter(
name = 'release',
label = 'release project',
default = False
name='release',
label='release project',
default=False
),
util.StringParameter(
name = 'copyFolder',
label = 'Folder with buildet data',
default = "Distro"
name='copyFolder',
label='Folder with buildet data',
default="Distro"
),
]

@ -2,6 +2,7 @@
import json
from pathlib import Path
class SecretManager:
def __init__(self, jsFile):
@ -11,7 +12,6 @@ class SecretManager:
except:
pass
def getValue(self, key):
try:
return self.jsfile[key]