Skip to content

Commit

Permalink
Merge pull request #6565 from owncloud/update-drone-file
Browse files Browse the repository at this point in the history
[full-ci] Update drone starlark
  • Loading branch information
kiranparajuli589 authored Mar 18, 2022
2 parents 1a5dae6 + 452fc76 commit e77ce8e
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 110 deletions.
119 changes: 67 additions & 52 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,37 @@ FULL = 1
FEDERATED = 2
NOTIFICATIONS = 3

ALPINE_GIT = "alpine/git:latest"
DEEPDRIVER_DOCKER_ORACLE_XE_11G = "deepdiver/docker-oracle-xe-11g:latest"
DRONE_CLI_ALPINE = "drone/cli:alpine"
HENRICH_DOCKER_SAUCE_CONNECT = "henrrich/docker-sauce-connect:latest"
MELTWATER_DRONE_CACHE = "meltwater/drone-cache:v1"
MINIO_MC = "minio/mc:RELEASE.2021-03-23T05-46-11Z"
OC_CI_ALPINE = "owncloudci/alpine:latest"
OC_CI_BAZEL_BUILDIFIER = "owncloudci/bazel-buildifier"
OC_CI_CORE_NODEJS = "owncloudci/core:nodejs14"
OC_CI_DRONE_ANSIBLE = "owncloudci/drone-ansible:latest"
OC_CI_DRONE_CANCEL_PREVIOUS_BUILDS = "owncloudci/drone-cancel-previous-builds"
OC_CI_DRONE_SKIP_PIPELINE = "owncloudci/drone-skip-pipeline"
OC_CI_GOLANG = "owncloudci/golang:1.17"
OC_CI_HUGO = "owncloudci/hugo:0.89.4"
OC_CI_NODEJS = "owncloudci/nodejs:14"
OC_CI_PHP = "owncloudci/php:7.4"
OC_CI_WAIT_FOR = "owncloudci/wait-for:latest"
OC_TESTING_MIDDLEWARE = "owncloud/owncloud-test-middleware:1.4.0"
OC_UBUNTU = "owncloud/ubuntu:20.04"
PLUGINS_DOCKER = "plugins/docker:18.09"
PLUGINS_DOWNSTREAM = "plugins/downstream"
PLUGINS_GH_PAGES = "plugins/gh-pages:1"
PLUGINS_GIT_ACTION = "plugins/git-action:1"
PLUGINS_GITHUB_RELEASE = "plugins/github-release:1"
PLUGINS_S3 = "plugins/s3"
PLUGINS_SLACK = "plugins/slack:1"
SELENIUM_STANDALONE_CHROME_DEBUG = "selenium/standalone-chrome-debug:3.141.59"
SELENIUM_STANDALONE_FIREFOX_DEBUG = "selenium/standalone-firefox-debug:3.141.59"
SONARSOURCE_SONAR_SCANNER_CLI = "sonarsource/sonar-scanner-cli:latest"
THEGEEKLAB_DRONE_GITHUB_COMMENT = "thegeeklab/drone-github-comment:1"
TOOLHIPPIE_CALENS = "toolhippie/calens:latest"

OC10_VERSION = "latest"

Expand Down Expand Up @@ -761,7 +784,7 @@ def main(ctx):
return pipelines

def beforePipelines(ctx):
return checkForRecentBuilds(ctx) + \
return cancelPreviousBuilds() + \
checkStarlark() + \
documentation(ctx) + \
changelog(ctx) + \
Expand Down Expand Up @@ -838,29 +861,22 @@ def yarnlint(ctx):

return pipelines

