summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@hora-obscura.de>2019-07-12 03:22:31 +0000
committerStefan Sauer <ensonic@hora-obscura.de>2019-07-12 03:22:31 +0000
commit23a3d0adbef1dabce2d7a2724e8ec7fa93a06746 (patch)
tree1614c0794825a2e18ddd2b3201baec027717172f
parent4cb077c1e397f4bd8fbeadccdd551e55d436866d (diff)
parent7b55fbd0961e9e30a2a124cfefe8b8883c596bcb (diff)
downloadgtk-doc-23a3d0adbef1dabce2d7a2724e8ec7fa93a06746.tar.gz
Merge branch 'docker-ci' into 'master'
ci: Use the docker registry See merge request GNOME/gtk-doc!33
-rw-r--r--.gitlab-ci.yml13
-rw-r--r--.gitlab-ci/README.md23
-rw-r--r--.gitlab-ci/debian.Dockerfile58
-rwxr-xr-x.gitlab-ci/run-docker.sh120
4 files changed, 202 insertions, 12 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3c1fa7b..b9d5d89 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,15 +1,4 @@
-image: debian:unstable
-
-before_script:
- - apt update -qq
- - apt install -y -qq --no-install-recommends
- autoconf automake bc build-essential libtool make meson pkg-config
- dblatex docbook docbook-xml docbook-xsl libxml2-utils xsltproc
- libglib2.0-dev
- python3 python3-coverage python3-dev python3-lxml python3-parameterized
- python3-pip python3-pygments python3-setuptools python3-unittest2
- - pip3 install anytree
- - export LANG=C.UTF-8
+image: registry.gitlab.gnome.org/gnome/gtk-doc/debian:v1
stages:
- build
diff --git a/.gitlab-ci/README.md b/.gitlab-ci/README.md
new file mode 100644
index 0000000..41dfd75
--- /dev/null
+++ b/.gitlab-ci/README.md
@@ -0,0 +1,23 @@
+# CI support stuff
+
+## Docker image
+
+GitLab CI jobs run in a Docker image, defined here. To update that image
+(perhaps to install some more packages):
+
+1. Edit `.gitlab-ci/Dockerfile` with the changes you want
+2. Edit `.gitlab-ci/run-docker.sh` and bump the version in `TAG`
+3. Run `.gitlab-ci/run-docker.sh` to build the new image, and launch a shell
+ inside it
+ * When you're done, exit the shell in the usual way
+4. Run `.gitlab-ci/run-docker.sh --push` to upload the new image to the GNOME
+ GitLab Docker registry
+ * If this is the first time you're doing this, you'll need to log into the
+ registry
+ * If you use 2-factor authentication on your GNOME GitLab account, you'll
+ need to [create a personal access token][pat] and use that rather than
+ your normal password
+5. Edit `.gitlab-ci.yml` (in the root of this repository) to use your new
+ image
+
+[pat]: https://gitlab.gnome.org/profile/personal_access_tokens
diff --git a/.gitlab-ci/debian.Dockerfile b/.gitlab-ci/debian.Dockerfile
new file mode 100644
index 0000000..275fafa
--- /dev/null
+++ b/.gitlab-ci/debian.Dockerfile
@@ -0,0 +1,58 @@
+FROM debian:unstable
+
+RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \
+ autoconf \
+ automake \
+ bc \
+ build-essential \
+ dblatex \
+ docbook \
+ docbook-xml \
+ docbook-xsl \
+ libglib2.0-dev \
+ libtool \
+ libxml2-utils \
+ locales \
+ make \
+ meson \
+ pkg-config \
+ python3 \
+ python3-coverage \
+ python3-dev \
+ python3-lxml \
+ python3-parameterized \
+ python3-pip \
+ python3-pygments \
+ python3-setuptools \
+ python3-unittest2 \
+ xsltproc \
+ && rm -rf /usr/share/doc/* /usr/share/man/*
+
+# Locale for our build
+RUN locale-gen C.UTF-8 && /usr/sbin/update-locale LANG=C.UTF-8
+
+# Locales for our tests
+RUN locale-gen de_DE.UTF-8 \
+ && locale-gen el_GR.UTF-8 \
+ && locale-gen en_US.UTF-8 \
+ && locale-gen es_ES.UTF-8 \
+ && locale-gen fa_IR.UTF-8 \
+ && locale-gen fr_FR.UTF-8 \
+ && locale-gen hr_HR.UTF-8 \
+ && locale-gen ja_JP.UTF-8 \
+ && locale-gen lt_LT.UTF-8 \
+ && locale-gen pl_PL.UTF-8 \
+ && locale-gen ru_RU.UTF-8 \
+ && locale-gen tr_TR.UTF-8
+
+ENV LANG=C.UTF-8 LANGUAGE=C.UTF-8 LC_ALL=C.UTF-8
+
+RUN pip3 install meson==0.48.0 anytree
+ARG HOST_USER_ID=5555
+ENV HOST_USER_ID ${HOST_USER_ID}
+RUN useradd -u $HOST_USER_ID -ms /bin/bash user
+
+USER user
+WORKDIR /home/user
+
+ENV LANG=C.UTF-8 LANGUAGE=C.UTF-8 LC_ALL=C.UTF-8
diff --git a/.gitlab-ci/run-docker.sh b/.gitlab-ci/run-docker.sh
new file mode 100755
index 0000000..9d71c00
--- /dev/null
+++ b/.gitlab-ci/run-docker.sh
@@ -0,0 +1,120 @@
+#!/bin/bash
+
+read_arg() {
+ # $1 = arg name
+ # $2 = arg value
+ # $3 = arg parameter
+ local rematch='^[^=]*=(.*)$'
+ if [[ $2 =~ $rematch ]]; then
+ read "$1" <<< "${BASH_REMATCH[1]}"
+ else
+ read "$1" <<< "$3"
+ # There is no way to shift our callers args, so
+ # return 1 to indicate they should do it instead.
+ return 1
+ fi
+}
+
+set -e
+
+build=0
+run=0
+push=0
+list=0
+print_help=0
+no_login=0
+
+while (($# > 0)); do
+ case "${1%%=*}" in
+ build) build=1;;
+ run) run=1;;
+ push) push=1;;
+ list) list=1;;
+ help) print_help=1;;
+ --base|-b) read_arg base "$@" || shift;;
+ --base-version) read_arg base_version "$@" || shift;;
+ --no-login) no_login=1;;
+ *) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;;
+ esac
+ shift
+done
+
+if [ $print_help == 1 ]; then
+ echo "$0 - Build and run Docker images"
+ echo ""
+ echo "Usage: $0 <command> [options] [basename]"
+ echo ""
+ echo "Available commands"
+ echo ""
+ echo " build --base=<BASENAME> - Build Docker image <BASENAME>.Dockerfile"
+ echo " run --base=<BASENAME> - Run Docker image <BASENAME>"
+ echo " push --base=<BASENAME> - Push Docker image <BASENAME> to the registry"
+ echo " list - List available images"
+ echo " help - This help message"
+ echo ""
+ exit 0
+fi
+
+cd "$(dirname "$0")"
+
+if [ $list == 1 ]; then
+ echo "Available Docker images:"
+ for f in *.Dockerfile; do
+ filename=$( basename -- "$f" )
+ basename="${filename%.*}"
+
+ echo -e " \e[1;39m$basename\e[0m"
+ done
+ exit 0
+fi
+
+# All commands after this require --base to be set
+if [ -z $base ]; then
+ echo "Usage: $0 <command>"
+ exit 1
+fi
+
+if [ ! -f "$base.Dockerfile" ]; then
+ echo -e "\e[1;31mERROR\e[0m: Dockerfile for '$base' not found"
+ exit 1
+fi
+
+if [ -z $base_version ]; then
+ base_version="latest"
+else
+ base_version="v$base_version"
+fi
+
+TAG="registry.gitlab.gnome.org/gnome/gtk-doc/${base}:${base_version}"
+
+if [ $build == 1 ]; then
+ echo -e "\e[1;32mBUILDING\e[0m: ${base} as ${TAG}"
+ sudo docker build \
+ --build-arg HOST_USER_ID="$UID" \
+ --tag "${TAG}" \
+ --file "${base}.Dockerfile" .
+ exit $?
+fi
+
+if [ $push == 1 ]; then
+ echo -e "\e[1;32mPUSHING\e[0m: ${base} as ${TAG}"
+
+ if [ $no_login == 0 ]; then
+ sudo docker login registry.gitlab.gnome.org
+ fi
+
+ sudo docker push $TAG
+ exit $?
+fi
+
+if [ $run == 1 ]; then
+ echo -e "\e[1;32mRUNNING\e[0m: ${base} as ${TAG}"
+ sudo docker run \
+ --rm \
+ --volume "$(pwd)/..:/home/user/app" \
+ --workdir "/home/user/app" \
+ --tty \
+ --interactive "${TAG}" \
+ bash
+ exit $?
+fi