From fccf3475954bbd35b65966b7b1ff2fda33521ea1 Mon Sep 17 00:00:00 2001 From: Magnus Walbeck Date: Tue, 16 Feb 2021 12:48:49 +0100 Subject: [PATCH 1/2] Add starlark --- .drone.star | 152 ++++++++++++++++ .drone.yml | 509 +++++++++++++++++++++++++++------------------------- 2 files changed, 419 insertions(+), 242 deletions(-) create mode 100644 .drone.star diff --git a/.drone.star b/.drone.star new file mode 100644 index 0000000..ac29451 --- /dev/null +++ b/.drone.star @@ -0,0 +1,152 @@ +def main(ctx): + return [ + lint(), + default_tests("1.6", "1.6"), + default_tests("1.6-prod", "1.6", "Dockerfile.prod"), + default_tests("1.7", "1.7"), + default_tests("1.7-prod", "1.7", "Dockerfile.prod"), + release("1.6", "1.6"), + release("1.6-prod", "1.6", "Dockerfile.prod", "prod"), + release("1.7", "1.7", custom_tags="latest"), + release("1.7-prod", "1.7", "Dockerfile.prod", "prod", "latest-prod"), + ] + +def lint(): + return { + "kind": "pipeline", + "type": "docker", + "name": "lint", + "steps": [ + { + "name": "Lint Dockerfiles", + "image": "hadolint/hadolint", + "commands": [ + "hadolint */Dockerfile*" + ], + "when": { + "status": [ + "failure", + "success" + ] + } + }, + { + "name": "Lint entrypoint scripts", + "image": "koalaman/shellcheck-alpine", + "commands": [ + "shellcheck entrypoint*.sh" + ], + "when": { + "status": [ + "failure", + "success" + ] + } + } + ], + "trigger": { + "event": [ + "pull_request", + "push" + ], + "ref": { + "exclude": [ + "refs/heads/renovate/*" + ] + } + } + } + +def default_tests(name, grav_version, dockerfile="Dockerfile"): + return { + "kind": "pipeline", + "type": "docker", + "name": "default_tests_%s" % name, + "steps": [ + { + "name": "build test", + "image": "plugins/docker", + "settings": { + "dockerfile": "%s/%s" % (grav_version, dockerfile), + "dry_run": "true", + "repo": "mwalbeck/getgrav" + }, + } + ], + "trigger": { + "event": [ + "pull_request" + ] + }, + "depends_on": [ + "lint" + ] + } + +def release(name, grav_version, dockerfile="Dockerfile", app_env="", custom_tags="",): + return { + "kind": "pipeline", + "type": "docker", + "name": "release_%s" % name, + "steps": [ + { + "name": "determine tags", + "image": "mwalbeck/determine-docker-tags", + "environment": { + "VERSION_TYPE": "docker_env", + "APP_NAME": "GRAV", + "DOCKERFILE_PATH": "%s/%s" % (grav_version, dockerfile), + "APP_ENV": app_env, + "CUSTOM_TAGS": custom_tags, + "INCLUDE_MAJOR": "no" + }, + }, + { + "name": "build and publish", + "image": "plugins/docker", + "settings": { + "dockerfile": "%s/%s" % (grav_version, dockerfile), + "username": { + "from_secret": "dockerhub_username" + }, + "password": { + "from_secret": "dockerhub_password" + }, + "repo": "mwalbeck/getgrav" + }, + }, + { + "name": "notify", + "image": "plugins/matrix", + "settings": { + "homeserver": "https://matrix.mwalbeck.org", + "roomid": { + "from_secret": "matrix_roomid" + }, + "username": { + "from_secret": "matrix_username" + }, + "password": { + "from_secret": "matrix_password" + } + }, + "when": { + "status": [ + "failure", + "success" + ] + } + } + ], + "trigger": { + "branch": [ + "master" + ], + "event": [ + "push" + ] + }, + "depends_on": [ + "lint" + ] + } diff --git a/.drone.yml b/.drone.yml index 9c46dfa..5261a50 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,320 +1,345 @@ --- -############################################################################### kind: pipeline type: docker name: lint -steps: - - name: Lint Dockerfiles - image: hadolint/hadolint - commands: - - hadolint */Dockerfile* - when: - status: - - failure - - success +platform: + os: linux + arch: amd64 - - name: Lint entrypoint scripts - image: koalaman/shellcheck-alpine - commands: - - shellcheck entrypoint*.sh - when: - status: - - failure - - success +steps: +- name: Lint Dockerfiles + image: hadolint/hadolint + commands: + - hadolint */Dockerfile* + when: + status: + - failure + - success + +- name: Lint entrypoint scripts + image: koalaman/shellcheck-alpine + commands: + - shellcheck entrypoint*.sh + when: + status: + - failure + - success trigger: event: - - pull_request - - push + - pull_request + - push ref: exclude: - - refs/heads/renovate/* + - refs/heads/renovate/* --- -############################################################################### kind: pipeline type: docker -name: test_1.6 +name: default_tests_1.6 + +platform: + os: linux + arch: amd64 steps: - - name: build test - image: plugins/docker - settings: - dockerfile: 1.6/Dockerfile - repo: mwalbeck/getgrav - dry_run: true +- name: build test + image: plugins/docker + settings: + dockerfile: 1.6/Dockerfile + dry_run: true + repo: mwalbeck/getgrav trigger: event: - - pull_request + - pull_request depends_on: - - lint +- lint --- -############################################################################### kind: pipeline type: docker -name: build_and_release_1.6 +name: default_tests_1.6-prod + +platform: + os: linux + arch: amd64 steps: - - name: determine tags - image: mwalbeck/determine-docker-tags - environment: - VERSION_TYPE: "docker_env" - APP_NAME: "GRAV" - DOCKERFILE_PATH: "1.6/Dockerfile" - APP_ENV: "" - CUSTOM_TAGS: "" - INCLUDE_MAJOR: "no" +- name: build test + image: plugins/docker + settings: + dockerfile: 1.6/Dockerfile.prod + dry_run: true + repo: mwalbeck/getgrav - - name: build and publish - image: plugins/docker - settings: - dockerfile: 1.6/Dockerfile - username: - from_secret: dockerhub_username - password: - from_secret: dockerhub_password - repo: mwalbeck/getgrav +trigger: + event: + - pull_request - - name: notify - image: plugins/matrix - settings: - homeserver: https://matrix.mwalbeck.org - roomid: - from_secret: matrix_roomid - username: - from_secret: matrix_username - password: - from_secret: matrix_password - when: - status: - - success - - failure +depends_on: +- lint + +--- +kind: pipeline +type: docker +name: default_tests_1.7 + +platform: + os: linux + arch: amd64 + +steps: +- name: build test + image: plugins/docker + settings: + dockerfile: 1.7/Dockerfile + dry_run: true + repo: mwalbeck/getgrav + +trigger: + event: + - pull_request + +depends_on: +- lint + +--- +kind: pipeline +type: docker +name: default_tests_1.7-prod + +platform: + os: linux + arch: amd64 + +steps: +- name: build test + image: plugins/docker + settings: + dockerfile: 1.7/Dockerfile.prod + dry_run: true + repo: mwalbeck/getgrav + +trigger: + event: + - pull_request + +depends_on: +- lint + +--- +kind: pipeline +type: docker +name: release_1.6 + +platform: + os: linux + arch: amd64 + +steps: +- name: determine tags + image: mwalbeck/determine-docker-tags + environment: + APP_NAME: GRAV + DOCKERFILE_PATH: 1.6/Dockerfile + INCLUDE_MAJOR: no + VERSION_TYPE: docker_env + +- name: build and publish + image: plugins/docker + settings: + dockerfile: 1.6/Dockerfile + password: + from_secret: dockerhub_password + repo: mwalbeck/getgrav + username: + from_secret: dockerhub_username + +- name: notify + image: plugins/matrix + settings: + homeserver: https://matrix.mwalbeck.org + password: + from_secret: matrix_password + roomid: + from_secret: matrix_roomid + username: + from_secret: matrix_username + when: + status: + - failure + - success trigger: branch: - - master + - master event: - - push + - push depends_on: - - lint +- lint --- -############################################################################### kind: pipeline type: docker -name: test_1.6-prod +name: release_1.6-prod + +platform: + os: linux + arch: amd64 steps: - - name: build test - image: plugins/docker - settings: - dockerfile: 1.6/Dockerfile.prod - repo: mwalbeck/getgrav - dry_run: true +- name: determine tags + image: mwalbeck/determine-docker-tags + environment: + APP_ENV: prod + APP_NAME: GRAV + DOCKERFILE_PATH: 1.6/Dockerfile.prod + INCLUDE_MAJOR: no + VERSION_TYPE: docker_env -trigger: - event: - - pull_request +- name: build and publish + image: plugins/docker + settings: + dockerfile: 1.6/Dockerfile.prod + password: + from_secret: dockerhub_password + repo: mwalbeck/getgrav + username: + from_secret: dockerhub_username -depends_on: - - lint - ---- -############################################################################### -kind: pipeline -type: docker -name: build_and_release_1.6-prod - -steps: - - name: determine tags - image: mwalbeck/determine-docker-tags - environment: - VERSION_TYPE: "docker_env" - APP_NAME: "GRAV" - DOCKERFILE_PATH: "1.6/Dockerfile.prod" - APP_ENV: "prod" - CUSTOM_TAGS: "" - INCLUDE_MAJOR: "no" - - - name: build and publish - image: plugins/docker - settings: - dockerfile: 1.6/Dockerfile.prod - username: - from_secret: dockerhub_username - password: - from_secret: dockerhub_password - repo: mwalbeck/getgrav - - - name: notify - image: plugins/matrix - settings: - homeserver: https://matrix.mwalbeck.org - roomid: - from_secret: matrix_roomid - username: - from_secret: matrix_username - password: - from_secret: matrix_password - when: - status: - - success - - failure +- name: notify + image: plugins/matrix + settings: + homeserver: https://matrix.mwalbeck.org + password: + from_secret: matrix_password + roomid: + from_secret: matrix_roomid + username: + from_secret: matrix_username + when: + status: + - failure + - success trigger: branch: - - master + - master event: - - push + - push depends_on: - - lint +- lint --- -############################################################################### kind: pipeline type: docker -name: test_1.7 +name: release_1.7 + +platform: + os: linux + arch: amd64 steps: - - name: build test - image: plugins/docker - settings: - dockerfile: 1.7/Dockerfile - repo: mwalbeck/getgrav - dry_run: true +- name: determine tags + image: mwalbeck/determine-docker-tags + environment: + APP_NAME: GRAV + CUSTOM_TAGS: latest + DOCKERFILE_PATH: 1.7/Dockerfile + INCLUDE_MAJOR: no + VERSION_TYPE: docker_env -trigger: - event: - - pull_request +- name: build and publish + image: plugins/docker + settings: + dockerfile: 1.7/Dockerfile + password: + from_secret: dockerhub_password + repo: mwalbeck/getgrav + username: + from_secret: dockerhub_username -depends_on: - - lint - ---- -############################################################################### -kind: pipeline -type: docker -name: build_and_release_1.7 - -steps: - - name: determine tags - image: mwalbeck/determine-docker-tags - environment: - VERSION_TYPE: "docker_env" - APP_NAME: "GRAV" - DOCKERFILE_PATH: "1.7/Dockerfile" - APP_ENV: "" - CUSTOM_TAGS: "latest" - INCLUDE_MAJOR: "no" - - - name: build and publish - image: plugins/docker - settings: - dockerfile: 1.7/Dockerfile - username: - from_secret: dockerhub_username - password: - from_secret: dockerhub_password - repo: mwalbeck/getgrav - - - name: notify - image: plugins/matrix - settings: - homeserver: https://matrix.mwalbeck.org - roomid: - from_secret: matrix_roomid - username: - from_secret: matrix_username - password: - from_secret: matrix_password - when: - status: - - success - - failure +- name: notify + image: plugins/matrix + settings: + homeserver: https://matrix.mwalbeck.org + password: + from_secret: matrix_password + roomid: + from_secret: matrix_roomid + username: + from_secret: matrix_username + when: + status: + - failure + - success trigger: branch: - - master + - master event: - - push + - push depends_on: - - lint +- lint --- -############################################################################### kind: pipeline type: docker -name: test_1.7-prod +name: release_1.7-prod + +platform: + os: linux + arch: amd64 steps: - - name: build test - image: plugins/docker - settings: - dockerfile: 1.7/Dockerfile.prod - repo: mwalbeck/getgrav - dry_run: true +- name: determine tags + image: mwalbeck/determine-docker-tags + environment: + APP_ENV: prod + APP_NAME: GRAV + CUSTOM_TAGS: latest-prod + DOCKERFILE_PATH: 1.7/Dockerfile.prod + INCLUDE_MAJOR: no + VERSION_TYPE: docker_env -trigger: - event: - - pull_request +- name: build and publish + image: plugins/docker + settings: + dockerfile: 1.7/Dockerfile.prod + password: + from_secret: dockerhub_password + repo: mwalbeck/getgrav + username: + from_secret: dockerhub_username -depends_on: - - lint - ---- -############################################################################### -kind: pipeline -type: docker -name: build_and_release_1.7-prod - -steps: - - name: determine tags - image: mwalbeck/determine-docker-tags - environment: - VERSION_TYPE: "docker_env" - APP_NAME: "GRAV" - DOCKERFILE_PATH: "1.7/Dockerfile.prod" - APP_ENV: "prod" - CUSTOM_TAGS: "latest-prod" - INCLUDE_MAJOR: "no" - - - name: build and publish - image: plugins/docker - settings: - dockerfile: 1.7/Dockerfile.prod - username: - from_secret: dockerhub_username - password: - from_secret: dockerhub_password - repo: mwalbeck/getgrav - - - name: notify - image: plugins/matrix - settings: - homeserver: https://matrix.mwalbeck.org - roomid: - from_secret: matrix_roomid - username: - from_secret: matrix_username - password: - from_secret: matrix_password - when: - status: - - success - - failure +- name: notify + image: plugins/matrix + settings: + homeserver: https://matrix.mwalbeck.org + password: + from_secret: matrix_password + roomid: + from_secret: matrix_roomid + username: + from_secret: matrix_username + when: + status: + - failure + - success trigger: branch: - - master + - master event: - - push + - push depends_on: - - lint +- lint + +... -- 2.45.2 From 18d39f4f3ab6cb178f66467ebf190065257a362a Mon Sep 17 00:00:00 2001 From: Magnus Walbeck Date: Tue, 16 Feb 2021 15:50:49 +0100 Subject: [PATCH 2/2] Switch to using negative instead of no --- .drone.star | 2 +- .drone.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.drone.star b/.drone.star index ac29451..e203fa4 100644 --- a/.drone.star +++ b/.drone.star @@ -98,7 +98,7 @@ def release(name, grav_version, dockerfile="Dockerfile", app_env="", custom_tags "DOCKERFILE_PATH": "%s/%s" % (grav_version, dockerfile), "APP_ENV": app_env, "CUSTOM_TAGS": custom_tags, - "INCLUDE_MAJOR": "no" + "INCLUDE_MAJOR": "negative" }, }, { diff --git a/.drone.yml b/.drone.yml index 5261a50..5143be5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -145,7 +145,7 @@ steps: environment: APP_NAME: GRAV DOCKERFILE_PATH: 1.6/Dockerfile - INCLUDE_MAJOR: no + INCLUDE_MAJOR: negative VERSION_TYPE: docker_env - name: build and publish @@ -198,7 +198,7 @@ steps: APP_ENV: prod APP_NAME: GRAV DOCKERFILE_PATH: 1.6/Dockerfile.prod - INCLUDE_MAJOR: no + INCLUDE_MAJOR: negative VERSION_TYPE: docker_env - name: build and publish @@ -251,7 +251,7 @@ steps: APP_NAME: GRAV CUSTOM_TAGS: latest DOCKERFILE_PATH: 1.7/Dockerfile - INCLUDE_MAJOR: no + INCLUDE_MAJOR: negative VERSION_TYPE: docker_env - name: build and publish @@ -305,7 +305,7 @@ steps: APP_NAME: GRAV CUSTOM_TAGS: latest-prod DOCKERFILE_PATH: 1.7/Dockerfile.prod - INCLUDE_MAJOR: no + INCLUDE_MAJOR: negative VERSION_TYPE: docker_env - name: build and publish -- 2.45.2