Skip to content

Commit

Permalink
Update .drone.star from activity app
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Aug 30, 2021
1 parent a974652 commit 0882013
Showing 1 changed file with 96 additions and 11 deletions.
107 changes: 96 additions & 11 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def main(ctx):
return before + coverageTests + afterCoverageTests + nonCoverageTests + stages + after

def beforePipelines(ctx):
return codestyle(ctx) + jscodestyle(ctx) + checkForRecentBuilds(ctx) + phpstan(ctx) + phan(ctx) + checkStarlark()
return codestyle(ctx) + jscodestyle(ctx) + checkForRecentBuilds(ctx) + phpstan(ctx) + phan(ctx) + phplint(ctx) + checkStarlark()

def coveragePipelines(ctx):
# All unit test pipelines that have coverage or other test analysis reported
Expand Down Expand Up @@ -312,6 +312,7 @@ def phpstan(ctx):
"phpVersions": ["7.2"],
"logLevel": "2",
"extraApps": {},
"enableApp": True,
}

if "defaults" in config:
Expand Down Expand Up @@ -351,7 +352,7 @@ def phpstan(ctx):
"steps": installCore(ctx, "daily-master-qa", "sqlite", False) +
installApp(ctx, phpVersion) +
installExtraApps(phpVersion, params["extraApps"]) +
setupServerAndApp(ctx, phpVersion, params["logLevel"]) +
setupServerAndApp(ctx, phpVersion, params["logLevel"], False, params["enableApp"]) +
[
{
"name": "phpstan",
Expand Down Expand Up @@ -553,6 +554,7 @@ def javascript(ctx, withCoverage):
"extraCommandsBeforeTestRun": [],
"extraTeardown": [],
"skip": False,
"enableApp": True,
}

if "defaults" in config:
Expand Down Expand Up @@ -594,12 +596,12 @@ def javascript(ctx, withCoverage):
},
"steps": installCore(ctx, "daily-master-qa", "sqlite", False) +
installApp(ctx, "7.4") +
setupServerAndApp(ctx, "7.4", params["logLevel"]) +
setupServerAndApp(ctx, "7.4", params["logLevel"], False, params["enableApp"]) +
params["extraSetup"] +
[
{
"name": "js-tests",
"image": "owncloudci/php:8.0",
"image": "owncloudci/nodejs:%s" % getNodeJsVersion(),
"pull": "always",
"environment": params["extraEnvironment"],
"commands": params["extraCommandsBeforeTestRun"] + [
Expand Down Expand Up @@ -674,6 +676,7 @@ def phpTests(ctx, testType, withCoverage):
"extraApps": {},
"extraTeardown": [],
"skip": False,
"enableApp": True,
}

if "defaults" in config:
Expand Down Expand Up @@ -766,7 +769,7 @@ def phpTests(ctx, testType, withCoverage):
"steps": installCore(ctx, "daily-master-qa", db, False) +
installApp(ctx, phpVersion) +
installExtraApps(phpVersion, params["extraApps"]) +
setupServerAndApp(ctx, phpVersion, params["logLevel"]) +
setupServerAndApp(ctx, phpVersion, params["logLevel"], False, params["enableApp"]) +
setupCeph(params["cephS3"]) +
setupScality(params["scalityS3"]) +
params["extraSetup"] +
Expand Down Expand Up @@ -880,6 +883,7 @@ def acceptance(ctx):
"debugSuites": [],
"skipExceptParts": [],
"earlyFail": True,
"enableApp": True,
}

if "defaults" in config:
Expand Down Expand Up @@ -1096,7 +1100,7 @@ def acceptance(ctx):
(installFederated(testConfig["server"], testConfig["phpVersion"], testConfig["logLevel"], testConfig["database"], federationDbSuffix) + owncloudLog("federated") if testConfig["federatedServerNeeded"] else []) +
installApp(ctx, testConfig["phpVersion"]) +
installExtraApps(testConfig["phpVersion"], testConfig["extraApps"]) +
setupServerAndApp(ctx, testConfig["phpVersion"], testConfig["logLevel"], testConfig["federatedServerNeeded"]) +
setupServerAndApp(ctx, testConfig["phpVersion"], testConfig["logLevel"], testConfig["federatedServerNeeded"], params["enableApp"]) +
owncloudLog("server") +
setupCeph(testConfig["cephS3"]) +
setupScality(testConfig["scalityS3"]) +
Expand Down Expand Up @@ -1393,10 +1397,11 @@ def elasticSearchService(esVersion):

return [{
"name": "elasticsearch",
"image": "webhippie/elasticsearch:%s" % esVersion,
"image": "owncloudops/elasticsearch:%s" % esVersion,
"pull": "always",
"environment": {
"ELASTICSEARCH_PLUGINS_INSTALL": "ingest-attachment",
"ELASTICSEARCH_ROOT_LOG_LEVEL": "warn",
"ELASTICSEARCH_BOOTSTRAP_MEMORY_LOCK": "false",
},
}]

Expand Down Expand Up @@ -1509,6 +1514,13 @@ def getDbDatabase(db):

return "owncloud"

def getNodeJsVersion():
if "nodeJsVersion" not in config:
# We use nodejs 14 as the default
return "14"
else:
return config["nodeJsVersion"]

def cacheRestore():
return [{
"name": "cache-restore",
Expand Down Expand Up @@ -1625,7 +1637,23 @@ def installApp(ctx, phpVersion):
if "appInstallCommand" not in config:
return []

return [{
if "buildJsDeps" not in config:
installJsDeps = False
else:
installJsDeps = config["buildJsDeps"]

return [
{
"name": "install-app-js-%s" % config["app"],
"image": "owncloudci/nodejs:%s" % getNodeJsVersion(),
"pull": "always",
"commands": [
"cd /var/www/owncloud/server/apps/%s" % config["app"],
"make install-js-deps",
"make build-dev",
],
},
] if installJsDeps else [] + [{
"name": "install-app-%s" % ctx.repo.name,
"image": "owncloudci/php:%s" % phpVersion,
"pull": "always",
Expand All @@ -1635,15 +1663,15 @@ def installApp(ctx, phpVersion):
],
}]

def setupServerAndApp(ctx, phpVersion, logLevel, federatedServerNeeded = False):
def setupServerAndApp(ctx, phpVersion, logLevel, federatedServerNeeded = False, enableApp = True):
return [{
"name": "setup-server-%s" % ctx.repo.name,
"image": "owncloudci/php:%s" % phpVersion,
"pull": "always",
"commands": [
"cd %s" % dir["server"],
"php occ a:l",
"php occ a:e %s" % ctx.repo.name,
"php occ a:e %s" % ctx.repo.name if enableApp else "",
"php occ a:e testing",
"php occ a:l",
"php occ config:system:set trusted_domains 1 --value=server",
Expand Down Expand Up @@ -1952,3 +1980,60 @@ def checkStarlark():
],
},
}]

def phplint(ctx):
pipelines = []

if "phplint" not in config:
return pipelines

if type(config["phplint"]) == "bool":
if not config["phplint"]:
return pipelines

result = {
"kind": "pipeline",
"type": "docker",
"name": "lint-test",
"workspace": {
"base": "/var/www/owncloud",
"path": "server/apps/%s" % ctx.repo.name,
},
"steps": installNPM() +
lintTest(),
"depends_on": [],
"trigger": {
"ref": [
"refs/heads/master",
"refs/tags/**",
"refs/pull/**",
],
},
}

for branch in config["branches"]:
result["trigger"]["ref"].append("refs/heads/%s" % branch)

pipelines.append(result)

return pipelines

def installNPM():
return [{
"name": "npm-install",
"image": "owncloudci/nodejs:%s" % getNodeJsVersion(),
"pull": "always",
"commands": [
"yarn install --frozen-lockfile",
],
}]

def lintTest():
return [{
"name": "lint-test",
"image": "owncloudci/php:7.2",
"pull": "always",
"commands": [
"make test-lint",
],
}]

0 comments on commit 0882013

Please sign in to comment.