Skip to content

Commit

Permalink
Merge pull request #868 from owncloud/update-starlark-waitfor
Browse files Browse the repository at this point in the history
[tests-only] Use owncloudci/wait-for docker image and PHP 7.4
  • Loading branch information
phil-davis authored Dec 26, 2021
2 parents 9ce0644 + d528f97 commit 4216c12
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 63 deletions.
158 changes: 98 additions & 60 deletions .drone.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
OC_CI_ALPINE = "owncloudci/alpine:latest"
OC_CI_WAIT_FOR = "owncloudci/wait-for:latest"
OC_CI_NODEJS = "owncloudci/nodejs:14"
OC_UBUNTU = "owncloud/ubuntu:20.04"

dir = {
"base": "/var/www/owncloud",
"federated": "/var/www/owncloud/federated",
Expand All @@ -16,22 +21,7 @@ config = {
"codestyle": True,
"phpstan": True,
"javascript": False,
"phpunit": {
"allDatabases": {
"phpVersions": [
"7.3",
],
},
"reducedDatabases": {
"phpVersions": [
"7.4",
],
"databases": [
"mysql:8.0",
],
"coverage": False,
},
},
"phpunit": True,
"acceptance": False,
}

Expand Down Expand Up @@ -118,7 +108,7 @@ def codestyle(ctx):
return pipelines

default = {
"phpVersions": ["7.3"],
"phpVersions": ["7.4"],
}

if "defaults" in config:
Expand Down Expand Up @@ -202,7 +192,7 @@ def jscodestyle(ctx):
"steps": [
{
"name": "coding-standard-js",
"image": "owncloudci/nodejs:14",
"image": OC_CI_NODEJS,
"pull": "always",
"commands": [
"make test-js-style",
Expand Down Expand Up @@ -283,7 +273,7 @@ def phpstan(ctx):
return pipelines

default = {
"phpVersions": ["7.3"],
"phpVersions": ["7.4"],
"logLevel": "2",
"extraApps": {},
"enableApp": True,
Expand Down Expand Up @@ -360,7 +350,7 @@ def phan(ctx):
return pipelines

default = {
"phpVersions": ["7.3", "7.4"],
"phpVersions": ["7.4"],
}

if "defaults" in config:
Expand Down Expand Up @@ -431,7 +421,7 @@ def build(ctx):
return pipelines

default = {
"phpVersions": ["7.3"],
"phpVersions": ["7.4"],
"commands": [
"make dist",
],
Expand Down Expand Up @@ -630,7 +620,7 @@ def phpTests(ctx, testType, withCoverage):
errorFound = False

default = {
"phpVersions": ["7.3", "7.4"],
"phpVersions": ["7.4"],
"databases": [
"sqlite",
"mariadb:10.2",
Expand Down Expand Up @@ -1083,8 +1073,10 @@ def acceptance(ctx):
setupScality(testConfig["scalityS3"]) +
setupElasticSearch(testConfig["esVersion"]) +
testConfig["extraSetup"] +
waitForServer(testConfig["federatedServerNeeded"]) +
waitForEmailService(testConfig["emailNeeded"]) +
fixPermissions(testConfig["phpVersion"], testConfig["federatedServerNeeded"], params["selUserNeeded"]) +
waitForBrowserService(testConfig["phpVersion"], isWebUI) +
waitForBrowserService(testConfig["browser"]) +
[
({
"name": "acceptance-tests",
Expand Down Expand Up @@ -1171,7 +1163,7 @@ def sonarAnalysis(ctx, phpVersion = "7.4"):
"steps": [
{
"name": "clone",
"image": "owncloudci/alpine:latest",
"image": OC_CI_ALPINE,
"commands": [
"git clone https://github.com/%s.git ." % repo_slug,
"git checkout $DRONE_COMMIT",
Expand Down Expand Up @@ -1359,16 +1351,16 @@ def browserService(browser):

return []

def waitForBrowserService(phpVersion, isWebUi):
if isWebUi:
def waitForBrowserService(browser):
if browser in ["chrome", "firefox"]:
return [{
"name": "wait-for-selenium",
"image": "owncloudci/php:%s" % phpVersion,
"pull": "always",
"image": OC_CI_WAIT_FOR,
"commands": [
"wait-for-it -t 600 selenium:4444",
"wait-for -it selenium:4444 -t 600",
],
}]

return []

def emailService(emailNeeded):
Expand All @@ -1381,6 +1373,18 @@ def emailService(emailNeeded):

return []

def waitForEmailService(emailNeeded):
if emailNeeded:
return [{
"name": "wait-for-email",
"image": OC_CI_WAIT_FOR,
"commands": [
"wait-for -it email:8025 -t 600",
],
}]

return []

def ldapService(ldapNeeded):
if ldapNeeded:
return [{
Expand Down Expand Up @@ -1714,20 +1718,28 @@ def setupCeph(serviceParams):

createFirstBucket = serviceParams["createFirstBucket"] if "createFirstBucket" in serviceParams else True
setupCommands = serviceParams["setupCommands"] if "setupCommands" in serviceParams else [
"wait-for-it -t 600 ceph:80",
"cd %s/apps/files_primary_s3" % dir["server"],
"cp tests/drone/ceph.config.php %s/config" % dir["server"],
"cd %s" % dir["server"],
]

return [{
"name": "setup-ceph",
"image": "owncloudci/php:7.4",
"pull": "always",
"commands": setupCommands + ([
"./apps/files_primary_s3/tests/drone/create-bucket.sh",
] if createFirstBucket else []),
}]
return [
{
"name": "wait-for-ceph",
"image": OC_CI_WAIT_FOR,
"commands": [
"wait-for -it ceph:80 -t 600",
],
},
{
"name": "setup-ceph",
"image": "owncloudci/php:7.4",
"pull": "always",
"commands": setupCommands + ([
"./apps/files_primary_s3/tests/drone/create-bucket.sh",
] if createFirstBucket else []),
},
]

def setupScality(serviceParams):
if type(serviceParams) == "bool":
Expand All @@ -1742,37 +1754,65 @@ def setupScality(serviceParams):
createFirstBucket = serviceParams["createFirstBucket"] if "createFirstBucket" in serviceParams else True
createExtraBuckets = serviceParams["createExtraBuckets"] if "createExtraBuckets" in serviceParams else False
setupCommands = serviceParams["setupCommands"] if "setupCommands" in serviceParams else [
"wait-for-it -t 600 scality:8000",
"cd %s/apps/files_primary_s3" % dir["server"],
"cp tests/drone/%s %s/config" % (configFile, dir["server"]),
"cd %s" % dir["server"],
]

return [{
"name": "setup-scality",
"image": "owncloudci/php:7.4",
"pull": "always",
"commands": setupCommands + ([
"php occ s3:create-bucket owncloud --accept-warning",
] if createFirstBucket else []) + ([
"for I in $(seq 1 9); do php ./occ s3:create-bucket owncloud$I --accept-warning; done",
] if createExtraBuckets else []),
}]
return [
{
"name": "wait-for-scality",
"image": OC_CI_WAIT_FOR,
"commands": [
"wait-for -it scality:8000 -t 600",
],
},
{
"name": "setup-scality",
"image": "owncloudci/php:7.4",
"pull": "always",
"commands": setupCommands + ([
"php occ s3:create-bucket owncloud --accept-warning",
] if createFirstBucket else []) + ([
"for I in $(seq 1 9); do php ./occ s3:create-bucket owncloud$I --accept-warning; done",
] if createExtraBuckets else []),
},
]

def setupElasticSearch(esVersion):
if esVersion == "none":
return []

return [
{
"name": "wait-for-es",
"image": OC_CI_WAIT_FOR,
"commands": [
"wait-for -it elasticsearch:9200 -t 600",
],
},
{
"name": "setup-es",
"image": "owncloudci/php:7.4",
"pull": "always",
"commands": [
"cd %s" % dir["server"],
"php occ config:app:set search_elastic servers --value elasticsearch",
"php occ search:index:reset --force",
],
},
]

def waitForServer(federatedServerNeeded):
return [{
"name": "setup-es",
"image": "owncloudci/php:7.4",
"name": "wait-for-server",
"image": OC_CI_WAIT_FOR,
"pull": "always",
"commands": [
"cd %s" % dir["server"],
"php occ config:app:set search_elastic servers --value elasticsearch",
"wait-for-it -t 600 elasticsearch:9200",
"php occ search:index:reset --force",
],
"wait-for -it server:80 -t 600",
] + ([
"wait-for -it federated:80 -t 600",
] if federatedServerNeeded else []),
}]

def fixPermissions(phpVersion, federatedServerNeeded, selUserNeeded = False):
Expand All @@ -1782,10 +1822,8 @@ def fixPermissions(phpVersion, federatedServerNeeded, selUserNeeded = False):
"pull": "always",
"commands": [
"chown -R www-data %s" % dir["server"],
"wait-for-it -t 600 server:80",
] + ([
"chown -R www-data %s" % dir["federated"],
"wait-for-it -t 600 federated:80",
] if federatedServerNeeded else []) + ([
"chmod 777 /home/seluser/Downloads/",
] if selUserNeeded else []),
Expand All @@ -1798,7 +1836,7 @@ def fixPermissions(phpVersion, federatedServerNeeded, selUserNeeded = False):
def owncloudLog(server):
return [{
"name": "owncloud-log-%s" % server,
"image": "owncloud/ubuntu:18.04",
"image": OC_UBUNTU,
"pull": "always",
"detach": True,
"commands": [
Expand Down Expand Up @@ -1929,7 +1967,7 @@ def buildGithubCommentForBuildStopped(alternateSuiteName, earlyFail):
if (earlyFail):
return [{
"name": "build-github-comment-buildStop",
"image": "owncloud/ubuntu:16.04",
"image": OC_UBUNTU,
"pull": "always",
"commands": [
"echo ':boom: Acceptance tests pipeline <strong>%s</strong> failed. The build has been cancelled.\\n\\n${DRONE_BUILD_LINK}/${DRONE_JOB_NUMBER}${DRONE_STAGE_NUMBER}/1\\n' >> %s/comments.file" % (alternateSuiteName, dir["base"]),
Expand Down
6 changes: 4 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ parameters:
inferPrivatePropertyTypeFromConstructor: true
bootstrapFiles:
- %currentWorkingDirectory%/../../lib/base.php
excludes_analyse:
excludePaths:
- %currentWorkingDirectory%/appinfo/Migrations/*.php
- %currentWorkingDirectory%/appinfo/routes.php
ignoreErrors:

-
message: '#Property OCA\\Market\\Controller\\LocalAppsController::\$appManager is never read, only written.#'
path: lib/Controller/LocalAppsController.php
2 changes: 1 addition & 1 deletion vendor-bin/phpstan/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"phpstan/phpstan": "^0.12"
"phpstan/phpstan": "^1.2"
}
}

0 comments on commit 4216c12

Please sign in to comment.