stages:
  - build

# with :; prevent from run it on windows
before_script:
  - ":; uname -a"
  - ":; cat /etc/os-release"
  - ":; pwd"
  - ":; cat /proc/sys/kernel/core_pattern"
  - ":; mkdir logs || true"
  - ":; ${UPDATEREPOS}"
  - ":; ${DOCKERRETRY} ${PMUPDATE} >logs/apt.log"
  - ":; ${DOCKERRETRY} ${PMINSTALL} ${PACKAGES} >>logs/apt.log"
  - ":; ./tools/ci/scripts/clonesrc.sh"
  - ":; cd manaplus"

image: debian:unstable
variables:
  GET_SOURCES_ATTEMPTS: "5"
  ARTIFACT_DOWNLOAD_ATTEMPTS: "5"
  UPDATEREPOS: "tools/ci/scripts/updaterepos.sh"
  PMUPDATE: "apt-get update"
  PMINSTALL: "apt-get install -y -qq"
  DOCKERRETRY: "./tools/ci/scripts/dockerretry.sh"
  GIT_DEPTH: "1"

.job-push: &job-push
  artifacts:
    paths:
    - logs
    - manaplus/logs
    when: always
    expire_in: 3 week
  dependencies: []

.job-always: &job-always
  artifacts:
    paths:
    - logs
    - manaplus/logs
    when: always
    expire_in: 3 week
  dependencies: []

.fedora_gcc-snapshot_sanitize_tests:
  stage: build
  script:
  - ./tools/ci/jobs/gccsnapshot_sanitize_tests.sh --without-dyecmd --without-manaplusgame
  - ldd ./src/manaplustests | grep "libasan"
  <<: *job-push
  image: fedora:rawhide
  variables:
    PMUPDATE: "dnf --nogpgcheck install --refresh -y @development-tools"
    PMINSTALL: "dnf --nogpgcheck install -y git bash tar findutils gcc gcc-c++ make libpng-devel libcurl-devel openssl-devel libxml2-devel gcc SDL-devel SDL_net-devel SDL_image-devel SDL_ttf-devel SDL_mixer-devel SDL_gfx-devel zlib-devel gettext-devel automake autoconf valgrind libasan liblsan libubsan"
    FLAGS: "gccfedora.sh"
  tags:
  - docker

.fedora_gcc-snapshot_sanitize_sdl2_tests:
  stage: build
  script:
  - ./tools/ci/jobs/gccsnapshot_sanitize_tests.sh --with-sdl2 --without-dyecmd --without-manaplusgame
  - ldd ./src/manaplustests | grep "libasan"
  <<: *job-push
  image: fedora:rawhide
  variables:
    PMUPDATE: "dnf --nogpgcheck install --refresh -y @development-tools"
    PMINSTALL: "dnf --nogpgcheck install -y git bash tar findutils mesa-libGL-devel gcc gcc-c++ make libpng-devel libcurl-devel openssl-devel libxml2-devel gcc SDL2-devel SDL2_net-devel SDL2_image-devel SDL2_ttf-devel SDL2_mixer-devel SDL2_gfx-devel zlib-devel gettext-devel automake autoconf valgrind libasan liblsan libubsan"
    FLAGS: "gccfedora.sh"
  tags:
  - docker

fedora_gcc-snapshot_tests:
  stage: build
  script:
  - ./tools/ci/jobs/gccsnapshot_tests.sh --without-dyecmd --without-manaplusgame
  <<: *job-push
  image: fedora:rawhide
  variables:
    PMUPDATE: "dnf --nogpgcheck install --refresh -y @development-tools"
    PMINSTALL: "dnf --nogpgcheck install -y git bash tar findutils gcc gcc-c++ make libpng-devel libcurl-devel openssl-devel libxml2-devel gcc SDL-devel SDL_net-devel SDL_image-devel SDL_ttf-devel SDL_mixer-devel SDL_gfx-devel zlib-devel gettext-devel automake autoconf valgrind"
    FLAGS: "gccfedora.sh"
  tags:
  - docker

fedora_gcc-snapshot_sdl2_tests:
  stage: build
  script:
  - ./tools/ci/jobs/gccsnapshot_tests.sh --with-sdl2 --without-dyecmd --without-manaplusgame
  <<: *job-push
  image: fedora:rawhide
  variables:
    PMUPDATE: "dnf --nogpgcheck install --refresh -y @development-tools"
    PMINSTALL: "dnf --nogpgcheck install -y git bash tar findutils mesa-libGL-devel gcc gcc-c++ make libpng-devel libcurl-devel openssl-devel libxml2-devel gcc SDL2-devel SDL2_net-devel SDL2_image-devel SDL2_ttf-devel SDL2_mixer-devel SDL2_gfx-devel zlib-devel gettext-devel automake autoconf valgrind"
    FLAGS: "gccfedora.sh"
  tags:
  - docker

fedora_gcc-snapshot:
  stage: build
  script:
  - ./tools/ci/jobs/gccsnapshot.sh
  - ./tools/ci/scripts/runtests.sh
  <<: *job-push
  image: fedora:rawhide
  variables:
    PMUPDATE: "dnf --nogpgcheck install --refresh -y @development-tools"
    PMINSTALL: "dnf --nogpgcheck install -y git nc bash tar findutils gcc gcc-c++ make libpng-devel libcurl-devel openssl-devel libxml2-devel gcc SDL-devel SDL_net-devel SDL_image-devel SDL_ttf-devel SDL_mixer-devel SDL_gfx-devel zlib-devel gettext-devel automake autoconf"
    FLAGS: "gccfedora.sh"
  tags:
  - docker

fedora_gcc-snapshot_sdl2:
  stage: build
  script:
  - ./tools/ci/jobs/gccsnapshot.sh --with-sdl2
  - ./tools/ci/scripts/runtests.sh
  <<: *job-push
  image: fedora:rawhide
  variables:
    PMUPDATE: "dnf --nogpgcheck install --refresh -y @development-tools"
    PMINSTALL: "dnf --nogpgcheck install -y git nc bash tar findutils mesa-libGL-devel gcc gcc-c++ make libpng-devel libcurl-devel openssl-devel libxml2-devel gcc SDL2-devel SDL2_net-devel SDL2_image-devel SDL2_ttf-devel SDL2_mixer-devel SDL2_gfx-devel zlib-devel gettext-devel automake autoconf"
    FLAGS: "gccfedora.sh"
  tags:
  - docker
