mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-20 12:40:07 +01:00
gitlab CI: extend the generation script to be somewhat more generic
Mostly busywork, it moves the hardcoded paths into a variables, etc. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
fa0a3fc445
commit
12211d452a
1 changed files with 27 additions and 3 deletions
|
|
@ -3,7 +3,13 @@
|
||||||
|
|
||||||
# This file generates the .gitlab-ci.yml file that defines the pipeline.
|
# This file generates the .gitlab-ci.yml file that defines the pipeline.
|
||||||
|
|
||||||
|
import argparse
|
||||||
import jinja2
|
import jinja2
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
distributions = [
|
distributions = [
|
||||||
{'name': 'fedora', 'version': '30'},
|
{'name': 'fedora', 'version': '30'},
|
||||||
|
|
@ -35,16 +41,34 @@ distributions = [
|
||||||
{'name': 'alpine', 'version': 'latest'},
|
{'name': 'alpine', 'version': 'latest'},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# The various sources for templating
|
||||||
|
SOURCE_DIR = Path('.gitlab-ci')
|
||||||
|
TEMPLATE_FILE = 'gitlab-ci.tmpl'
|
||||||
|
|
||||||
|
BASE_DIR = Path('.')
|
||||||
|
OUTPUT_FILE = '.gitlab-ci.yml'
|
||||||
|
|
||||||
def generate_template():
|
def generate_template():
|
||||||
env = jinja2.Environment(loader=jinja2.FileSystemLoader('./.gitlab-ci'),
|
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.fspath(SOURCE_DIR)),
|
||||||
trim_blocks=True, lstrip_blocks=True)
|
trim_blocks=True, lstrip_blocks=True)
|
||||||
|
|
||||||
template = env.get_template('gitlab-ci.tmpl')
|
template = env.get_template(TEMPLATE_FILE)
|
||||||
config = {'distributions': distributions}
|
config = {'distributions': distributions}
|
||||||
with open('.gitlab-ci.yml', 'w') as fd:
|
with open(BASE_DIR / OUTPUT_FILE, 'w') as fd:
|
||||||
template.stream(config).dump(fd)
|
template.stream(config).dump(fd)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
description = ('''
|
||||||
|
This script generates the .gitlab-ci.yml file.
|
||||||
|
|
||||||
|
It must be run from the git repository root directory and will overwrite
|
||||||
|
the existing .gitlab-ci.yml file.
|
||||||
|
''')
|
||||||
|
parser = argparse.ArgumentParser(description=description)
|
||||||
|
parser.parse_args()
|
||||||
|
|
||||||
|
if not SOURCE_DIR.exists():
|
||||||
|
print('Error: run me from the top-level tree')
|
||||||
|
sys.exit(1)
|
||||||
generate_template()
|
generate_template()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue