Merge pull request #2635 from owncloud/skip_on_docs_only

skip on docs only
This commit is contained in:
Willy Kloucek
2021-11-09 07:28:04 +01:00
committed by GitHub
2 changed files with 70 additions and 43 deletions
+70 -39
View File
@@ -133,10 +133,10 @@ def main(ctx):
pipelines = [] pipelines = []
test_pipelines = \ test_pipelines = \
checkForRecentBuilds(ctx) + \
[buildOcisBinaryForTesting(ctx)] + \ [buildOcisBinaryForTesting(ctx)] + \
testOcisModules(ctx) + \ testOcisModules(ctx) + \
testPipelines(ctx) + \ testPipelines(ctx)
checkForRecentBuilds(ctx)
build_release_pipelines = \ build_release_pipelines = \
dockerReleases(ctx) + \ dockerReleases(ctx) + \
@@ -149,36 +149,22 @@ def main(ctx):
docs(ctx), docs(ctx),
] ]
if ctx.build.event == "cron": test_pipelines.append(
pipelines = test_pipelines + [ pipelineDependsOn(
pipelineDependsOn( purgeBuildArtifactCache(ctx, "ocis-binary-amd64"),
purgeBuildArtifactCache(ctx, "ocis-binary-amd64"), testPipelines(ctx),
testPipelines(ctx), ),
), )
] + example_deploys(ctx)
elif (ctx.build.event == "pull_request" and "[docs-only]" in ctx.build.title) or \ pipelines = test_pipelines + build_release_pipelines + build_release_helpers
(ctx.build.event != "pull_request" and "[docs-only]" in (ctx.build.title + ctx.build.message)):
# [docs-only] is not taken from PR messages, but from commit messages
pipelines = [docs(ctx), changelog(ctx)]
else: pipelines = \
test_pipelines.append( pipelines + \
pipelineDependsOn( pipelinesDependsOn(
purgeBuildArtifactCache(ctx, "ocis-binary-amd64"), example_deploys(ctx),
testPipelines(ctx), pipelines,
),
) )
pipelines = test_pipelines + build_release_pipelines + build_release_helpers
pipelines = \
pipelines + \
pipelinesDependsOn(
example_deploys(ctx),
pipelines,
)
# always append notification step # always append notification step
pipelines.append( pipelines.append(
pipelineDependsOn( pipelineDependsOn(
@@ -268,7 +254,7 @@ def testPipelines(ctx):
return pipelines return pipelines
def testOcisModule(ctx, module): def testOcisModule(ctx, module):
steps = makeGenerate(module) + [ steps = skipIfUnchanged(ctx, "unit-tests") + makeGenerate(module) + [
{ {
"name": "golangci-lint", "name": "golangci-lint",
"image": OC_CI_GOLANG, "image": OC_CI_GOLANG,
@@ -339,7 +325,8 @@ def buildOcisBinaryForTesting(ctx):
"os": "linux", "os": "linux",
"arch": "amd64", "arch": "amd64",
}, },
"steps": makeGenerate("") + "steps": skipIfUnchanged(ctx, "acceptance-tests") +
makeGenerate("") +
build() + build() +
rebuildBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin/ocis"), rebuildBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin/ocis"),
"trigger": { "trigger": {
@@ -387,6 +374,7 @@ def uploadScanResults(ctx):
"git checkout $DRONE_COMMIT", "git checkout $DRONE_COMMIT",
], ],
}, },
] + skipIfUnchanged(ctx, "unit-tests") + [
{ {
"name": "sync-from-cache", "name": "sync-from-cache",
"image": MINIO_MC, "image": MINIO_MC,
@@ -447,7 +435,7 @@ def localApiTests(ctx, storage, suite, accounts_hash_difficulty = 4):
"os": "linux", "os": "linux",
"arch": "amd64", "arch": "amd64",
}, },
"steps": restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin/ocis") + "steps": skipIfUnchanged(ctx, "acceptance-tests") + restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin/ocis") +
ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) +
cloneCoreRepos() + [ cloneCoreRepos() + [
{ {
@@ -495,7 +483,7 @@ def coreApiTests(ctx, part_number = 1, number_of_parts = 1, storage = "ocis", ac
"os": "linux", "os": "linux",
"arch": "amd64", "arch": "amd64",
}, },
"steps": restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin/ocis") + "steps": skipIfUnchanged(ctx, "acceptance-tests") + restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin/ocis") +
ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) +
cloneCoreRepos() + [ cloneCoreRepos() + [
{ {
@@ -606,7 +594,7 @@ def uiTestPipeline(ctx, filterTags, early_fail, runPart = 1, numberOfParts = 1,
"os": "linux", "os": "linux",
"arch": "amd64", "arch": "amd64",
}, },
"steps": restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin/ocis") + "steps": skipIfUnchanged(ctx, "acceptance-tests") + restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin/ocis") +
ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + [ ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + [
{ {
"name": "webUITests", "name": "webUITests",
@@ -670,7 +658,7 @@ def accountsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4):
"os": "linux", "os": "linux",
"arch": "amd64", "arch": "amd64",
}, },
"steps": restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin/ocis") + "steps": skipIfUnchanged(ctx, "acceptance-tests") + restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin/ocis") +
ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + [ ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + [
{ {
"name": "WebUIAcceptanceTests", "name": "WebUIAcceptanceTests",
@@ -735,7 +723,7 @@ def settingsUITests(ctx, storage = "ocis", accounts_hash_difficulty = 4):
"os": "linux", "os": "linux",
"arch": "amd64", "arch": "amd64",
}, },
"steps": restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin/ocis") + "steps": skipIfUnchanged(ctx, "acceptance-tests") + restoreBuildArtifactCache(ctx, "ocis-binary-amd64", "ocis/bin/ocis") +
ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + [ ocisServer(storage, accounts_hash_difficulty, [stepVolumeOC10Tests]) + [
{ {
"name": "WebUIAcceptanceTests", "name": "WebUIAcceptanceTests",
@@ -802,7 +790,7 @@ def failEarly(ctx, early_fail):
Returns: Returns:
pipeline steps pipeline steps
""" """
if ("full-ci" in ctx.build.title.lower() or ctx.build.event == "cron"): if ("full-ci" in ctx.build.title.lower() or ctx.build.event == "tag" or ctx.build.event == "cron"):
return [] return []
if (early_fail): if (early_fail):
@@ -884,7 +872,8 @@ def dockerRelease(ctx, arch):
"os": "linux", "os": "linux",
"arch": arch, "arch": arch,
}, },
"steps": makeGenerate("") + [ "steps": skipIfUnchanged(ctx, "build-docker") +
makeGenerate("") + [
{ {
"name": "build", "name": "build",
"image": OC_CI_GOLANG, "image": OC_CI_GOLANG,
@@ -957,7 +946,8 @@ def dockerEos(ctx):
"os": "linux", "os": "linux",
"arch": "amd64", "arch": "amd64",
}, },
"steps": makeGenerate("") + [ "steps": skipIfUnchanged(ctx, "build-docker") +
makeGenerate("") + [
{ {
"name": "build", "name": "build",
"image": OC_CI_GOLANG, "image": OC_CI_GOLANG,
@@ -1059,7 +1049,8 @@ def binaryRelease(ctx, name):
"os": "linux", "os": "linux",
"arch": "amd64", "arch": "amd64",
}, },
"steps": makeGenerate("") + [ "steps": skipIfUnchanged(ctx, "build-binary") +
makeGenerate("") + [
{ {
"name": "build", "name": "build",
"image": OC_CI_GOLANG, "image": OC_CI_GOLANG,
@@ -1558,6 +1549,46 @@ def build():
}, },
] ]
def skipIfUnchanged(ctx, type):
if ("full-ci" in ctx.build.title.lower() or ctx.build.event == "tag" or ctx.build.event == "cron"):
return []
base = [
"^docs/.*",
"^changelog/.*",
]
unit = [
".*_test.go$",
]
acceptance = [
"^tests/acceptance/.*",
]
skip = []
if type == "acceptance-tests":
skip = base + unit
if type == "unit-tests":
skip = base + acceptance
if type == "build-binary" or type == "build-docker":
skip = base + unit + acceptance
if len(skip) == 0:
return []
return [{
"name": "skip-if-unchanged",
"image": "owncloudci/drone-skip-pipeline",
"pull": "always",
"settings": {
"ALLOW_SKIP_CHANGED": skip,
},
"when": {
"event": [
"pull_request",
],
},
}]
def example_deploys(ctx): def example_deploys(ctx):
latest_configs = [ latest_configs = [
"cs3_users_ocis/latest.yml", "cs3_users_ocis/latest.yml",
@@ -35,10 +35,6 @@ You may add flags to your commit message or PR title in order to speed up pipeli
- `[full-ci]`: deactivates the fail early mechanism and runs all available test (as default only smoke tests are run) - `[full-ci]`: deactivates the fail early mechanism and runs all available test (as default only smoke tests are run)
- `[docs-only]`: please add this flag, if you only changed documentation. This will only trigger documentation related CI steps.
- `[tests-only]`: please add this flag, if you only changed tests or test-related tooling. You do not need to add a changelog for tests-only changes.
### Knowledge base ### Knowledge base
- My pipeline fails because some CI related files or commands are missing. - My pipeline fails because some CI related files or commands are missing.