From 9b550310f97c2d28fed96b799c20faf10f021ff9 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon, 22 Jan 2024 13:44:56 +1000
Subject: [PATCH] ci: Switch to using ci-templates

This makes builds more reliable, we don't rely on every package being
available or pick up every bug on the way.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
---
 .gitlab-ci.yml | 45 +++++++++++++++++++++++++++++++++++++--------
 1 file changed, 37 insertions(+), 8 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6fad501e..5b592d63 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,10 +1,37 @@
-image: alpine:latest
+.templates_sha: &template_sha dd90ac0d7a03b574eb4f18d7358083f0c97825f3
+
+include:
+  - project: 'freedesktop/ci-templates'
+    ref: *template_sha
+    file:
+      - '/templates/alpine.yml'
+
+stages:
+  - prep
+  - build
+  - deploy
+
+variables:
+  WAYLAND_PACKAGES: git build-base meson libffi-dev expat-dev doxygen libxslt xmlto graphviz ttf-dejavu
+  # libinput's .gitlab-ci.yml has the list of ALPINE_PACKAGES, copied from there
+  LIBINPUT_PACKAGES: git gcc build-base pkgconfig meson check-dev eudev-dev libevdev-dev libwacom-dev mtdev-dev bash doxygen graphviz py3-pip py3-sphinx py3-pytest-xdist
+  PIP_PACKAGES: recommonmark sphinx_rtd_theme
+  FDO_DISTRIBUTION_EXEC: "pip install --break-system-packages $PIP_PACKAGES"
+  FDO_DISTRIBUTION_PACKAGES: $WAYLAND_PACKAGES $LIBINPUT_PACKAGES
+  FDO_DISTRIBUTION_TAG: 2024-01-23.0
+  FDO_UPSTREAM_REPO: wayland/wayland.freedesktop.org
+
+container-build:
+  extends:
+    - .fdo.container-build@alpine
+  stage: prep
+  variables:
+    GIT_STRATEGY: none
 
 libinput:
+  extends:
+    - .fdo.distribution-image@alpine
   stage: build
-  before_script:
-  - apk add $ALPINE_PACKAGES
-  - pip3 install recommonmark sphinx_rtd_theme
   script:
   - git clone https://gitlab.freedesktop.org/libinput/libinput.git libinput.git
   - cd libinput.git
@@ -23,13 +50,13 @@ libinput:
   variables:
     MESON_ARGS: '-Ddebug-gui=false -Dtests=false -Ddocumentation=true'
     MESON_BUILDDIR: 'builddir'
-    # libinput's .gitlab-ci.yml has the list of ALPINE_PACKAGES, copied from there
-    ALPINE_PACKAGES:  'git gcc build-base pkgconfig meson check-dev eudev-dev libevdev-dev libwacom-dev mtdev-dev bash doxygen graphviz py3-pip py3-sphinx py3-pytest-xdist'
+  needs:
+    - container-build
 
 wayland:
+  extends:
+    - .fdo.distribution-image@alpine
   stage: build
-  before_script:
-  - apk add git build-base meson libffi-dev expat-dev doxygen libxslt xmlto graphviz ttf-dejavu
   script:
   - git clone https://gitlab.freedesktop.org/wayland/wayland.git
   - cd wayland
@@ -44,6 +71,8 @@ wayland:
   artifacts:
     paths:
     - docs/html
+  needs:
+    - container-build
 
 pages:
   stage: deploy
-- 
GitLab