Merge pull request #961 from owncloud/cache_ocis_build_artifact_for_testing
[tests-only] cache ocis build artifact for testing
This commit is contained in:
1 file changed
+145
-16
+145
-16
@@ -107,7 +107,6 @@ def getPipelineNames(pipelines=[]):
|
|||||||
names.append(pipeline['name'])
|
names.append(pipeline['name'])
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
||||||
def main(ctx):
|
def main(ctx):
|
||||||
"""main is the entrypoint for drone
|
"""main is the entrypoint for drone
|
||||||
|
|
||||||
@@ -117,9 +116,11 @@ def main(ctx):
|
|||||||
Returns:
|
Returns:
|
||||||
none
|
none
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pipelines = []
|
pipelines = []
|
||||||
|
|
||||||
before = \
|
before = \
|
||||||
|
[ buildOcisBinaryForTesting(ctx) ] + \
|
||||||
testOcisModules(ctx) + \
|
testOcisModules(ctx) + \
|
||||||
testPipelines(ctx)
|
testPipelines(ctx)
|
||||||
|
|
||||||
@@ -134,6 +135,9 @@ def main(ctx):
|
|||||||
releaseSubmodule(ctx),
|
releaseSubmodule(ctx),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
purge = purgeBuildArtifactCache(ctx, 'ocis-binary-amd64')
|
||||||
|
purge['depends_on'] = getPipelineNames(testPipelines(ctx))
|
||||||
|
|
||||||
after = [
|
after = [
|
||||||
manifest(ctx),
|
manifest(ctx),
|
||||||
changelog(ctx),
|
changelog(ctx),
|
||||||
@@ -141,6 +145,7 @@ def main(ctx):
|
|||||||
badges(ctx),
|
badges(ctx),
|
||||||
docs(ctx),
|
docs(ctx),
|
||||||
updateDeployment(ctx),
|
updateDeployment(ctx),
|
||||||
|
purge,
|
||||||
]
|
]
|
||||||
|
|
||||||
if ctx.build.event == "cron":
|
if ctx.build.event == "cron":
|
||||||
@@ -150,7 +155,12 @@ def main(ctx):
|
|||||||
|
|
||||||
pipelines = before + [ notify_pipeline ]
|
pipelines = before + [ notify_pipeline ]
|
||||||
|
|
||||||
elif '[docs-only]' in (ctx.build.title + ctx.build.message):
|
elif \
|
||||||
|
(ctx.build.event == "pull" and '[docs-only]' in ctx.build.title) \
|
||||||
|
or \
|
||||||
|
(ctx.build.event != "pull" and '[docs-only]' in (ctx.build.title + ctx.build.message)):
|
||||||
|
# [docs-only] is not taken from PR messages, but from commit messages
|
||||||
|
|
||||||
docs_pipeline = docs(ctx)
|
docs_pipeline = docs(ctx)
|
||||||
docs_pipeline['depends_on'] = []
|
docs_pipeline['depends_on'] = []
|
||||||
docs_pipelines = [ docs_pipeline ]
|
docs_pipelines = [ docs_pipeline ]
|
||||||
@@ -182,7 +192,6 @@ def testOcisModules(ctx):
|
|||||||
|
|
||||||
return pipelines + [coverage_upload]
|
return pipelines + [coverage_upload]
|
||||||
|
|
||||||
|
|
||||||
def testPipelines(ctx):
|
def testPipelines(ctx):
|
||||||
pipelines = [
|
pipelines = [
|
||||||
localApiTests(ctx, config['apiTests']['coreBranch'], config['apiTests']['coreCommit'], 'owncloud', 'apiOcisSpecific'),
|
localApiTests(ctx, config['apiTests']['coreBranch'], config['apiTests']['coreCommit'], 'owncloud', 'apiOcisSpecific'),
|
||||||
@@ -200,7 +209,7 @@ def testPipelines(ctx):
|
|||||||
return pipelines
|
return pipelines
|
||||||
|
|
||||||
def testOcisModule(ctx, module):
|
def testOcisModule(ctx, module):
|
||||||
steps = generate(module) + [
|
steps = makeGenerate(module) + [
|
||||||
{
|
{
|
||||||
'name': 'vet',
|
'name': 'vet',
|
||||||
'image': 'webhippie/golang:1.14',
|
'image': 'webhippie/golang:1.14',
|
||||||
@@ -307,6 +316,34 @@ def testOcisModule(ctx, module):
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def buildOcisBinaryForTesting(ctx):
|
||||||
|
return {
|
||||||
|
'kind': 'pipeline',
|
||||||
|
'type': 'docker',
|
||||||
|
'name': 'build_ocis_binary_for_testing',
|
||||||
|
'platform': {
|
||||||
|
'os': 'linux',
|
||||||
|
'arch': 'amd64',
|
||||||
|
},
|
||||||
|
'steps':
|
||||||
|
makeGenerate('ocis') +
|
||||||
|
build() +
|
||||||
|
rebuildBuildArtifactCache(ctx, 'ocis-binary-amd64', 'ocis/bin/ocis'),
|
||||||
|
'trigger': {
|
||||||
|
'ref': [
|
||||||
|
'refs/heads/master',
|
||||||
|
'refs/tags/v*',
|
||||||
|
'refs/pull/**',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'volumes': [
|
||||||
|
{
|
||||||
|
'name': 'gopath',
|
||||||
|
'temp': {},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
def uploadCoverage(ctx):
|
def uploadCoverage(ctx):
|
||||||
return {
|
return {
|
||||||
'kind': 'pipeline',
|
'kind': 'pipeline',
|
||||||
@@ -385,8 +422,7 @@ def localApiTests(ctx, coreBranch = 'master', coreCommit = '', storage = 'ownclo
|
|||||||
'arch': 'amd64',
|
'arch': 'amd64',
|
||||||
},
|
},
|
||||||
'steps':
|
'steps':
|
||||||
generate('ocis') +
|
restoreBuildArtifactCache(ctx, 'ocis-binary-amd64', 'ocis/bin/ocis') +
|
||||||
build() +
|
|
||||||
ocisServer(storage, accounts_hash_difficulty) +
|
ocisServer(storage, accounts_hash_difficulty) +
|
||||||
cloneCoreRepos(coreBranch, coreCommit) + [
|
cloneCoreRepos(coreBranch, coreCommit) + [
|
||||||
{
|
{
|
||||||
@@ -421,6 +457,7 @@ def localApiTests(ctx, coreBranch = 'master', coreCommit = '', storage = 'ownclo
|
|||||||
'temp': {},
|
'temp': {},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
'depends_on': getPipelineNames([buildOcisBinaryForTesting(ctx)]),
|
||||||
'trigger': {
|
'trigger': {
|
||||||
'ref': [
|
'ref': [
|
||||||
'refs/heads/master',
|
'refs/heads/master',
|
||||||
@@ -440,8 +477,7 @@ def coreApiTests(ctx, coreBranch = 'master', coreCommit = '', part_number = 1, n
|
|||||||
'arch': 'amd64',
|
'arch': 'amd64',
|
||||||
},
|
},
|
||||||
'steps':
|
'steps':
|
||||||
generate('ocis') +
|
restoreBuildArtifactCache(ctx, 'ocis-binary-amd64', 'ocis/bin/ocis') +
|
||||||
build() +
|
|
||||||
ocisServer(storage, accounts_hash_difficulty) +
|
ocisServer(storage, accounts_hash_difficulty) +
|
||||||
cloneCoreRepos(coreBranch, coreCommit) + [
|
cloneCoreRepos(coreBranch, coreCommit) + [
|
||||||
{
|
{
|
||||||
@@ -477,6 +513,7 @@ def coreApiTests(ctx, coreBranch = 'master', coreCommit = '', part_number = 1, n
|
|||||||
'temp': {},
|
'temp': {},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
'depends_on': getPipelineNames([buildOcisBinaryForTesting(ctx)]),
|
||||||
'trigger': {
|
'trigger': {
|
||||||
'ref': [
|
'ref': [
|
||||||
'refs/heads/master',
|
'refs/heads/master',
|
||||||
@@ -509,8 +546,7 @@ def uiTestPipeline(ctx, suiteName, phoenixBranch = 'master', phoenixCommit = '',
|
|||||||
'arch': 'amd64',
|
'arch': 'amd64',
|
||||||
},
|
},
|
||||||
'steps':
|
'steps':
|
||||||
generate('ocis') +
|
restoreBuildArtifactCache(ctx, 'ocis-binary-amd64', 'ocis/bin/ocis') +
|
||||||
build() +
|
|
||||||
ocisServer(storage, accounts_hash_difficulty) + [
|
ocisServer(storage, accounts_hash_difficulty) + [
|
||||||
{
|
{
|
||||||
'name': 'webUITests',
|
'name': 'webUITests',
|
||||||
@@ -562,6 +598,7 @@ def uiTestPipeline(ctx, suiteName, phoenixBranch = 'master', phoenixCommit = '',
|
|||||||
'temp': {}
|
'temp': {}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
'depends_on': getPipelineNames([buildOcisBinaryForTesting(ctx)]),
|
||||||
'trigger': {
|
'trigger': {
|
||||||
'ref': [
|
'ref': [
|
||||||
'refs/heads/master',
|
'refs/heads/master',
|
||||||
@@ -581,8 +618,7 @@ def accountsUITests(ctx, phoenixBranch, phoenixCommit, storage = 'owncloud', acc
|
|||||||
'arch': 'amd64',
|
'arch': 'amd64',
|
||||||
},
|
},
|
||||||
'steps':
|
'steps':
|
||||||
generate('ocis') +
|
restoreBuildArtifactCache(ctx, 'ocis-binary-amd64', 'ocis/bin/ocis') +
|
||||||
build() +
|
|
||||||
ocisServer(storage, accounts_hash_difficulty) + [
|
ocisServer(storage, accounts_hash_difficulty) + [
|
||||||
{
|
{
|
||||||
'name': 'WebUIAcceptanceTests',
|
'name': 'WebUIAcceptanceTests',
|
||||||
@@ -655,6 +691,7 @@ def accountsUITests(ctx, phoenixBranch, phoenixCommit, storage = 'owncloud', acc
|
|||||||
'temp': {}
|
'temp': {}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
'depends_on': getPipelineNames([buildOcisBinaryForTesting(ctx)]),
|
||||||
'trigger': {
|
'trigger': {
|
||||||
'ref': [
|
'ref': [
|
||||||
'refs/heads/master',
|
'refs/heads/master',
|
||||||
@@ -674,7 +711,7 @@ def docker(ctx, arch):
|
|||||||
'arch': arch,
|
'arch': arch,
|
||||||
},
|
},
|
||||||
'steps':
|
'steps':
|
||||||
generate('ocis') +
|
makeGenerate('ocis') +
|
||||||
build() + [
|
build() + [
|
||||||
{
|
{
|
||||||
'name': 'dryrun',
|
'name': 'dryrun',
|
||||||
@@ -747,7 +784,7 @@ def dockerEos(ctx):
|
|||||||
'arch': 'amd64',
|
'arch': 'amd64',
|
||||||
},
|
},
|
||||||
'steps':
|
'steps':
|
||||||
generate('ocis') +
|
makeGenerate('ocis') +
|
||||||
build() + [
|
build() + [
|
||||||
{
|
{
|
||||||
'name': 'dryrun-eos-ocis',
|
'name': 'dryrun-eos-ocis',
|
||||||
@@ -858,7 +895,7 @@ def binary(ctx, name):
|
|||||||
'arch': 'amd64',
|
'arch': 'amd64',
|
||||||
},
|
},
|
||||||
'steps':
|
'steps':
|
||||||
generate('ocis') + [
|
makeGenerate('ocis') + [
|
||||||
{
|
{
|
||||||
'name': 'build',
|
'name': 'build',
|
||||||
'image': 'webhippie/golang:1.14',
|
'image': 'webhippie/golang:1.14',
|
||||||
@@ -1312,7 +1349,7 @@ def docs(ctx):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def generate(module):
|
def makeGenerate(module):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
'name': 'generate',
|
'name': 'generate',
|
||||||
@@ -1541,3 +1578,95 @@ def build():
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def genericCache(name, action, mounts, cache_key):
|
||||||
|
rebuild = 'false'
|
||||||
|
restore = 'false'
|
||||||
|
if action == 'rebuild':
|
||||||
|
rebuild = 'true'
|
||||||
|
action = 'rebuild'
|
||||||
|
else:
|
||||||
|
restore = 'true'
|
||||||
|
action = 'restore'
|
||||||
|
|
||||||
|
step = {
|
||||||
|
'name': '%s_%s' %(action, name),
|
||||||
|
'image': 'meltwater/drone-cache:v1',
|
||||||
|
'pull': 'always',
|
||||||
|
'environment': {
|
||||||
|
'AWS_ACCESS_KEY_ID': {
|
||||||
|
'from_secret': 'cache_s3_access_key',
|
||||||
|
},
|
||||||
|
'AWS_SECRET_ACCESS_KEY': {
|
||||||
|
'from_secret': 'cache_s3_secret_key',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'settings': {
|
||||||
|
'endpoint': {
|
||||||
|
'from_secret': 'cache_s3_endpoint'
|
||||||
|
},
|
||||||
|
'bucket': 'cache',
|
||||||
|
'region': 'us-east-1', # not used at all, but failes if not given!
|
||||||
|
'path_style': 'true',
|
||||||
|
'cache_key': cache_key,
|
||||||
|
'rebuild': rebuild,
|
||||||
|
'restore': restore,
|
||||||
|
'mount': mounts,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return step
|
||||||
|
|
||||||
|
def genericCachePurge(ctx, name, cache_key):
|
||||||
|
return {
|
||||||
|
'kind': 'pipeline',
|
||||||
|
'type': 'docker',
|
||||||
|
'name': 'purge_%s' %(name),
|
||||||
|
'platform': {
|
||||||
|
'os': 'linux',
|
||||||
|
'arch': 'amd64',
|
||||||
|
},
|
||||||
|
'steps': [
|
||||||
|
{
|
||||||
|
'name': 'purge-cache',
|
||||||
|
'image': 'minio/mc',
|
||||||
|
'failure': 'ignore',
|
||||||
|
'environment': {
|
||||||
|
'MC_HOST_cache': {
|
||||||
|
'from_secret': 'cache_s3_connection_url'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'commands': [
|
||||||
|
'mc rm --recursive --force cache/cache/%s/%s' % (ctx.repo.name, cache_key),
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'trigger': {
|
||||||
|
'ref': [
|
||||||
|
'refs/heads/master',
|
||||||
|
'refs/tags/v*',
|
||||||
|
'refs/pull/**',
|
||||||
|
],
|
||||||
|
'status': [
|
||||||
|
'success',
|
||||||
|
'failure',
|
||||||
|
]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
def genericBuildArtifactCache(ctx, name, action, path):
|
||||||
|
name = '%s_build_artifact_cache' %(name)
|
||||||
|
cache_key = '%s/%s/%s' % (ctx.repo.slug, ctx.build.commit + '-${DRONE_BUILD_NUMBER}', name)
|
||||||
|
if action == "rebuild" or action == "restore":
|
||||||
|
return genericCache(name, action, [path], cache_key)
|
||||||
|
if action == "purge":
|
||||||
|
return genericCachePurge(ctx, name, cache_key)
|
||||||
|
return []
|
||||||
|
|
||||||
|
def restoreBuildArtifactCache(ctx, name, path):
|
||||||
|
return [genericBuildArtifactCache(ctx, name, 'restore', path)]
|
||||||
|
|
||||||
|
def rebuildBuildArtifactCache(ctx, name, path):
|
||||||
|
return [genericBuildArtifactCache(ctx, name, 'rebuild', path)]
|
||||||
|
|
||||||
|
def purgeBuildArtifactCache(ctx, name):
|
||||||
|
return genericBuildArtifactCache(ctx, name, 'purge', [])
|
||||||
Reference in new issue
Block a user