.gitlab-ci.yml 4.66 KB
Newer Older
1 2 3 4 5 6
# ======================================================================================
# ======================================================================================
# Global defaults, overwritable in each job
# ======================================================================================
# ======================================================================================

7
default:
8 9 10 11 12 13
    image:
        # Image from dockerhub per default. Specify full path to use a different image.
        name: alexpovel/latex
        # Override any entrypoint back to a naked shell so that job `script`s can be
        # executed normally.
        # See also: https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#overriding-the-entrypoint-of-an-image
14 15 16 17 18
        # Cannot use `make` as ENTRYPOINT even if all scripts used it: runner expects an
        # entrypoint that accepts shell scripts ("the runner expects that the image has
        # no entrypoint or that the entrypoint is prepared to start a shell command. ")
        # See also:
        # https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#overriding-the-entrypoint-of-an-image
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
        entrypoint: [""]

# ======================================================================================
# ======================================================================================
# Job templates (start with period).
# Not actually run by the runner, but can be used to extend other jobs, keeping the
# config dry.
# The main logic happens here, the actual jobs only combine these as needed.
# ======================================================================================
# ======================================================================================

.make: # Core job template
    # Use make as the basis for all jobs. This allows to also easily run the steps
    # offline/locally, as well as transition to other CI engines. All job names have to
    # correspond to targets make knows about (see Makefile).
    # Note we cannot have `default: script:`, so this approach works better.
    script: make ${CI_JOB_NAME}

.pdf: # Job template for PDF-producing jobs
    extends: .make
    stage: build
    before_script:
        # Make sure to clean any PDFs that might have crept in via the cache, forcing a
        # remake at least once (otherwise, no remake might occur).
        # It would be better to exclude the PDFs from the cache in the first place. This is
        # not available yet, see: https://gitlab.com/gitlab-org/gitlab/-/issues/220017#note_440142507
        - make clean-pdf
46 47 48 49 50 51 52 53
    # LaTeX and pandoc stages both provide PDFs:
    artifacts:
        # artifacts.zip is renamed to current tag/branch:
        name: "$CI_COMMIT_REF_NAME"
        paths:
            # Return all found *.pdf-files using wildcard.
            # For example, a thesis and the accompanying presentation.
            - "*.pdf"
54 55 56 57 58 59 60 61 62

.test:
    extends: .make
    stage: test
    # Would be ideal to read the image tag from `pyproject.toml`, i.e. the poetry project
    # file. See also: https://gitlab.com/gitlab-org/gitlab/-/issues/34202#note_444271649.
    image: python:3.7.9
    variables:
        PIP_DOWNLOAD_DIR: ".pip"
63
    before_script:
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
        - cd tests
        # Allow caching by only downloading first:
        - pip download --dest=${PIP_DOWNLOAD_DIR} poetry
        - pip install --find-links=${PIP_DOWNLOAD_DIR} poetry
        # Make available for caching by installing to current directory:
        - poetry config virtualenvs.in-project true
        - poetry install -vv
    cache:
        untracked: true
        key:
            files:
                # Cache is invalidated if any of these files changes, but also shared if
                # these two files are equal.
                - poetry.lock
                - pyproject.toml

# ======================================================================================
# ======================================================================================
# Actual job definitions.
# All job names have to correspond to make targets, see .make above.
# ======================================================================================
# ======================================================================================
Alexander Povel's avatar
Alexander Povel committed
86

87
preflight:
88
    extends: .make
89 90 91 92 93
    stage: .pre
    # Preflight checks are relevant, but we are interested in how exactly later jobs
    # error out if preflight fails. Therefore, allow failure.
    allow_failure: true

94 95
tex:
    extends: .pdf
Alexander Povel's avatar
Alexander Povel committed
96
    cache:
97 98
        untracked: true
        key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
Alexander Povel's avatar
Alexander Povel committed
99

100 101 102 103 104 105 106 107 108
README.pdf:
    extends: .pdf

test-self:
    extends: .test
    needs: [] # Allows job to start immediately

test-pdfs:
    extends: .test