Skip to content

Commit b090bda

Browse files
Merge pull request #73 from owncloud/update-drone-starlark-20191121
Implement current drone starlark code
2 parents a16c763 + 550355b commit b090bda

File tree

1 file changed

+106
-50
lines changed

1 file changed

+106
-50
lines changed

.drone.starlark

Lines changed: 106 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,23 @@ def phptests(testType):
552552
for item in default:
553553
params[item] = matrix[item] if item in matrix else default[item]
554554

555-
if ((config['app'] != 'files_primary_s3') and ((params['cephS3'] != False) or (params['scalityS3'] != False))):
555+
cephS3Params = params['cephS3']
556+
if type(cephS3Params) == "bool":
557+
cephS3Needed = cephS3Params
558+
filesPrimaryS3NeededForCeph = cephS3Params
559+
else:
560+
cephS3Needed = True
561+
filesPrimaryS3NeededForCeph = cephS3Params['filesPrimaryS3Needed'] if 'filesPrimaryS3Needed' in cephS3Params else True
562+
563+
scalityS3Params = params['scalityS3']
564+
if type(scalityS3Params) == "bool":
565+
scalityS3Needed = scalityS3Params
566+
filesPrimaryS3NeededForScality = scalityS3Params
567+
else:
568+
scalityS3Needed = True
569+
filesPrimaryS3NeededForScality = scalityS3Params['filesPrimaryS3Needed'] if 'filesPrimaryS3Needed' in scalityS3Params else True
570+
571+
if ((config['app'] != 'files_primary_s3') and (filesPrimaryS3NeededForCeph or filesPrimaryS3NeededForScality)):
556572
# If we are not already 'files_primary_s3' and we need S3 storage, then install the 'files_primary_s3' app
557573
extraAppsDict = {
558574
'files_primary_s3': 'composer install'
@@ -683,6 +699,7 @@ def acceptance():
683699
'runAllSuites': False,
684700
'runCoreTests': False,
685701
'numberOfParts': 1,
702+
'cron': '',
686703
}
687704

688705
if 'defaults' in config:
@@ -710,9 +727,23 @@ def acceptance():
710727
if isAPI or isCLI:
711728
params['browsers'] = ['']
712729

713-
needObjectStore = (params['cephS3'] != False) or (params['scalityS3'] != False)
730+
cephS3Params = params['cephS3']
731+
if type(cephS3Params) == "bool":
732+
cephS3Needed = cephS3Params
733+
filesPrimaryS3NeededForCeph = cephS3Params
734+
else:
735+
cephS3Needed = True
736+
filesPrimaryS3NeededForCeph = cephS3Params['filesPrimaryS3Needed'] if 'filesPrimaryS3Needed' in cephS3Params else True
714737

715-
if ((config['app'] != 'files_primary_s3') and (needObjectStore)):
738+
scalityS3Params = params['scalityS3']
739+
if type(scalityS3Params) == "bool":
740+
scalityS3Needed = scalityS3Params
741+
filesPrimaryS3NeededForScality = scalityS3Params
742+
else:
743+
scalityS3Needed = True
744+
filesPrimaryS3NeededForScality = scalityS3Params['filesPrimaryS3Needed'] if 'filesPrimaryS3Needed' in scalityS3Params else True
745+
746+
if ((config['app'] != 'files_primary_s3') and (filesPrimaryS3NeededForCeph or filesPrimaryS3NeededForScality)):
716747
# If we are not already 'files_primary_s3' and we need S3 object storage, then install the 'files_primary_s3' app
717748
extraAppsDict = {
718749
'files_primary_s3': 'composer install'
@@ -780,7 +811,7 @@ def acceptance():
780811
if params['ldapNeeded']:
781812
environment['TEST_EXTERNAL_USER_BACKENDS'] = True
782813

783-
if (needObjectStore):
814+
if (cephS3Needed or scalityS3Needed):
784815
environment['OC_TEST_ON_OBJECTSTORE'] = '1'
785816
if (params['cephS3'] != False):
786817
environment['S3_TYPE'] = 'ceph'
@@ -856,16 +887,18 @@ def acceptance():
856887
owncloudService(server, phpVersion, 'server', '/var/www/owncloud/server', False) +
857888
(owncloudService(server, phpVersion, 'federated', '/var/www/owncloud/federated', False) if params['federatedServerNeeded'] else []),
858889
'depends_on': [],
859-
'trigger': {
860-
'ref': [
861-
'refs/pull/**',
862-
'refs/tags/**'
863-
]
864-
}
890+
'trigger': {}
865891
}
866892