def checkForRecentBuilds(ctx):
def cancelPreviousBuilds():
return [{
"kind": "pipeline",
"type": "docker",
"name": "stop-recent-builds",
"workspace": {
"base": dir["base"],
"path": config["app"],
"name": "cancel-previous-builds",
"clone": {
"disable": True,
},
"steps": [{
"name": "stop-recent-builds",
"image": "drone/cli:alpine",
"environment": {
"DRONE_SERVER": "https://drone.owncloud.com",
"name": "cancel-previous-builds",
"image": OC_CI_DRONE_CANCEL_PREVIOUS_BUILDS,
"settings": {
"DRONE_TOKEN": {
"from_secret": "drone_token",
},
},
"commands": [
"drone build ls %s --status running > %s/recentBuilds.txt" % (ctx.repo.slug, dir["web"]),
"drone build info %s ${DRONE_BUILD_NUMBER} > %s/thisBuildInfo.txt" % (ctx.repo.slug, dir["web"]),
"cd %s && ./tests/acceptance/cancelBuilds.sh" % dir["web"],
],
}],
"trigger": {
"ref": [
Expand Down Expand Up @@ -918,7 +934,7 @@ def changelog(ctx):
"steps": [
{
"name": "clone",
"image": "plugins/git-action:1",
"image": PLUGINS_GIT_ACTION,
"settings": {
"actions": [
"clone",
Expand All @@ -937,7 +953,7 @@ def changelog(ctx):
},
{
"name": "generate",
"image": "toolhippie/calens:latest",
"image": TOOLHIPPIE_CALENS,
"commands": [
"calens >| CHANGELOG.md",
],
Expand All @@ -951,14 +967,14 @@ def changelog(ctx):
},
{
"name": "output",
"image": "toolhippie/calens:latest",
"image": TOOLHIPPIE_CALENS,
"commands": [
"cat CHANGELOG.md",
],
},
{
"name": "publish",
"image": "plugins/git-action:1",
"image": PLUGINS_GIT_ACTION,
"settings": {
"actions": [
"commit",
Expand Down Expand Up @@ -1080,7 +1096,7 @@ def unitTests(ctx):
},
{
"name": "sonarcloud",
"image": "sonarsource/sonar-scanner-cli:latest",
"image": SONARSOURCE_SONAR_SCANNER_CLI,
"environment": sonar_env,
},
],
Expand Down Expand Up @@ -1451,7 +1467,7 @@ def notify():
"steps": [
{
"name": "notify-rocketchat",
"image": "plugins/slack:1",
"image": PLUGINS_SLACK,
"settings": {
"webhook": {
"from_secret": config["rocketchat"]["from_secret"],
Expand Down Expand Up @@ -1525,7 +1541,7 @@ def databaseService(db):
if dbName == "oracle":
return [{
"name": dbName,
"image": "deepdiver/docker-oracle-xe-11g:latest",
"image": DEEPDRIVER_DOCKER_ORACLE_XE_11G,
"environment": {
"ORACLE_USER": getDbUsername(db),
"ORACLE_PASSWORD": getDbPassword(db),
Expand All @@ -1540,7 +1556,7 @@ def browserService(alternateSuiteName, browser):
if browser == "chrome":
return [{
"name": "selenium",
"image": "selenium/standalone-chrome-debug:3.141.59",
"image": SELENIUM_STANDALONE_CHROME_DEBUG,
"volumes": [{
"name": "uploads",
"path": "/uploads",
Expand All @@ -1550,7 +1566,7 @@ def browserService(alternateSuiteName, browser):
if browser == "firefox":
return [{
"name": "selenium",
"image": "selenium/standalone-firefox-debug:3.141.59",
"image": SELENIUM_STANDALONE_FIREFOX_DEBUG,
"volumes": [{
"name": "uploads",
"path": "/uploads",
Expand All @@ -1560,7 +1576,7 @@ def browserService(alternateSuiteName, browser):
if not isLocalBrowser(browser):
return [{
"name": "saucelabs",
"image": "henrrich/docker-sauce-connect:latest",
"image": HENRICH_DOCKER_SAUCE_CONNECT,
"pull": "if-not-exists",
"environment": {
"SAUCE_USERNAME": {
Expand Down Expand Up @@ -1825,7 +1841,7 @@ def setupIntegrationWebApp():
def buildDockerImage():
return [{
"name": "docker",
"image": "plugins/docker:18.09",
"image": PLUGINS_DOCKER,
"settings": {
"username": {
"from_secret": "docker_username",
Expand Down Expand Up @@ -1858,7 +1874,7 @@ def buildRelease(ctx):
},
{
"name": "changelog",
"image": "toolhippie/calens:latest",
"image": TOOLHIPPIE_CALENS,
"commands": [
"calens --version %s -o dist/CHANGELOG.md -t changelog/CHANGELOG-Release.tmpl" % ctx.build.ref.replace("refs/tags/v", "").split("-")[0],
],
Expand All @@ -1870,7 +1886,7 @@ def buildRelease(ctx):
},
{
"name": "publish",
"image": "plugins/github-release:1",
"image": PLUGINS_GITHUB_RELEASE,
"settings": {
"api_key": {
"from_secret": "github_token",
Expand Down Expand Up @@ -1914,7 +1930,7 @@ def documentation(ctx):
},
{
"name": "test",
"image": "owncloudci/hugo:0.89.4",
"image": OC_CI_HUGO,
"commands": [
"cd hugo",
"hugo",
Expand All @@ -1929,7 +1945,7 @@ def documentation(ctx):
},
{
"name": "publish",
"image": "plugins/gh-pages:1",
"image": PLUGINS_GH_PAGES,
"settings": {
"username": {
"from_secret": "github_username",
Expand All @@ -1950,7 +1966,7 @@ def documentation(ctx):
},
{
"name": "downstream",
"image": "plugins/downstream",
"image": PLUGINS_DOWNSTREAM,
"settings": {
"server": "https://drone.owncloud.com/",
"token": {
Expand Down Expand Up @@ -2438,7 +2454,7 @@ def cacheOcisPipeline(ctx):
def getOcis():
return [{
"name": "get-ocis-from-cache",
"image": "minio/mc:RELEASE.2020-12-10T01-26-17Z",
"image": MINIO_MC,
"failure": "ignore",
"environment": {
"MC_HOST": {
Expand Down Expand Up @@ -2496,7 +2512,7 @@ def buildOCISCache():
def cacheOcis():
return [{
"name": "upload-ocis-bin",
"image": "plugins/s3",
"image": PLUGINS_S3,
"pull": "if-not-exists",
"settings": {
"bucket": "owncloud",
Expand All @@ -2519,7 +2535,7 @@ def cacheOcis():
def listRemoteCache():
return [{
"name": "list-ocis-bin-cache",
"image": "minio/mc:RELEASE.2020-12-10T01-26-17Z",
"image": MINIO_MC,
"failure": "ignore",
"environment": {
"MC_HOST": {
Expand All @@ -2540,7 +2556,7 @@ def listRemoteCache():
def stopBuild():
return [{
"name": "stop-build",
"image": "drone/cli:alpine",
"image": DRONE_CLI_ALPINE,
"environment": {
"DRONE_SERVER": "https://drone.owncloud.com",
"DRONE_TOKEN": {
Expand All @@ -2563,7 +2579,7 @@ def stopBuild():
def uploadScreenshots():
return [{
"name": "upload-screenshots",
"image": "plugins/s3",
"image": PLUGINS_S3,
"pull": "if-not-exists",
"settings": {
"bucket": {
Expand Down Expand Up @@ -2612,7 +2628,7 @@ def listScreenShots():
def uploadVisualDiff():
return [{
"name": "upload-diff-screenshots",
"image": "plugins/s3",
"image": PLUGINS_S3,
"pull": "if-not-exists",
"settings": {
"bucket": {
Expand Down Expand Up @@ -2647,7 +2663,7 @@ def uploadVisualDiff():
def uploadVisualScreenShots():
return [{
"name": "upload-latest-screenshots",
"image": "plugins/s3",
"image": PLUGINS_S3,
"pull": "if-not-exists",
"settings": {
"bucket": {
Expand Down Expand Up @@ -2774,13 +2790,13 @@ def githubComment(alternateSuiteName):
prefix = "Results for <strong>%s</strong> ${DRONE_BUILD_LINK}/${DRONE_JOB_NUMBER}${DRONE_STAGE_NUMBER}/1" % alternateSuiteName
return [{
"name": "github-comment",
"image": "jmccann/drone-github-comment:1",
"image": THEGEEKLAB_DRONE_GITHUB_COMMENT,
"pull": "if-not-exists",
"settings": {
"message_file": "%s/comments.file" % dir["web"],
},
"environment": {
"GITHUB_TOKEN": {
"message": "%s/comments.file" % dir["web"],
"key": "pr-${DRONE_PULL_REQUEST}", #TODO: we could delete the comment after a successful CI run
"update": "true",
"api_key": {
"from_secret": "github_token",
},
},
Expand All @@ -2789,7 +2805,6 @@ def githubComment(alternateSuiteName):
],
"when": {
"status": [
"success",
"failure",
],
"event": [
Expand Down Expand Up @@ -2834,15 +2849,15 @@ def deploy(ctx, config, rebuild):
"steps": [
{
"name": "clone continuous deployment playbook",
"image": "alpine/git:latest",
"image": ALPINE_GIT,
"commands": [
"cd deployments/continuous-deployment-config",
"git clone https://github.com/owncloud-devops/continuous-deployment.git",
],
},
{
"name": "deploy",
"image": "owncloudci/drone-ansible:latest",
"image": OC_CI_DRONE_ANSIBLE,
"failure": "ignore",
"environment": {
"CONTINUOUS_DEPLOY_SERVERS_CONFIG": "../%s" % (config),
Expand Down Expand Up @@ -2881,14 +2896,14 @@ def checkStarlark():
"steps": [
{
"name": "format-check-starlark",
"image": "owncloudci/bazel-buildifier",
"image": OC_CI_BAZEL_BUILDIFIER,
"commands": [
"buildifier --mode=check .drone.star",
],
},
{
"name": "show-diff",
"image": "owncloudci/bazel-buildifier",
"image": OC_CI_BAZEL_BUILDIFIER,
"commands": [
"buildifier --mode=fix .drone.star",
"git diff",
Expand Down Expand Up @@ -2976,7 +2991,7 @@ def skipIfUnchanged(ctx, type):

skip_step = {
"name": "skip-if-unchanged",
"image": "owncloudci/drone-skip-pipeline",
"image": OC_CI_DRONE_SKIP_PIPELINE,
"when": {
"event": [
"pull_request",
Expand Down Expand Up @@ -3052,7 +3067,7 @@ def genericCache(name, action, mounts, cache_key):

step = {
"name": "%s_%s" % (action, name),
"image": "meltwater/drone-cache:v1",
"image": MELTWATER_DRONE_CACHE,
"environment": {
"AWS_ACCESS_KEY_ID": {
"from_secret": "cache_s3_access_key",
Expand Down Expand Up @@ -3088,7 +3103,7 @@ def genericCachePurge(ctx, name, cache_key):
"steps": [
{
"name": "purge-cache",
"image": "minio/mc:RELEASE.2021-03-23T05-46-11Z",
"image": MINIO_MC,
"failure": "ignore",
"environment": {
"MC_HOST_cache": {
Expand Down Expand Up @@ -3205,7 +3220,7 @@ def uploadTracingResult(ctx):

return [{
"name": "upload-tracing-result",
"image": "plugins/s3",
"image": PLUGINS_S3,
"pull": "if-not-exists",
"settings": {
"bucket": {
Expand Down
Loading

0 comments on commit e77ce8e

Please sign in to comment.