variables:
  MAKEFLAGS: "-j10"
  VERBOSE: 1

default:
  after_script:
    - build-aux/print-failed-test-output build/meson-logs/testlog.json

.arch-test:
  image: archlinux:base-devel
  before_script:
    - >
      pacman -Syu --needed --noconfirm
      git
      gpgme libarchive curl
      python
      fakeroot fakechroot
      meson
  artifacts:
      when: always
      paths:
        - build/meson-logs/meson-log.txt

arch:
  extends: .arch-test
  script:
    - meson setup build
    - ninja -C build
    - fakechroot meson test -C build

arch-debug:
  extends: .arch-test
  script:
    - meson setup --buildtype=debug --werror build
    - ninja -C build
    - fakechroot meson test -C build

arch-docs:
  extends: .arch-test
  script:
    - pacman -Syu --needed --noconfirm asciidoc
    - meson setup -Ddoc=enabled build
    - ninja -C build

arch-clang:
  extends: .arch-test
  script:
    - pacman -Syu --needed --noconfirm clang
    - CC=clang meson setup build
    - ninja -C build
    - fakechroot meson test -C build

#arch-valgrind:
#  extends: .arch-test
#  script:
#    - pacman -Syu --needed --noconfirm valgrind
#    - pacman -U --noconfirm https://geo.mirror.pkgbuild.com/core-debug/os/x86_64/glibc-debug-$(pacman -S --print-format %v glibc)-x86_64.pkg.tar.zst
#    - meson setup build
#    - ninja -C build
#    - PACTEST_VALGRIND=1 fakechroot meson test -C build

arch-nettle:
  extends: .arch-test
  script:
    - meson setup -Dcrypto=nettle --buildtype=debug build
    - ninja -C build
    - fakechroot meson test -C build

arch-no-gpg:
  extends: .arch-test
  script:
    - meson setup -Dgpgme=disabled --buildtype=debug build
    - ninja -C build
    - fakechroot meson test -C build

arch-no-curl:
  extends: .arch-test
  script:
    - meson setup -Dcurl=disabled --buildtype=debug build
    - ninja -C build
    - fakechroot meson test -C build

arch-no-nls:
  extends: .arch-test
  script:
    - meson setup -Di18n=false --buildtype=debug build
    - ninja -C build
    - fakechroot meson test -C build

debian:
  image: debian:bullseye
  before_script:
    - apt update
    - >
      apt -y install --no-install-recommends
      git pkg-config meson gcc libtool
      libgpgme-dev libarchive-dev libcurl4-openssl-dev libssl-dev curl
      gettext python3 python3-setuptools dash gawk ca-certificates
      fakeroot fakechroot
  script:
    - meson setup --buildtype=debug build
    - ninja -C build
    - fakechroot meson test -C build

fedora:
  image: fedora
  before_script:
    - >
      dnf -y install
      git findutils patch sed
      meson gcc libtool bsdtar
      gpgme-devel libarchive-devel libcurl-devel openssl-devel gettext-devel
      asciidoc python3 dash gawk
      fakeroot fakechroot
      perl-Module-Load-Conditional
  script:
    - meson setup --buildtype=debug build
    - ninja -C build
    - fakechroot meson test -C build