867-
for branch in config['branches']:
868-
result['trigger']['ref'].append('refs/heads/%s' % branch)
893+
if (params['cron'] == ''):
894+
result['trigger']['ref'] = [
895+
'refs/pull/**',
896+
'refs/tags/**'
897+
]
898+
for branch in config['branches']:
899+
result['trigger']['ref'].append('refs/heads/%s' % branch)
900+
else:
901+
result['trigger']['cron'] = params['cron']
869902

870903
pipelines.append(result)
871904

@@ -1005,38 +1038,50 @@ def ldapService(ldapNeeded):
10051038

10061039
return []
10071040

1008-
def scalityService(scalityS3):
1009-
if not scalityS3:
1010-
return []
1041+
def scalityService(serviceParams):
1042+
serviceEnvironment = {
1043+
'HOST_NAME': 'scality'
1044+
}
1045+
1046+
if type(serviceParams) == "bool":
1047+
if not serviceParams:
1048+
return []
1049+
else:
1050+
if 'extraEnvironment' in serviceParams:
1051+
for env in serviceParams['extraEnvironment']:
1052+
serviceEnvironment[env] = serviceParams['extraEnvironment'][env]
10111053

10121054
return [{
10131055
'name': 'scality',
10141056
'image': 'owncloudci/scality-s3server',
10151057
'pull': 'always',
1016-
'environment': {
1017-
'HOST_NAME': 'scality'
1018-
}
1058+
'environment': serviceEnvironment
10191059
}]
10201060

1061+
def cephService(serviceParams):
1062+
serviceEnvironment = {
1063+
'NETWORK_AUTO_DETECT': '4',
1064+
'RGW_NAME': 'ceph',
1065+
'CEPH_DEMO_UID': 'owncloud',
1066+
'CEPH_DEMO_ACCESS_KEY': 'owncloud123456',
1067+
'CEPH_DEMO_SECRET_KEY': 'secret123456',
1068+
}
10211069

1022-
def cephService(cephS3):
1023-
if not cephS3:
1024-
return []
1070+
if type(serviceParams) == "bool":
1071+
if not serviceParams:
1072+
return []
1073+
else:
1074+
if 'extraEnvironment' in serviceParams:
1075+
for env in serviceParams['extraEnvironment']:
1076+
serviceEnvironment[env] = serviceParams['extraEnvironment'][env]
10251077

10261078
return [{
10271079
'name': 'ceph',
10281080
'image': 'owncloudci/ceph:tag-build-master-jewel-ubuntu-16.04',
10291081
'pull': 'always',
1030-
'environment': {
1031-
'NETWORK_AUTO_DETECT': '4',
1032-
'RGW_NAME': 'ceph',
1033-
'CEPH_DEMO_UID': 'owncloud',
1034-
'CEPH_DEMO_ACCESS_KEY': 'owncloud123456',
1035-
'CEPH_DEMO_SECRET_KEY': 'secret123456',
1036-
}
1082+
'environment': serviceEnvironment
10371083
}]
10381084

1039-
10401085
def owncloudService(version, phpVersion, name = 'server', path = '/var/www/owncloud/server', ssl = True):
10411086
if ssl:
10421087
environment = {
@@ -1202,46 +1247,57 @@ def setupServerAndApp(phpVersion, logLevel):
12021247
]
12031248
}]
12041249

