Skip to content

Commit bea7f5d

Browse files
Merge pull request #1122 from owncloud/allow-php-unit-tests-to-run-against-different-core-versions
[tests-only] [full-ci] Allow PHP unit tests to run against different core versions
2 parents 6c175e9 + c9a26ee commit bea7f5d

1 file changed

Lines changed: 84 additions & 77 deletions

File tree

.drone.star

Lines changed: 84 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ def phpTests(ctx, testType, withCoverage):
728728
# Note: do not run Oracle by default in PRs.
729729
prDefault = {
730730
"phpVersions": [DEFAULT_PHP_VERSION],
731+
"servers": ["daily-master-qa"],
731732
"databases": [
732733
"sqlite",
733734
"mariadb:10.2",
@@ -752,6 +753,7 @@ def phpTests(ctx, testType, withCoverage):
752753
# The default PHP unit test settings for the cron job (usually runs nightly).
753754
cronDefault = {
754755
"phpVersions": [DEFAULT_PHP_VERSION],
756+
"servers": ["daily-master-qa"],
755757
"databases": [
756758
"sqlite",
757759
"mariadb:10.2",
@@ -849,87 +851,92 @@ def phpTests(ctx, testType, withCoverage):
849851
else:
850852
command = "make test-php-integration"
851853

852-
for db in params["databases"]:
853-
keyString = "-" + category if params["includeKeyInMatrixName"] else ""
854-
name = "%s%s-php%s-%s" % (testType, keyString, phpVersion, db.replace(":", ""))
855-
maxLength = 50
856-
nameLength = len(name)
857-
if nameLength > maxLength:
858-
print("Error: generated phpunit stage name of length", nameLength, "is not supported. The maximum length is " + str(maxLength) + ".", name)
859-
errorFound = True
860-
861-
result = {
862-
"kind": "pipeline",
863-
"type": "docker",
864-
"name": name,
865-
"workspace": {
866-
"base": dir["base"],
867-
"path": "server/apps/%s" % ctx.repo.name,
868-
},
869-
"steps": skipIfUnchanged(ctx, "unit-tests") +
870-
installCore(ctx, "daily-master-qa", db, False) +
871-
installAppPhp(ctx, phpVersion) +
872-
installExtraApps(phpVersion, params["extraApps"]) +
873-
setupServerAndApp(ctx, phpVersion, params["logLevel"], False, params["enableApp"]) +
874-
setupCeph(params["cephS3"]) +
875-
setupScality(params["scalityS3"]) +
876-
params["extraSetup"] +
877-
[
878-
{
879-
"name": "%s-tests" % testType,
880-
"image": OC_CI_PHP % phpVersion,
881-
"environment": params["extraEnvironment"],
882-
"commands": params["extraCommandsBeforeTestRun"] + [
883-
command,
884-
],
885-
},
886-
] + params["extraTeardown"],
887-
"services": databaseService(db) +
888-
cephService(params["cephS3"]) +
889-
scalityService(params["scalityS3"]) +
890-
params["extraServices"],
891-
"depends_on": [],
892-
"trigger": {
893-
"ref": [
894-
"refs/pull/**",
895-
"refs/tags/**",
896-
],
897-
},
898-
}
854+
for server in params["servers"]:
855+
for db in params["databases"]:
856+
keyString = "-" + category if params["includeKeyInMatrixName"] else ""
857+
if len(params["servers"]) > 1:
858+
serverString = "-%s" % server.replace("daily-", "").replace("-qa", "")
859+
else:
860+
serverString = ""
861+
name = "%s%s-php%s%s-%s" % (testType, keyString, phpVersion, serverString, db.replace(":", ""))
862+
maxLength = 50
863+
nameLength = len(name)
864+
if nameLength > maxLength:
865+
print("Error: generated phpunit stage name of length", nameLength, "is not supported. The maximum length is " + str(maxLength) + ".", name)
866+
errorFound = True
899867

900-
if params["coverage"]:
901-
result["steps"].append({
902-
"name": "coverage-rename",
903-
"image": OC_CI_PHP % phpVersion,
904-
"commands": [
905-
"mv tests/output/clover.xml tests/output/clover-%s.xml" % (name),
906-
],
907-
})
908-
result["steps"].append({
909-
"name": "coverage-cache-1",
910-
"image": PLUGINS_S3,
911-
"settings": {
912-
"endpoint": {
913-
"from_secret": "cache_s3_endpoint",
914-
},
915-
"bucket": "cache",
916-
"source": "tests/output/clover-%s.xml" % (name),
917-
"target": "%s/%s" % (ctx.repo.slug, ctx.build.commit + "-${DRONE_BUILD_NUMBER}"),
918-
"path_style": True,
919-
"strip_prefix": "tests/output",
920-
"access_key": {
921-
"from_secret": "cache_s3_access_key",
922-
},
923-
"secret_key": {
924-
"from_secret": "cache_s3_secret_key",
925-
},
868+
result = {
869+
"kind": "pipeline",
870+
"type": "docker",
871+
"name": name,
872+
"workspace": {
873+
"base": dir["base"],
874+
"path": "server/apps/%s" % ctx.repo.name,
875+
},
876+
"steps": skipIfUnchanged(ctx, "unit-tests") +
877+
installCore(ctx, server, db, False) +
878+
installAppPhp(ctx, phpVersion) +
879+
installExtraApps(phpVersion, params["extraApps"]) +
880+
setupServerAndApp(ctx, phpVersion, params["logLevel"], False, params["enableApp"]) +
881+
setupCeph(params["cephS3"]) +
882+
setupScality(params["scalityS3"]) +
883+
params["extraSetup"] +
884+
[
885+
{
886+
"name": "%s-tests" % testType,
887+
"image": OC_CI_PHP % phpVersion,
888+
"environment": params["extraEnvironment"],
889+
"commands": params["extraCommandsBeforeTestRun"] + [
890+
command,
891+
],
892+
},
893+
] + params["extraTeardown"],
894+
"services": databaseService(db) +
895+
cephService(params["cephS3"]) +
896+
scalityService(params["scalityS3"]) +
897+
params["extraServices"],
898+
"depends_on": [],
899+
"trigger": {
900+
"ref": [
901+
"refs/pull/**",
902+
"refs/tags/**",
903+
],
926904
},
927-
})
905+
}
906+
907+
if params["coverage"]:
908+
result["steps"].append({
909+
"name": "coverage-rename",
910+
"image": OC_CI_PHP % phpVersion,
911+
"commands": [
912+
"mv tests/output/clover.xml tests/output/clover-%s.xml" % (name),
913+
],
914+
})
915+
result["steps"].append({
916+
"name": "coverage-cache-1",
917+
"image": PLUGINS_S3,
918+
"settings": {
919+
"endpoint": {
920+
"from_secret": "cache_s3_endpoint",
921+
},
922+
"bucket": "cache",
923+
"source": "tests/output/clover-%s.xml" % (name),
924+
"target": "%s/%s" % (ctx.repo.slug, ctx.build.commit + "-${DRONE_BUILD_NUMBER}"),
925+
"path_style": True,
926+
"strip_prefix": "tests/output",
927+
"access_key": {
928+
"from_secret": "cache_s3_access_key",
929+
},
930+
"secret_key": {
931+
"from_secret": "cache_s3_secret_key",
932+
},
933+
},
934+
})
928935

929-
for branch in config["branches"]:
930-
result["trigger"]["ref"].append("refs/heads/%s" % branch)
936+
for branch in config["branches"]:
937+
result["trigger"]["ref"].append("refs/heads/%s" % branch)
931938

932-
pipelines.append(result)
939+
pipelines.append(result)
933940

934941
if errorFound:
935942
return False

0 commit comments

Comments
 (0)