Merge pull request #2653 from owncloud/update-ci-images

update ci images and early fail
This commit is contained in:
Willy Kloucek authored and GitHub committed 2021-11-02 08:00:50 +01:00
commit dcfcf68584
1 file changed
+106 -121
+106 -121
View File
@@ -1,3 +1,14 @@
"""oCIS CI defintion
"""
# images
OC_CI_ALPINE = "owncloudci/alpine:latest"
OC_CI_GOLANG = "owncloudci/golang:1.17"
OC_CI_NODEJS = "owncloudci/nodejs:14"
OC_CI_PHP = "owncloudci/php:7.4"
MINIO_MC = "minio/mc:RELEASE.2021-10-07T04-19-58Z"
# configuration
config = { config = {
"modules": [ "modules": [
# if you add a module here please also add it to the root level Makefile # if you add a module here please also add it to the root level Makefile
@@ -260,7 +271,7 @@ def testOcisModule(ctx, module):
steps = makeGenerate(module) + [ steps = makeGenerate(module) + [
{ {
"name": "golangci-lint", "name": "golangci-lint",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": [ "commands": [
"mkdir -p cache/checkstyle", "mkdir -p cache/checkstyle",
"make -C %s ci-golangci-lint" % (module), "make -C %s ci-golangci-lint" % (module),
@@ -270,7 +281,7 @@ def testOcisModule(ctx, module):
}, },
{ {
"name": "test", "name": "test",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": [ "commands": [
"mkdir -p cache/coverage", "mkdir -p cache/coverage",
"make -C %s test" % (module), "make -C %s test" % (module),
@@ -378,7 +389,7 @@ def uploadScanResults(ctx):
}, },
{ {
"name": "sync-from-cache", "name": "sync-from-cache",
"image": "minio/mc:RELEASE.2021-03-23T05-46-11Z", "image": MINIO_MC,
"environment": { "environment": {
"MC_HOST_cachebucket": { "MC_HOST_cachebucket": {
"from_secret": "cache_s3_connection_url", "from_secret": "cache_s3_connection_url",
@@ -405,7 +416,7 @@ def uploadScanResults(ctx):
}, },
{ {
"name": "purge-cache", "name": "purge-cache",
"image": "minio/mc:RELEASE.2021-03-23T05-46-11Z", "image": MINIO_MC,
"environment": { "environment": {
"MC_HOST_cachebucket": { "MC_HOST_cachebucket": {
"from_secret": "cache_s3_connection_url", "from_secret": "cache_s3_connection_url",
@@ -426,10 +437,7 @@ def uploadScanResults(ctx):
} }
def localApiTests(ctx, storage, suite, accounts_hash_difficulty = 4): def localApiTests(ctx, storage, suite, accounts_hash_difficulty = 4):
earlyFail = config["localApiTests"]["earlyFail"] if "earlyFail" in config["localApiTests"] else False early_fail = config["localApiTests"]["earlyFail"] if "earlyFail" in config["localApiTests"] else False
if ("full-ci" in ctx.build.title.lower() or ctx.build.event == "cron"):
earlyFail = False
return { return {
"kind": "pipeline", "kind": "pipeline",
@@ -444,7 +452,7 @@ def localApiTests(ctx, storage, suite, accounts_hash_difficulty = 4):
cloneCoreRepos() + [ cloneCoreRepos() + [
{ {
"name": "localApiTests-%s-%s" % (suite, storage), "name": "localApiTests-%s-%s" % (suite, storage),
"image": "owncloudci/php:7.4", "image": OC_CI_PHP,
"environment": { "environment": {
"TEST_SERVER_URL": "https://ocis-server:9200", "TEST_SERVER_URL": "https://ocis-server:9200",
"OCIS_REVA_DATA_ROOT": "%s" % ("/srv/app/tmp/ocis/owncloud/data/" if storage == "owncloud" else ""), "OCIS_REVA_DATA_ROOT": "%s" % ("/srv/app/tmp/ocis/owncloud/data/" if storage == "owncloud" else ""),
@@ -463,7 +471,7 @@ def localApiTests(ctx, storage, suite, accounts_hash_difficulty = 4):
], ],
"volumes": [stepVolumeOC10Tests], "volumes": [stepVolumeOC10Tests],
}, },
] + buildGithubCommentForBuildStopped("localApiTests-%s-%s" % (suite, storage), earlyFail) + githubComment(earlyFail) + stopBuild(earlyFail), ] + failEarly(ctx, early_fail),
"services": redisForOCStorage(storage), "services": redisForOCStorage(storage),
"depends_on": getPipelineNames([buildOcisBinaryForTesting(ctx)]), "depends_on": getPipelineNames([buildOcisBinaryForTesting(ctx)]),
"trigger": { "trigger": {
@@ -477,10 +485,7 @@ def localApiTests(ctx, storage, suite, accounts_hash_difficulty = 4):
} }
def coreApiTests(ctx, part_number = 1, number_of_parts = 1, storage = "ocis", accounts_hash_difficulty = 4): def coreApiTests(ctx, part_number = 1, number_of_parts = 1, storage = "ocis", accounts_hash_difficulty = 4):
earlyFail = config["apiTests"]["earlyFail"] if "earlyFail" in config["apiTests"] else False early_fail = config["apiTests"]["earlyFail"] if "earlyFail" in config["apiTests"] else False
if ("full-ci" in ctx.build.title.lower() or ctx.build.event == "cron"):
earlyFail = False
return { return {
"kind": "pipeline", "kind": "pipeline",
@@ -495,7 +500,7 @@ def coreApiTests(ctx, part_number = 1, number_of_parts = 1, storage = "ocis", ac
cloneCoreRepos() + [ cloneCoreRepos() + [
{ {
"name": "oC10ApiTests-%s-storage-%s" % (storage, part_number), "name": "oC10ApiTests-%s-storage-%s" % (storage, part_number),
"image": "owncloudci/php:7.4", "image": OC_CI_PHP,
"environment": { "environment": {
"TEST_SERVER_URL": "https://ocis-server:9200", "TEST_SERVER_URL": "https://ocis-server:9200",
"OCIS_REVA_DATA_ROOT": "%s" % ("/srv/app/tmp/ocis/owncloud/data/" if storage == "owncloud" else ""), "OCIS_REVA_DATA_ROOT": "%s" % ("/srv/app/tmp/ocis/owncloud/data/" if storage == "owncloud" else ""),
@@ -515,7 +520,7 @@ def coreApiTests(ctx, part_number = 1, number_of_parts = 1, storage = "ocis", ac
], ],
"volumes": [stepVolumeOC10Tests], "volumes": [stepVolumeOC10Tests],
}, },
] + buildGithubCommentForBuildStopped("Core-API-Tests-%s-storage-%s" % (storage, part_number), earlyFail) + githubComment(earlyFail) + stopBuild(earlyFail), ] + failEarly(ctx, early_fail),
"services": redisForOCStorage(storage), "services": redisForOCStorage(storage),
"depends_on": getPipelineNames([buildOcisBinaryForTesting(ctx)]), "depends_on": getPipelineNames([buildOcisBinaryForTesting(ctx)]),
"trigger": { "trigger": {
@@ -556,9 +561,6 @@ def uiTests(ctx):
filterTags = params["filterTags"] filterTags = params["filterTags"]
earlyFail = params["earlyFail"] earlyFail = params["earlyFail"]
if ("full-ci" in ctx.build.title.lower() or ctx.build.event == "cron"):
earlyFail = False
if ("full-ci" in ctx.build.title.lower() or ctx.build.event == "tag" or ctx.build.event == "cron"): if ("full-ci" in ctx.build.title.lower() or ctx.build.event == "tag" or ctx.build.event == "cron"):
numberOfParts = params["numberOfParts"] numberOfParts = params["numberOfParts"]
skipExceptParts = params["skipExceptParts"] skipExceptParts = params["skipExceptParts"]
@@ -576,7 +578,7 @@ def uiTests(ctx):
return pipelines return pipelines
def uiTestPipeline(ctx, filterTags, earlyFail, runPart = 1, numberOfParts = 1, storage = "ocis", uniqueName = "", accounts_hash_difficulty = 4): def uiTestPipeline(ctx, filterTags, early_fail, runPart = 1, numberOfParts = 1, storage = "ocis", uniqueName = "", accounts_hash_difficulty = 4):
standardFilterTags = "not @skipOnOCIS and not @skip and not @notToImplementOnOCIS and not @federated-server-needed" standardFilterTags = "not @skipOnOCIS and not @skip and not @notToImplementOnOCIS and not @federated-server-needed"
if filterTags == "": if filterTags == "":
finalFilterTags = standardFilterTags finalFilterTags = standardFilterTags
@@ -608,7 +610,7 @@ def uiTestPipeline(ctx, filterTags, earlyFail, runPart = 1, numberOfParts = 1, s
ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + [ ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + [
{ {
"name": "webUITests", "name": "webUITests",
"image": "owncloudci/nodejs:14", "image": OC_CI_NODEJS,
"environment": { "environment": {
"SERVER_HOST": "https://ocis-server:9200", "SERVER_HOST": "https://ocis-server:9200",
"BACKEND_HOST": "https://ocis-server:9200", "BACKEND_HOST": "https://ocis-server:9200",
@@ -640,7 +642,7 @@ def uiTestPipeline(ctx, filterTags, earlyFail, runPart = 1, numberOfParts = 1, s
"path": "/uploads", "path": "/uploads",
}], }],
}, },
] + buildGithubCommentForBuildStopped("Web-Tests-ocis-%s-storage-%s" % (storage, runPart), earlyFail) + githubComment(earlyFail) + stopBuild(earlyFail), ] + failEarly(ctx, early_fail),
"services": selenium(), "services": selenium(),
"volumes": [pipelineVolumeOC10Tests] + "volumes": [pipelineVolumeOC10Tests] +
[{ [{
@@ -658,10 +660,7 @@ def uiTestPipeline(ctx, filterTags, earlyFail, runPart = 1, numberOfParts = 1, s
} }
def accountsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4): def accountsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4):
earlyFail = config["accountsUITests"]["earlyFail"] if "earlyFail" in config["accountsUITests"] else False early_fail = config["accountsUITests"]["earlyFail"] if "earlyFail" in config["accountsUITests"] else False
if ("full-ci" in ctx.build.title.lower() or ctx.build.event == "cron"):
earlyFail = False
return { return {
"kind": "pipeline", "kind": "pipeline",
@@ -675,7 +674,7 @@ def accountsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4):
ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + [ ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + [
{ {
"name": "WebUIAcceptanceTests", "name": "WebUIAcceptanceTests",
"image": "owncloudci/nodejs:14", "image": OC_CI_NODEJS,
"environment": { "environment": {
"SERVER_HOST": "https://ocis-server:9200", "SERVER_HOST": "https://ocis-server:9200",
"BACKEND_HOST": "https://ocis-server:9200", "BACKEND_HOST": "https://ocis-server:9200",
@@ -708,7 +707,7 @@ def accountsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4):
"path": "/uploads", "path": "/uploads",
}], }],
}, },
] + buildGithubCommentForBuildStopped("accountsUITests", earlyFail) + githubComment(earlyFail) + stopBuild(earlyFail), ] + failEarly(ctx, early_fail),
"services": selenium(), "services": selenium(),
"volumes": [stepVolumeOC10Tests] + "volumes": [stepVolumeOC10Tests] +
[{ [{
@@ -726,10 +725,7 @@ def accountsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4):
} }
def settingsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4): def settingsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4):
earlyFail = config["settingsUITests"]["earlyFail"] if "earlyFail" in config["settingsUITests"] else False early_fail = config["settingsUITests"]["earlyFail"] if "earlyFail" in config["settingsUITests"] else False
if ("full-ci" in ctx.build.title.lower() or ctx.build.event == "cron"):
earlyFail = False
return { return {
"kind": "pipeline", "kind": "pipeline",
@@ -743,7 +739,7 @@ def settingsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4):
ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + [ ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + [
{ {
"name": "WebUIAcceptanceTests", "name": "WebUIAcceptanceTests",
"image": "owncloudci/nodejs:14", "image": OC_CI_NODEJS,
"environment": { "environment": {
"SERVER_HOST": "https://ocis-server:9200", "SERVER_HOST": "https://ocis-server:9200",
"BACKEND_HOST": "https://ocis-server:9200", "BACKEND_HOST": "https://ocis-server:9200",
@@ -774,7 +770,7 @@ def settingsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4):
"path": "/uploads", "path": "/uploads",
}], }],
}, },
] + buildGithubCommentForBuildStopped("settingsUITests", earlyFail) + githubComment(earlyFail) + stopBuild(earlyFail), ] + failEarly(ctx, early_fail),
"services": [ "services": [
{ {
"name": "redis", "name": "redis",
@@ -796,79 +792,68 @@ def settingsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4):
}, },
} }
def stopBuild(earlyFail): def failEarly(ctx, early_fail):
if (earlyFail): """failEarly sends posts a comment about the failed pipeline to the github pr and then kills all pipelines of the current build
return [{
"name": "stop-build", Args:
"image": "drone/cli:alpine", ctx: drone passes a context with information which the pipeline can be adapted to
"environment": { early_fail: boolean if an early fail should happen or not
"DRONE_SERVER": "https://drone.owncloud.com",
"DRONE_TOKEN": { Returns:
"from_secret": "drone_token", pipeline steps
"""
if ("full-ci" in ctx.build.title.lower() or ctx.build.event == "cron"):
return []
if (early_fail):
return [
{
"name": "github-comment",
"image": "thegeeklab/drone-github-comment:1",
"settings": {
"message": ":boom: Acceptance test [<strong>${DRONE_STAGE_NAME}</strong>](${DRONE_BUILD_LINK}/${DRONE_STAGE_NUMBER}/1) failed. Further test are cancelled...",
"key": "pr-${DRONE_PULL_REQUEST}", #TODO: we could delete the comment after a successfull CI run
"update": "true",
"api_key": {
"from_secret": "github_token",
},
},
"when": {
"status": [
"failure",
],
"event": [
"pull_request",
],
}, },
}, },
"commands": [ {
"drone build stop owncloud/ocis ${DRONE_BUILD_NUMBER}", "name": "stop-build",
], "image": "drone/cli:alpine",
"when": { # # https://github.com/drone/runner-go/blob/0bd0f8fc31c489817572060d17c6e24aaa487470/pipeline/runtime/const.go#L95-L102
"status": [ # "failure": "fail-fast",
"failure", # would be an alternative, but is currently broken
"environment": {
"DRONE_SERVER": "https://drone.owncloud.com",
"DRONE_TOKEN": {
"from_secret": "drone_token",
},
},
"commands": [
"drone build stop owncloud/ocis ${DRONE_BUILD_NUMBER}",
], ],
"event": [ "when": {
"pull_request", "status": [
], "failure",
}, ],
}] "event": [
"pull_request",
else: ],
return []
def buildGithubCommentForBuildStopped(alternateSuiteName, earlyFail):
if (earlyFail):
return [{
"name": "build-github-comment-buildStop",
"image": "owncloud/ubuntu:20.04",
"commands": [
'echo "<details><summary>:boom: Acceptance tests <strong>%s</strong> failed. The build is cancelled...</summary>\\n\\n" >> /drone/src/comments.file' % alternateSuiteName,
],
"when": {
"status": [
"failure",
],
"event": [
"pull_request",
],
},
}]
else:
return []
def githubComment(earlyFail):
if (earlyFail):
return [{
"name": "github-comment",
"image": "jmccann/drone-github-comment:1",
"settings": {
"message_file": "/drone/src/comments.file",
},
"environment": {
"GITHUB_TOKEN": {
"from_secret": "github_token",
}, },
}, },
"when": { ]
"status": [
"failure",
],
"event": [
"pull_request",
],
},
}]
else: return []
return []
def dockerReleases(ctx): def dockerReleases(ctx):
pipelines = [] pipelines = []
@@ -902,7 +887,7 @@ def dockerRelease(ctx, arch):
"steps": makeGenerate("") + [ "steps": makeGenerate("") + [
{ {
"name": "build", "name": "build",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": [ "commands": [
"make -C ocis release-linux-docker", "make -C ocis release-linux-docker",
], ],
@@ -975,7 +960,7 @@ def dockerEos(ctx):
"steps": makeGenerate("") + [ "steps": makeGenerate("") + [
{ {
"name": "build", "name": "build",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": [ "commands": [
"make -C ocis release-linux-docker", "make -C ocis release-linux-docker",
], ],
@@ -1077,14 +1062,14 @@ def binaryRelease(ctx, name):
"steps": makeGenerate("") + [ "steps": makeGenerate("") + [
{ {
"name": "build", "name": "build",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": [ "commands": [
"make -C ocis release-%s" % (name), "make -C ocis release-%s" % (name),
], ],
}, },
{ {
"name": "finish", "name": "finish",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": [ "commands": [
"make -C ocis release-finish", "make -C ocis release-finish",
], ],
@@ -1108,7 +1093,7 @@ def binaryRelease(ctx, name):
}, },
{ {
"name": "changelog", "name": "changelog",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": [ "commands": [
"make changelog CHANGELOG_VERSION=%s" % ctx.build.ref.replace("refs/tags/v", "").split("-")[0], "make changelog CHANGELOG_VERSION=%s" % ctx.build.ref.replace("refs/tags/v", "").split("-")[0],
], ],
@@ -1240,21 +1225,21 @@ def changelog(ctx):
"steps": [ "steps": [
{ {
"name": "generate", "name": "generate",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": [ "commands": [
"make -C ocis changelog", "make -C ocis changelog",
], ],
}, },
{ {
"name": "diff", "name": "diff",
"image": "owncloudci/alpine:latest", "image": OC_CI_ALPINE,
"commands": [ "commands": [
"git diff", "git diff",
], ],
}, },
{ {
"name": "output", "name": "output",
"image": "owncloudci/alpine:latest", "image": OC_CI_ALPINE,
"commands": [ "commands": [
"cat CHANGELOG.md", "cat CHANGELOG.md",
], ],
@@ -1342,19 +1327,19 @@ def docs(ctx):
"steps": [ "steps": [
{ {
"name": "docs-generate", "name": "docs-generate",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": ["make -C %s docs-generate" % (module) for module in config["modules"]], "commands": ["make -C %s docs-generate" % (module) for module in config["modules"]],
}, },
{ {
"name": "prepare", "name": "prepare",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": [ "commands": [
"make -C docs docs-copy", "make -C docs docs-copy",
], ],
}, },
{ {
"name": "test", "name": "test",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": [ "commands": [
"make -C docs test", "make -C docs test",
], ],
@@ -1382,7 +1367,7 @@ def docs(ctx):
}, },
{ {
"name": "list and remove temporary files", "name": "list and remove temporary files",
"image": "owncloudci/alpine:latest", "image": OC_CI_ALPINE,
"commands": [ "commands": [
"tree docs/hugo/public", "tree docs/hugo/public",
"rm -rf docs/hugo", "rm -rf docs/hugo",
@@ -1425,7 +1410,7 @@ def makeGenerate(module):
return [ return [
{ {
"name": "generate nodejs", "name": "generate nodejs",
"image": "owncloudci/nodejs:14", "image": OC_CI_NODEJS,
"commands": [ "commands": [
"%s ci-node-generate" % (make), "%s ci-node-generate" % (make),
], ],
@@ -1433,7 +1418,7 @@ def makeGenerate(module):
}, },
{ {
"name": "generate go", "name": "generate go",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": [ "commands": [
"%s ci-go-generate" % (make), "%s ci-go-generate" % (make),
], ],
@@ -1501,7 +1486,7 @@ def ocisServer(storage, accounts_hash_difficulty = 4, volumes = []):
return [ return [
{ {
"name": "ocis-server", "name": "ocis-server",
"image": "owncloudci/alpine:latest", "image": OC_CI_ALPINE,
"detach": True, "detach": True,
"environment": environment, "environment": environment,
"commands": [ "commands": [
@@ -1523,7 +1508,7 @@ def cloneCoreRepos():
return [ return [
{ {
"name": "clone-core-repos", "name": "clone-core-repos",
"image": "owncloudci/alpine:latest", "image": OC_CI_ALPINE,
"commands": [ "commands": [
"source /drone/src/.drone.env", "source /drone/src/.drone.env",
"git clone -b master --depth=1 https://github.com/owncloud/testing.git /srv/app/tmp/testing", "git clone -b master --depth=1 https://github.com/owncloud/testing.git /srv/app/tmp/testing",
@@ -1565,7 +1550,7 @@ def build():
return [ return [
{ {
"name": "build", "name": "build",
"image": "owncloudci/golang:1.17", "image": OC_CI_GOLANG,
"commands": [ "commands": [
"make -C ocis build", "make -C ocis build",
], ],
@@ -1667,14 +1652,14 @@ def checkStarlark():
"steps": [ "steps": [
{ {
"name": "format-check-starlark", "name": "format-check-starlark",
"image": "owncloudci/bazel-buildifier", "image": "owncloudci/bazel-buildifier:latest",
"commands": [ "commands": [
"buildifier --mode=check .drone.star", "buildifier --mode=check .drone.star",
], ],
}, },
{ {
"name": "show-diff", "name": "show-diff",
"image": "owncloudci/bazel-buildifier", "image": "owncloudci/bazel-buildifier:latest",
"commands": [ "commands": [
"buildifier --mode=fix .drone.star", "buildifier --mode=fix .drone.star",
"git diff", "git diff",
@@ -1742,7 +1727,7 @@ def genericCachePurge(ctx, name, cache_key):
"steps": [ "steps": [
{ {
"name": "purge-cache", "name": "purge-cache",
"image": "minio/mc:RELEASE.2021-03-23T05-46-11Z", "image": MINIO_MC,
"failure": "ignore", "failure": "ignore",
"environment": { "environment": {
"MC_HOST_cache": { "MC_HOST_cache": {