From f26679c6ebb39b732a965dba84f975260366d266 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 21 Feb 2020 09:05:04 +1000 Subject: [PATCH] gitlab CI: move the configuration bits into a YAML file Only one change: the meson boolean to decide whether to build with meson is now inside the build: block. Signed-off-by: Peter Hutterer --- .gitlab-ci.yml | 2 +- .gitlab-ci/generate-gitlab-ci.py | 38 +++++--------------------------- .gitlab-ci/gitlab-ci-config.yaml | 38 ++++++++++++++++++++++++++++++++ .gitlab-ci/gitlab-ci.tmpl | 4 ++-- 4 files changed, 47 insertions(+), 35 deletions(-) create mode 100644 .gitlab-ci/gitlab-ci-config.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0adfd7a..fdd6474 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -130,7 +130,7 @@ check-ci-script: stage: prep before_script: - apk add python3 git - - pip3 install --user jinja2 + - pip3 install --user jinja2 PyYAML script: - python3 ./.gitlab-ci/generate-gitlab-ci.py - git diff --exit-code && exit 0 || true diff --git a/.gitlab-ci/generate-gitlab-ci.py b/.gitlab-ci/generate-gitlab-ci.py index 1bbebb3..f6fe5f1 100755 --- a/.gitlab-ci/generate-gitlab-ci.py +++ b/.gitlab-ci/generate-gitlab-ci.py @@ -7,53 +7,27 @@ import argparse import jinja2 import os import sys +import yaml from pathlib import Path - -distributions = [ - {'name': 'fedora', 'version': '30'}, - {'name': 'fedora', 'version': '31'}, - {'name': 'ubuntu', 'version': '19.10'}, - {'name': 'ubuntu', 'version': '19.04'}, - {'name': 'debian', 'version': 'stable'}, - {'name': 'debian', 'version': 'sid'}, - { - 'name': 'centos', 'version': '7', - 'build': { - 'extra_variables': { - 'MAKE_ARGS': ('\'\' # disable distcheck, requires doxygen'), - } - }, - 'meson': False - }, - { - 'name': 'centos', 'version': '8', - 'build': { - 'extra_variables': { - 'MAKE_ARGS': ('\'\' # disable distcheck, requires doxygen'), - } - }, - 'meson': False - }, - {'name': 'arch', 'version': 'rolling', - 'flavor': 'archlinux' }, # see https://gitlab.freedesktop.org/wayland/ci-templates/merge_requests/19 - {'name': 'alpine', 'version': 'latest'}, -] - # The various sources for templating SOURCE_DIR = Path('.gitlab-ci') +CONFIG_FILE = 'gitlab-ci-config.yaml' TEMPLATE_FILE = 'gitlab-ci.tmpl' BASE_DIR = Path('.') OUTPUT_FILE = '.gitlab-ci.yml' + def generate_template(): + with open(SOURCE_DIR / CONFIG_FILE) as fd: + config = yaml.safe_load(fd) + env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.fspath(SOURCE_DIR)), trim_blocks=True, lstrip_blocks=True) template = env.get_template(TEMPLATE_FILE) - config = {'distributions': distributions} with open(BASE_DIR / OUTPUT_FILE, 'w') as fd: template.stream(config).dump(fd) diff --git a/.gitlab-ci/gitlab-ci-config.yaml b/.gitlab-ci/gitlab-ci-config.yaml new file mode 100644 index 0000000..eab81f3 --- /dev/null +++ b/.gitlab-ci/gitlab-ci-config.yaml @@ -0,0 +1,38 @@ +# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0: +# +# This file contains the configuration for the gitlab ci. +# See the .gitlab-ci/generate-gitlab-ci.py file for more info + + +distributions: + - name: fedora + version: '30' + - name: fedora + version: '31' + - name: ubuntu + version: '19.10' + - name: ubuntu + version: '19.04' + - name: debian + version: 'stable' + - name: debian + version: 'sid' + - name: centos + version: 7 + build: + meson: False + extra_variables: + # note: the variable value includes the comment because we want that in the gitlab-ci file + MAKE_ARGS: "'' # disable distcheck, requires doxygen" + - name: centos + version: 8 + build: + meson: False + extra_variables: + # note: the variable value includes the comment because we want that in the gitlab-ci file + MAKE_ARGS: "'' # disable distcheck, requires doxygen" + - name: arch + version: 'rolling' + flavor: 'archlinux' # see https://gitlab.freedesktop.org/wayland/ci-templates/merge_requests/19 + - name: alpine + version: 'latest' diff --git a/.gitlab-ci/gitlab-ci.tmpl b/.gitlab-ci/gitlab-ci.tmpl index 632b68e..fa5a768 100644 --- a/.gitlab-ci/gitlab-ci.tmpl +++ b/.gitlab-ci/gitlab-ci.tmpl @@ -132,7 +132,7 @@ check-ci-script: stage: prep before_script: - apk add python3 git - - pip3 install --user jinja2 + - pip3 install --user jinja2 PyYAML script: - python3 ./.gitlab-ci/generate-gitlab-ci.py - git diff --exit-code && exit 0 || true @@ -343,7 +343,7 @@ fedora:31@qemu-prep: {% endif %} needs: ['{{ distro.name }}:{{ distro.version }}@container-prep'] -{% if distro.meson|default(True) %} +{% if not distro.build is defined or distro.build.meson|default(True) %} {{ distro.name }}:{{ distro.version }}@meson-build: extends: .meson-build@template stage: meson -- 2.34.1