From 64ac97e3851ad30bdb89f10bdf74f833c3ba69ce Mon Sep 17 00:00:00 2001 From: Sheogorath Date: Thu, 9 Apr 2020 20:24:19 +0200 Subject: [PATCH] Add automated tests for CI process --- .gitlab-ci.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5ce6767..6256647 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,6 +10,7 @@ stages: - analyse - build - test + - cleanup_test - tag - deploy @@ -19,6 +20,23 @@ build: - podman build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - podman push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" +test: + stage: test + script: + - curl -L https://github.com/hetznercloud/cli/releases/download/v1.16.2/hcloud-linux-amd64.tar.gz | tar -zxv hcloud + - sha256sum -c <(echo "a517c1362edd3c6374c1dd12ba58e3fe89d67ec7db37b12aa5b904d409182d25 hcloud") + - podman run -e CI_HETZNER_KEY --entrypoint /bin/bash "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -c 'docker-machine create --driver hetzner --hetzner-image="debian-10" --hetzner-server-type="cx11" --hetzner-api-token="$CI_HETZNER_KEY" ci-test-machine && docker-machine ls; docker-machine rm -y ci-test-machine' + +cleanup_test: + image: docker.io/library/ubuntu:19.04 + stage: cleanup_test + script: + - apt-get update + - apt-get install -y hcloud-cli + - HCLOUD_TOKEN="$CI_HETZNER_KEY" ./hcloud server delete ci-test-machine || exit 0 + - HCLOUD_TOKEN="$CI_HETZNER_KEY" ./hcloud ssh-key delete ci-test-machine || exit 0 + when: on_failure + tagging-master: stage: tag script: