include:
 - 'https://source.puri.sm/Librem5/librem5-ci/raw/master/librem5-pipeline-definitions.yml'
 - 'https://source.puri.sm/Librem5/librem5-ci/raw/master/librem5-pipeline-byzantium-jobs.yml'

stages:
  - build
  - test
  - package
  - test-package

.tags: &tags
  tags:
    - librem5

before_script:
  - export DEBIAN_FRONTEND=noninteractive
  - apt-get -y update

build-pureos-gcc-byzantium:
  <<: *tags
  image: pureos/byzantium
  stage: build
  script:
    - apt-get -y build-dep .
    - apt-get -y install libgtk-3-bin xvfb
    - export LC_ALL=C.UTF-8
    - meson . _build -Db_coverage=true --werror
    - ninja -C _build
  artifacts:
    paths:
      - _build

test:debian-gcc:
  <<: *tags
  stage: test
  image: pureos/byzantium
  dependencies:
    - build-pureos-gcc-byzantium
  script:
    - apt-get -y build-dep .
    - apt-get -y install libgtk-3-bin xvfb lcov
    - export G_DEBUG=fatal-warnings
    - export LC_ALL=C.UTF-8
    - xvfb-run -a -s "-screen 0 1024x768x24" ninja -C _build test
    - ninja -C _build coverage
  coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/'

check-po:
  <<: *tags
  stage: test
  image: debian:bullseye
  dependencies:
    - build-pureos-gcc-byzantium
  before_script:
    - apt-get -y update
    - apt-get -y install intltool
  script:
    # barf on untranslated C files. Seems intltool
    # can't be told to exit with non-zero exit status
    # in this case
    - cd po/
    - intltool-update -m 2>&1 | grep -qs '/.*\.c' && { intltool-update -m; exit 1; } || exit 0
