variables:
  GIT_SUBMODULE_STRATEGY: normal

stages:
  - min-bundles
  - basic-bundles
  - test

default:
  tags:
    - ciao_test_base

core:
  stage: min-bundles
  script:
    - builder/etc/gitlab-ci.sh core
  artifacts:
    expire_in: 2h
    untracked: true
    paths:
      - build-boot/
      - build/
  needs: []

ciaopp:
  stage: basic-bundles
  script:
    - builder/etc/gitlab-ci.sh ciaopp
  artifacts:
    expire_in: 2h
    untracked: true
    paths:
      - build-boot/
      - build/
  needs: [core]

ciaopp_lite:
  stage: basic-bundles
  script:
    - builder/etc/gitlab-ci.sh ciaopp_lite
  artifacts:
    expire_in: 2h
    untracked: true
    paths:
      - build-boot/
      - build/
  needs: [core]

ciaopp_lite.test.incanal_assrts:
  stage: test
  script:
    - builder/etc/gitlab-ci.sh ciaopp_lite.test.incanal_assrts
  needs: [ciaopp_lite]

ciaopp_lite.analyze.core:
  stage: test
  script:
    - builder/etc/gitlab-ci.sh ciaopp_lite.analyze.core
  needs: [ciaopp_lite]
  artifacts:
    when: always
    paths:
      - build/xmlreport/*.xml
    reports:
      junit:
        - build/xmlreport/module.xml
        - build/xmlreport/gr.xml

ciaopp_lite.test.rtchecks:
  stage: test
  script:
    - builder/etc/gitlab-ci.sh ciaopp_lite.test.rtchecks
  needs: [ciaopp_lite]

ciaopp_lite.test.incanal:
  stage: test
  script:
    - builder/etc/gitlab-ci.sh ciaopp_lite.test.incanal
  needs: [ciaopp_lite]

ciaopp_extra.test:
  stage: test
  allow_failure: true
  script:
    - builder/etc/gitlab-ci.sh ciaopp_extra.test
  needs: [ciaopp]

ciaopp_cost.test:
  stage: test
  allow_failure: true
  script:
    - builder/etc/gitlab-ci.sh ciaopp_cost.test
  needs: [ciaopp]

# This job should (probably) be removed once res_plai tests are fixed/checked/updated
# It is created to have a small set of tests for which res_plai output is
#  trusted to be correct and precise on 31/01/23.
ciaopp_cost.test.smalltrustedtmp.resplai:
  stage: test
  allow_failure: true
  script:
    - builder/etc/gitlab-ci.sh ciaopp_cost.test.smalltrustedtmp.resplai
  needs: [ciaopp]

lpdoc:
  stage: basic-bundles
  script:
    - builder/etc/gitlab-ci.sh lpdoc
  needs: [core]

bibutils:
  stage: basic-bundles
  script:
    - builder/etc/gitlab-ci.sh bibutils
  needs: [core]

jvm_in_ciao:
  stage: basic-bundles
  script:
    - builder/etc/gitlab-ci.sh jvm_in_ciao
  needs: [core]

ciao_gui:
  stage: basic-bundles
  script:
    - builder/etc/gitlab-ci.sh ciao_gui
  needs: [core]

wui:
  stage: basic-bundles
  allow_failure: true
  retry:
    max: 2
    when: script_failure
  script:
    - builder/etc/gitlab-ci.sh wui
  artifacts:
    expire_in: 2h
    untracked: true
    paths:
      - build/
  cache:
    paths:
      - third-party/
  needs: [core]

website:
  stage: test
  allow_failure: true
  script:
    - builder/etc/gitlab-ci.sh website
  needs: [wui]

core.test:
  stage: test
  script:
    - builder/etc/gitlab-ci.sh core.test
  needs: [core]

core_OC.test:
  stage: test
  script:
    - builder/etc/gitlab-ci.sh core_OC.test
  needs: [core]

core.test.rtchecks:
  stage: test
  script:
    - builder/etc/gitlab-ci.sh core.test.rtchecks
  allow_failure: true
  needs: [core]

ciaodbg.test.unittest:
  stage: test
  script:
    - builder/etc/gitlab-ci.sh ciaodbg.test.unittest
  allow_failure: true
  needs: [core]

iso_tests.test:
  stage: test
  script:
    - builder/etc/gitlab-ci.sh iso_tests.test
  allow_failure: true
  needs: [core]

ciao_emacs.test:
  stage: test
  script:
    - DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get update
    - DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -qq install -y --no-install-recommends emacs-nox
    - builder/etc/gitlab-ci.sh ciao_emacs.test
  needs: [core]

deepfind.test:
  stage: test
  script:
    - builder/etc/gitlab-ci.sh deepfind.test
  needs: [ciaopp_lite]
