Commit b6120fce authored by Sheogorath's avatar Sheogorath 🎓

Refactor gitlab CI integration

This patch refactors the CI process for the image a lot. It creates a
universal build and test step while reducing the previous duplicated
build step for master, to a relabling job. This should prevent problem
form code duplication that appeared in other projects before.
parent a921702d
image: quay.io/sheogorath/ubuntu-ci:18.04
services:
- docker:dind
image: quay.io/sheogorath/build-ah-engine
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
stages:
- analyse
- build
- test
- tag
- deploy
build-master:
build:
stage: build
script:
- podman build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- podman push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
testing:
stage: test
before_script:
- dnf install -y jq
- export CONTAINER_FILE="$(mktemp)"
- rm "$CONTAINER_FILE"
script:
- podman run -d -p 8053:8053 --cidfile="$CONTAINER_FILE" "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
- curl http://localhost:8053/dns-query\?name\=ci-test.dns.shivering-isles.com\&type\=A 2>/dev/null | jq '.Answer[].data' | grep -q '"127.0.0.123"'
- 'podman stop "$(cat "$CONTAINER_FILE")" && podman rm "$(cat "$CONTAINER_FILE")" && rm "$CONTAINER_FILE"'
- podman run -d -p 8053:8053 --cidfile="$CONTAINER_FILE" -e UPSTREAM_NAME="ci-upstream.dns.shivering-isles.com" "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
- curl http://localhost:8053/dns-query\?name\=ci-test.dns.shivering-isles.com\&type\=A 2>/dev/null | jq '.Answer[].data' | grep -q '"127.0.0.123"'
- 'podman stop "$(cat "$CONTAINER_FILE")" && podman rm "$(cat "$CONTAINER_FILE")" && rm "$CONTAINER_FILE"'
tagging-master:
stage: tag
variables:
DOCKER_HOST: "tcp://docker:2375"
DOH_VERSION: "2.2.1"
script:
- docker build --pull --build-arg VERSION="v${DOH_VERSION}" -t "doh:testing" .
- ./tools/tagging.sh "$CI_REGISTRY_IMAGE" "${DOH_VERSION:-latest}" ""
- docker images --format "{{.Repository}}:{{.Tag}}" "$CI_REGISTRY_IMAGE" | xargs -L 1 docker push
- podman pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
- si-tagging -l "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE" "${DOH_VERSION}"
- podman images --format "{{.Repository}}:{{.Tag}}" "$CI_REGISTRY_IMAGE" | grep "$CI_REGISTRY_IMAGE" | xargs -L 1 podman push
only:
- master
tags:
- docker
build:
stage: build
variables:
DOCKER_HOST: "tcp://docker:2375"
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
except:
- master
tags:
- docker
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment