Skip to content

Commit

Permalink
Merge pull request #7502 from owncloud/short-term-cache
Browse files Browse the repository at this point in the history
[full-ci] [tests-only] Short term cache stored in cache bucket
  • Loading branch information
individual-it authored Aug 23, 2022
2 parents 66656bc + 2d02224 commit 06aa024
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -767,10 +767,7 @@ def main(ctx):

pipelines = pipelines + deploys + pipelinesDependsOn(
[
purgeBuildArtifactCache(ctx, "yarn"),
purgeBuildArtifactCache(ctx, "playwright"),
purgeBuildArtifactCache(ctx, "tests-yarn"),
purgeBuildArtifactCache(ctx, "web-dist"),
purgeBuildArtifactCache(ctx),
],
pipelines,
)
Expand Down Expand Up @@ -2932,7 +2929,7 @@ def skipIfUnchanged(ctx, type):

return []

def genericCache(name, action, mounts, cache_key):
def genericCache(name, action, mounts, cache_path):
rebuild = "false"
restore = "false"
if action == "rebuild":
Expand All @@ -2958,16 +2955,18 @@ def genericCache(name, action, mounts, cache_key):
"secret_key": {
"from_secret": "cache_s3_secret_key",
},
"filename": "%s.tar" % (cache_key),
"filename": "%s.tar" % (name),
"path": cache_path,
"fallback_path": cache_path,
},
}
return step

def genericCachePurge(ctx, name, cache_key):
def genericCachePurge(flush_path):
return {
"kind": "pipeline",
"type": "docker",
"name": "purge_%s" % (name),
"name": "purge_build_artifact_cache",
"platform": {
"os": "linux",
"arch": "amd64",
Expand All @@ -2983,12 +2982,12 @@ def genericCachePurge(ctx, name, cache_key):
"endpoint": {
"from_secret": "cache_s3_endpoint",
},
"flush": True,
"flush_age": "14",
"secret_key": {
"from_secret": "cache_s3_secret_key",
},
"filename": "%s.tar" % (cache_key),
"flush": True,
"flush_age": 1,
"flush_path": flush_path,
},
},
],
Expand All @@ -3006,12 +3005,14 @@ def genericCachePurge(ctx, name, cache_key):
}

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)
cache_path = "%s/%s/%s" % ("cache", ctx.repo.slug, ctx.build.commit + "-${DRONE_BUILD_NUMBER}")
name = "%s_build_artifact_cache" % (name)
return genericCache(name, action, [path], cache_path)

if action == "purge":
return genericCachePurge(ctx, name, cache_key)
flush_path = "%s/%s" % ("cache", ctx.repo.slug)
return genericCachePurge(flush_path)
return []

def restoreBuildArtifactCache(ctx, name, path):
Expand All @@ -3020,8 +3021,8 @@ def restoreBuildArtifactCache(ctx, name, path):
def rebuildBuildArtifactCache(ctx, name, path):
return [genericBuildArtifactCache(ctx, name, "rebuild", path)]

def purgeBuildArtifactCache(ctx, name):
return genericBuildArtifactCache(ctx, name, "purge", [])
def purgeBuildArtifactCache(ctx):
return genericBuildArtifactCache(ctx, "", "purge", [])

def pipelineSanityChecks(ctx, pipelines):
"""pipelineSanityChecks helps the CI developers to find errors before running it
Expand Down

0 comments on commit 06aa024

Please sign in to comment.