Continuous integration for a Latex project in GitLab

A majority of research articles are written in Latex and several software development projects include Latex documentation. When publishing changes on such project, it's important to ensure all Latex resources still compile correctly. Sounds like a job for continuous integration! We will see how to quickly setup ci in GitLab for such project.

GitLab provides various CI examples centralized here; it goes from simple templates per language to more complete examples. Of course, it contains a template for Latex:

# use docker image with latex preinstalled
# since there is no official latex image, use
# possible alternative:
image: blang/latex
    - latexmk -pdf
      - "*.pdf"

Save this template in a file named .gitlab-ci.yml in your project and publish your changes to GitLab, that's it! A build will run to compile your latex sources, if it succeeds, the result pdf will be accessible in the build artifacts.

This build checks that the compilation succeeds and provides an history of your pdfs. If you don't care about old obsolete pdfs, you may add the following line in your yaml:

    expire_in: 1 week
      - "*.pdf"

Attention though, pdfs generated by the build won't be versioned in your repository. You still have to commit and push them manually. If you want to automatically push build results to a versioned storage, you may want to look at container registries