diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e772b6b..9d62b85 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,7 +47,7 @@ package: only: - tags -test-plain-install: +test-install: stage: test image: docker:latest services: @@ -62,7 +62,26 @@ test-plain-install: -e CI_PROJECT_DIR=/src -e CI_COMMIT_TAG=$CI_COMMIT_TAG jrei/systemd-ubuntu:20.04 - - docker exec -t systemd-ubuntu /bin/bash /src/.gitlab-ci/test.sh + - docker exec -t systemd-ubuntu /bin/bash /src/.gitlab-ci/test-install.sh + only: + - tags + +test-update: + stage: test + image: docker:latest + services: + - docker:dind + script: + - docker run + -d + --name systemd-ubuntu + --privileged + -v /sys/fs/cgroup:/sys/fs/cgroup:ro + -v $CI_PROJECT_DIR:/src + -e CI_PROJECT_DIR=/src + -e CI_COMMIT_TAG=$CI_COMMIT_TAG + jrei/systemd-ubuntu:20.04 + - docker exec -t systemd-ubuntu /bin/bash /src/.gitlab-ci/test-update.sh only: - tags diff --git a/.gitlab-ci/data.tgz b/.gitlab-ci/data.tgz new file mode 100644 index 0000000..62037dc Binary files /dev/null and b/.gitlab-ci/data.tgz differ diff --git a/.gitlab-ci/test-install.sh b/.gitlab-ci/test-install.sh new file mode 100644 index 0000000..d57b20e --- /dev/null +++ b/.gitlab-ci/test-install.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +. "${CI_PROJECT_DIR}/.gitlab-ci/test.sh" + +apt-get -qqy install "${CI_PROJECT_DIR}/gitea_${VERSION}-${PATCHLEVEL}_amd64.deb" +start_gitea diff --git a/.gitlab-ci/test-update.sh b/.gitlab-ci/test-update.sh new file mode 100644 index 0000000..91e949a --- /dev/null +++ b/.gitlab-ci/test-update.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +. "${CI_PROJECT_DIR}/.gitlab-ci/test.sh" + +curl -sL -o /etc/apt/trusted.gpg.d/morph027-gitea.asc https://packaging.gitlab.io/gitea/gpg.key +echo "deb [arch=amd64] https://packaging.gitlab.io/gitea gitea main" > /etc/apt/sources.list.d/morph027-gitea.list +apt-get -qq update +apt-get -qqy install gitea +tar -C / -xzf "/${CI_PROJECT_DIR}/.gitlab-ci/data.tgz" +chown -R gitea: /var/lib/gitea /etc/gitea +start_gitea +apt-get -qqy install "${CI_PROJECT_DIR}/gitea_${VERSION}-${PATCHLEVEL}_amd64.deb" +restart_gitea diff --git a/.gitlab-ci/test.sh b/.gitlab-ci/test.sh index e2e3c75..3b8899d 100644 --- a/.gitlab-ci/test.sh +++ b/.gitlab-ci/test.sh @@ -4,10 +4,21 @@ set -e VERSION=$(echo "${CI_COMMIT_TAG#*v}" | cut -d'-' -f1) PATCHLEVEL=$(echo "${CI_COMMIT_TAG}" | cut -d'-' -f2) +export VERSION PATCHLEVEL + +start_gitea() { + systemctl start gitea + sleep 10 + if ! systemctl is-active gitea; then + journalctl -lu gitea --no-pager + fi + curl -s localhost:3000/api/v1/version | jq -e '.version' +} + +restart_gitea() { + systemctl stop gitea + start_gitea +} + apt-get -qq update -apt-get -qqy install "${CI_PROJECT_DIR}/gitea_${VERSION}-${PATCHLEVEL}_amd64.deb" -systemctl start gitea -sleep 10 -if ! systemctl is-active gitea; then - journalctl -lu gitea --no-pager -fi +apt-get -qqy install curl jq