1205-
def setupCeph(cephS3):
1206-
if not cephS3:
1207-
return []
1250+
def setupCeph(serviceParams):
1251+
if type(serviceParams) == "bool":
1252+
if serviceParams:
1253+
# specify an empty dict that will get the defaults
1254+
serviceParams = {}
1255+
else:
1256+
return []
1257+
1258+
createFirstBucket = serviceParams['createFirstBucket'] if 'createFirstBucket' in serviceParams else True
1259+
setupCommands = serviceParams['setupCommands'] if 'setupCommands' in serviceParams else [
1260+
'wait-for-it -t 60 ceph:80',
1261+
'cd /var/www/owncloud/server/apps/files_primary_s3',
1262+
'cp tests/drone/ceph.config.php /var/www/owncloud/server/config',
1263+
'cd /var/www/owncloud/server',
1264+
]
12081265

12091266
return [{
12101267
'name': 'setup-ceph',
12111268
'image': 'owncloudci/php:7.0',
12121269
'pull': 'always',
1213-
'commands': [
1214-
'wait-for-it -t 60 ceph:80',
1215-
'cd /var/www/owncloud/server/apps/files_primary_s3',
1216-
'cp tests/drone/ceph.config.php /var/www/owncloud/server/config',
1217-
'cd /var/www/owncloud/server',
1270+
'commands': setupCommands + ([
12181271
'./apps/files_primary_s3/tests/drone/create-bucket.sh',
1219-
]
1272+
] if createFirstBucket else [])
12201273
}]
12211274

1222-
def setupScality(scalityS3):
1223-
if type(scalityS3) == "bool":
1224-
if scalityS3:
1275+
def setupScality(serviceParams):
1276+
if type(serviceParams) == "bool":
1277+
if serviceParams:
12251278
# specify an empty dict that will get the defaults
1226-
scalityS3 = {}
1279+
serviceParams = {}
12271280
else:
12281281
return []
12291282

1230-
specialConfig = '.' + scalityS3['config'] if 'config' in scalityS3 else ''
1283+
specialConfig = '.' + serviceParams['config'] if 'config' in serviceParams else ''
12311284
configFile = 'scality%s.config.php' % specialConfig
1232-
createExtraBuckets = scalityS3['createExtraBuckets'] if 'createExtraBuckets' in scalityS3 else False
1285+
createFirstBucket = serviceParams['createFirstBucket'] if 'createFirstBucket' in serviceParams else True
1286+
createExtraBuckets = serviceParams['createExtraBuckets'] if 'createExtraBuckets' in serviceParams else False
1287+
setupCommands = serviceParams['setupCommands'] if 'setupCommands' in serviceParams else [
1288+
'wait-for-it -t 60 scality:8000',
1289+
'cd /var/www/owncloud/server/apps/files_primary_s3',
1290+
'cp tests/drone/%s /var/www/owncloud/server/config' % configFile,
1291+
'cd /var/www/owncloud/server'
1292+
]
12331293

12341294
return [{
12351295
'name': 'setup-scality',
12361296
'image': 'owncloudci/php:7.0',
12371297
'pull': 'always',
1238-
'commands': [
1239-
'wait-for-it -t 60 scality:8000',
1240-
'cd /var/www/owncloud/server/apps/files_primary_s3',
1241-
'cp tests/drone/%s /var/www/owncloud/server/config' % configFile,
1242-
'cd /var/www/owncloud/server',
1298+
'commands': setupCommands + ([
12431299
'php occ s3:create-bucket owncloud --accept-warning'
1244-
] + ([
1300+
] if createFirstBucket else []) + ([
12451301
'for I in $(seq 1 9); do php ./occ s3:create-bucket owncloud$I --accept-warning; done',
12461302
] if createExtraBuckets else [])
12471303
}]

0 commit comments

Comments
 (0)