diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..4ad5366831860f60c89bd42a6e8e4a3e8c88ce24 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,45 @@ +compile_latex: + image: aergus/latex # the docker image by aergus https://hub.docker.com/r/aergus/latex/ + stage: build + variables: + GIT_SUBMODULE_STRATEGY: recursive + script: + # the following script requires bash + # when editing, be careful, not to use any colons since they mess up the yaml parser! + # compile all the PDFs you are interested in: + - verb() { echo -e "\e[32;1m===== $* =====\e[0m" ; } + - failed=( ) + - compile_tex() { latexmk -f -cd -pdf "$1" ; } + # activate the following line if you use a custom makefile + #- compile_tex() { make "${1%%.tex}.pdf" ; } + - mapfile -t gitfiles < <(git ls-files) + - mapfile -d $'\0' -t texfiles < <(grep -lZ -d skip --include '*.tex' -E '^[^%]*\\documentclass' "${gitfiles[@]}") + - for t in "${texfiles[@]}" ; do verb "Compiling $t" ; compile_tex "$t" || failed+=( "$t" ) ; done + - git ls-files -z | xargs -0 rm -v -f # remove all tracked files such that they are not included in the artifacts + - echo "Successful Compilation Coverage $(((${#texfiles[@]}-${#failed[@]})*10000/${#texfiles[@]}))" | sed 's/..$/\.&/' + - if [ "${#failed[@]}" -ge 1 ] ; then verb "failed files $failed" ; false ; fi + # the second last line in the script prints the statistics which are parsed by the following regex: + coverage: /^Successful Compilation Coverage [0-9]*\.[0-9][0-9]/ + cache: + untracked: true # cache all pdf files for subsequent runs + artifacts: + name: "${CI_PROJECT_NAME}-pdfs" + when: always + expire_in: 10 yrs + paths: + - ./*.pdf + - ./*/*.pdf + - ./*/*/*.pdf + + + # You can link the most recently *finished* artifacts by a badge: + # + # Link: https://gitlab.cs.fau.de/%{project_path}/-/jobs/artifacts/%{default_branch}/browse?job=compile_latex + # Badge image URL: https://gitlab.cs.fau.de/%{project_path}/badges/%{default_branch}/build.svg + # + # e.g.: https://gitlab.cs.fau.de/thorsten/coalgpartref/-/jobs/artifacts/master/browse?job=compile_latex + # see also https://docs.gitlab.com/ee/user/project/pipelines/job_artifacts.html#downloading-the-latest-artifacts + # + #environment: + # name: Recent PDFs + # url: https://gitlab.cs.fau.de/$CI_PROJECT_PATH/builds/$CI_BUILD_ID/artifacts/browse