Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
diff --git a/deployments/ansible/roles/kolab-ci/files/kolabci.service b/deployments/ansible/roles/kolab-ci/files/kolabci.service
new file mode 100644
index 0000000..e4fb633
--- /dev/null
+++ b/deployments/ansible/roles/kolab-ci/files/kolabci.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Run the kolabci script
+
+[Service]
+Type=oneshot
+TimeoutSec=7200
+ExecStart=/bin/bash /root/run.sh
diff --git a/deployments/ansible/roles/kolab-ci/files/kolabci.timer b/deployments/ansible/roles/kolab-ci/files/kolabci.timer
new file mode 100644
index 0000000..ad16cce
--- /dev/null
+++ b/deployments/ansible/roles/kolab-ci/files/kolabci.timer
@@ -0,0 +1,9 @@
+[Unit]
+Description=Run ci
+
+[Timer]
+OnCalendar=*-*-* 3,12,16:00:00
+Persistent=true
+
+[Install]
+WantedBy=timers.target
diff --git a/deployments/ansible/roles/kolab-ci/files/run.sh b/deployments/ansible/roles/kolab-ci/files/run.sh
new file mode 100644
index 0000000..4ad96f3
--- /dev/null
+++ b/deployments/ansible/roles/kolab-ci/files/run.sh
@@ -0,0 +1,91 @@
+#!/bin/bash
+
+PROMETHEUS_PUSHGATEWAY=""
+CACHE_REGISTRY=""
+GIT_REMOTE="https://git.kolab.org/source/kolab.git"
+GIT_REF="master"
+
+function check_success() {
+ if [[ "$1" == "0" ]]; then
+ echo "1";
+ else
+ echo "0";
+ fi;
+}
+
+function checkout() {
+ if [ ! -d "$1" ]; then
+ git clone "$2" "$1" || exit
+ pushd "$1" || exit
+ git checkout "$3" || exit
+ popd || exit
+ fi
+}
+
+if [[ "$CACHE_REGISTRY" != "" ]]; then
+ cat <<EOF >> /etc/containers/registries.conf
+[[registry]]
+prefix = "$CACHE_REGISTRY"
+insecure = true
+location = "$CACHE_REGISTRY"
+EOF
+fi
+
+# Make room
+podman image prune -f
+
+# This is the code that we are going to test
+rm -rf kolab
+checkout kolab "$GIT_REMOTE" "$GIT_REF"
+pushd kolab || exit
+
+HOST=${HOST:-$HOSTNAME}
+EPOCH=$(date +"%s")
+
+
+METRICS=$(
+ cat <<EOF
+kolab_ci_timestamp $EPOCH
+# HELP kolab_ci_testsuite Displays whether or not the testsuite passed
+# TYPE kolab_ci_testsuite gauge
+EOF
+)
+
+ci/testctl build
+BUILD_RESULT=$(check_success $?)
+ci/testctl lint
+LINT_RESULT=$(check_success $?)
+ci/testctl testrun
+TESTRUN_RESULT=$(check_success $?)
+ci/testctl teardown
+
+METRICS+=$(
+ cat <<EOF
+
+kolab_ci_testsuite{host="$HOST", testsuite="build"} $BUILD_RESULT
+kolab_ci_testsuite{host="$HOST", testsuite="lint"} $LINT_RESULT
+kolab_ci_testsuite{host="$HOST", testsuite="testrun"} $TESTRUN_RESULT
+EOF
+)
+
+env ADMIN_PASSWORD=simple123 ./kolabctl configure
+env ADMIN_PASSWORD=simple123 ./kolabctl deploy
+DEPLOY_RESULT=$(check_success $?)
+sleep 10
+env ADMIN_PASSWORD=simple123 ./kolabctl selfcheck
+SELFCHECK_RESULT=$(check_success $?)
+./kolabctl reset --force
+
+METRICS+=$(
+ cat <<EOF
+
+kolab_ci_testsuite{host="$HOST", testsuite="deploy"} $DEPLOY_RESULT
+kolab_ci_testsuite{host="$HOST", testsuite="selfcheck"} $SELFCHECK_RESULT
+EOF
+)
+# Publish test results
+if [[ "$PROMETHEUS_PUSHGATEWAY" != "" ]]; then
+ echo "Pushing result to $PROMETHEUS_PUSHGATEWAY"
+ echo "$METRICS"
+ echo "$METRICS" | curl -k --data-binary @- "$PROMETHEUS_PUSHGATEWAY"
+fi

File Metadata

Mime Type
text/x-diff
Expires
Sat, Apr 4, 8:48 AM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18823325
Default Alt Text
(3 KB)

Event Timeline