From 9b5f33decedf0d54c32553d486e8791be01e7062 Mon Sep 17 00:00:00 2001 From: Melora Hugues Date: Thu, 2 Feb 2023 20:20:43 +0100 Subject: [PATCH] Improve CI Add more tests to the CI, including a docker build test, and add the generation and publication of a new docker image on master and tags --- .drone.yml | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index 087a749..be7b0fb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,16 +1,88 @@ +--- +# Test building the code and docker image kind: pipeline type: docker -name: Tests +name: test-build steps: -- name: test +- name: go-test image: golang commands: - - cd tracker - - make build - - make test + - make -C tracker test + depends_on: + +- name: go-build + image: golang + commands: + - make -C tracker build + depends_on: + +- name: docker-build-only + image: thegeeklab/drone-docker-buildx + privileged: true + settings: + repo: git.faercol.me/faercol/public-ip-tracker + tags: latest + dry_run: true + platforms: + - linux/amd64 + - linux/arm64 + depends_on: + when: + branch: + exclude: + - master + event: + - push + +- name: docker-build-push + image: thegeeklab/drone-docker-buildx + privileged: true + settings: + repo: git.faercol.me/faercol/public-ip-tracker + registry: git.faercol.me + tags: latest + username: + from_secret: GIT_USERNAME + password: + from_secret: GIT_PASSWORD + depends_on: + - go-test + - go-build + when: + branch: + - master + event: + - push trigger: event: - push - tag + +--- +# On a tag, only build the related docker image +kind: pipeline +type: docker +name: tag-release +depends_on: + - test-build + +steps: +- name: docker-push-tag + image: thegeeklab/drone-docker-buildx + privileged: true + settings: + registry: git.faercol.me + repo: git.faercol.me/faercol/public-ip-tracker + auto_tag: true + username: + from_secret: GIT_USERNAME + password: + from_secret: GIT_PASSWORD + +trigger: + event: + - tag + +... \ No newline at end of file -- 2.45.2