libevdev/.gitlab-ci/generate-gitlab-ci.py
Peter Hutterer 67b6e447e7 Auto-generate the gitlab CI script
There is so much duplication between the various jobs that it's hard to keep
track of it manually. Let's employ a python script to generate those bits,
reducing the actual gitlab-ci.yml to the hand-written parts only.

The new script takes the .gitlab-ci/gitlab-ci.yml.in and simply appends the
generated parts to it. Most of it is straightforward, only centos needs some
custom parts because of missing doxygen.

The diff is a bit hard to review, thanks to the python script we now group
based on distribution, not based on name (i.e. all fedoras in one group
instead of all container-preps in one group).
And since we're generating anyway, some of the in-between stages were removed
(e.g. $DISTRO-build@template).

A new CI job is added to run a diff against the .gitlab-ci.yml that's checked
in and the one generated by this script. If they differ, we fail.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-17 14:23:18 +10:00

48 lines
1.4 KiB
Python
Executable file

#!/usr/bin/env python3
# vim: set expandtab shiftwidth=4:
# This file generates the .gitlab-ci.yml file that defines the pipeline.
import jinja2
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'),
}
},
},
{
'name': 'centos', 'version': '8',
'build': {
'extra_variables': {
'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'},
]
def generate_template():
env = jinja2.Environment(loader=jinja2.FileSystemLoader('./.gitlab-ci'),
trim_blocks=True, lstrip_blocks=True)
template = env.get_template('gitlab-ci.tmpl')
config = {'distributions': distributions}
with open('.gitlab-ci.yml', 'w') as fd:
template.stream(config).dump(fd)
if __name__ == '__main__':
generate_template()