[glib/wip/ebassi/ci] ci: Add GitLab CI description file



commit b6ff6de6080323b4eee15ad3fd743b63703b6d0f
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sun Feb 18 14:59:29 2018 +0000

    ci: Add GitLab CI description file
    
    We're mostly interested into building and testing everything that gets
    pushed to the repository — including merge requests.
    
    When pushing tags, though, we should assume we're spinning a release, so
    let's run the dist target, and store the tarball, and the generated
    documentation while we're at it, as artifacts on GitLab.
    
    The Dockerfile for the image used for the build is included in tree, and
    published on Docker Hub. Using a custom image allows us to avoid the
    costly "download and install build dependencies" phase, as well as
    controlling the environment a little bit better.

 .gitlab-ci.yml           | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 .gitlab-ci/Dockerfile    | 29 +++++++++++++++++++++++++++++
 .gitlab-ci/run-docker.sh |  9 +++++++++
 3 files changed, 85 insertions(+)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 000000000..6ad49a5ee
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,47 @@
+image: ebassi:gitlab-glib
+
+before_script:
+  - mkdir -p _ccache
+  - export CCACHE_BASEDIR=${PWD}
+  - export CCACHE_DIR=${PWD}/_ccache
+
+stages:
+  - build
+
+cache:
+  paths:
+    - _ccache/
+
+build-job:
+  stage: build
+  script:
+    - meson --prefix /usr --libdir /usr/lib64 _build .
+    - cd _build
+    - ninja
+    - meson test
+  except:
+    - tags
+  artifacts:
+    when: on_failure
+    name: "glib-_${CI_COMMIT_REF_NAME}"
+    paths:
+      - "${CI_PROJECT_DIR}/_build/meson-logs/testlog.txt"
+
+dist-job:
+  stage: build
+  only:
+    - tags
+  script:
+    - meson --prefix /usr --libdir /usr/lib64 -Dgtk_doc=true _build .
+    - cd _build
+    - ninja dist
+    - ninja glib-doc
+    - tar -c -f "glib-docs-$CI_COMMIT_TAG.tar.xz" -C docs/reference/glib html
+    - tar -c -f "gobject-docs-$CI_COMMIT_TAG.tar.xz" -C docs/reference/gobject html
+    - tar -c -f "gio-docs-$CI_COMMIT_TAG.tar.xz" -C docs/reference/gio html
+  artifacts:
+    paths:
+      - "${CI_PROJECT_DIR}/_build/glib-docs.tar.xz"
+      - "${CI_PROJECT_DIR}/_build/gobject-docs.tar.xz"
+      - "${CI_PROJECT_DIR}/_build/gio-docs.tar.xz"
+      - "${CI_PROJECT_DIR}/_build/meson-dist/glib-*.tar.xz"
diff --git a/.gitlab-ci/Dockerfile b/.gitlab-ci/Dockerfile
new file mode 100644
index 000000000..3bc415905
--- /dev/null
+++ b/.gitlab-ci/Dockerfile
@@ -0,0 +1,29 @@
+FROM fedora:27
+
+RUN dnf -y install \
+    ccache \
+    desktop-file-utils \
+    elfutils-libelf-devel \
+    gcc \
+    gcc-c++ \
+    gettext \
+    git \
+    glibc-devel \
+    gtk-doc \
+    itstool \
+    libattr-devel \
+    libffi-devel \
+    libmount-devel \
+    libselinux-devel \
+    meson \
+    pcre-devel \
+    zlib-devel
+
+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.utf8
diff --git a/.gitlab-ci/run-docker.sh b/.gitlab-ci/run-docker.sh
new file mode 100755
index 000000000..940456fad
--- /dev/null
+++ b/.gitlab-ci/run-docker.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+set -e
+
+sudo docker build --build-arg HOST_USER_ID="$UID" --tag "gitlab-glib" \
+    --file "Dockerfile" .
+sudo docker run --rm \
+    --volume "$(pwd)/..:/home/user/app" --workdir "/home/user/app" \
+    --tty --interactive "gitlab-glib" bash


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]