-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrender-gitlab-ci.py
63 lines (53 loc) · 2.18 KB
/
render-gitlab-ci.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import os
from glob import glob
from os.path import basename, dirname, splitext
from jinja2 import StrictUndefined, Template
TEMPLATE = Template("""# This file was generated by {{ gen_script }} in this repo!
default:
artifacts:
expire_in: 16 days
{% for file in tex_files %}
{{ file }}:
script:
- echo Latex file is $LATEX_FILE
- sed -i "/.*$LATEX_FILE}.*/s/^.*%//" pr.tex
- latexmk -pdf -shell-escape -verbose -file-line-error -interaction=nonstopmode pr.tex
- mv pr.pdf $LATEX_FILE.pdf
variables:
GIT_SUBMODULE_STRATEGY: recursive
LATEX_FILE: {{ file }}
artifacts:
paths:
- $LATEX_FILE.pdf
{% endfor %}
{% for file in exercise_slides %}
programming-exercises/{{ file }}:
script:
- echo Latex file is $LATEX_FILE
- cd programming-exercises/
- latexmk -pdf -shell-escape -verbose -file-line-error -interaction=nonstopmode $LATEX_FILE
variables:
GIT_SUBMODULE_STRATEGY: recursive
LATEX_FILE: {{ file }}
artifacts:
paths:
- programming-exercises/$LATEX_FILE.pdf
{% endfor %}
""", undefined=StrictUndefined)
os.chdir(dirname(__file__))
tex_files = sorted([splitext(f)[0] for f in glob('*.tex') if f not in ['00_cover.tex',
'commands.tex',
'license4.tex',
'pr.tex',
'nextTime.tex',
'pr-zus.tex',
'header.tex']])
print(f'{tex_files=}')
exercise_slides = sorted([splitext(f)[0].replace('programming-exercises/', '')
for f in glob('programming-exercises/*.tex')
if f not in ['programming-exercises/preamble.tex', ]])
print(f'{exercise_slides=}')
with open('.gitlab-ci.yml', 'w') as f:
f.write(TEMPLATE.render({'tex_files': tex_files,
'gen_script': basename(__file__),
'exercise_slides': exercise_slides}))