include:
    - project: 'steam/steam-ci-pipeline'
      file: '/steam-gitlab-ci-common.yml'

    - project: 'steam/steam-ci-pipeline'
      file: '/steam-gitlab-ci-pipeline.yml'

variables:
    BUILD_IMAGE: docker.internal.steamos.cloud/steamos/package-builder:buster
    STEAM_CI_USE_BINARIES_FROM: autopkgtest
    STEAM_CI_DEPENDENCIES: >-
        debhelper
        glslang-tools
        gtk-doc-tools
        libelf-dev
        libegl1-mesa-dev
        libgl1-mesa-dev
        libgles2-mesa-dev
        libglib2.0-dev
        libjson-glib-dev
        libtheora-dev
        libvulkan-dev
        libx11-dev
        libxcb1-dev
        libxcomposite-dev
        locales
        meson
        pandoc

stages:
    - build
    - test

autopkgtest:
    stage: test
    variables:
        BUILD_IMAGE: docker.internal.steamos.cloud/steamrt/sdk:scout-latest
        STEAM_CI_INSTALL_SCRIPT: |
            # Workaround for the build regression described in !88
            apt-get -y remove libsteam-runtime-tools-0-helpers

ubsan:
    stage: test
    image: "${BUILD_IMAGE}"
    script:
        - |
            set -eux
            export DEBIAN_FRONTEND=noninteractive

            apt-get install -y --no-install-recommends \
                ccache \
                clang \
                clang-tools \
                ${NULL+}

            rm -fr builddir
            meson \
                -Db_lundef=false \
                -Db_sanitize=address,undefined \
                --werror \
                builddir
            ninja -C builddir
            meson test -C builddir -v

            export CC=clang
            export CXX=clang++

            rm -fr builddir
            meson \
                -Db_lundef=false \
                -Db_sanitize=address,undefined \
                --werror \
                builddir
            ninja -C builddir scan-build
            meson test -C builddir -v
