image: ghcr.io/siemens/kas/kas-isar:latest

variables:
  GIT_STRATEGY: clone

.common-build: &common-build
  stage: build
  before_script:
    - export http_proxy=$HTTP_PROXY
    - export https_proxy=$HTTPS_PROXY
    - export ftp_proxy=$FTP_PROXY
    - export no_proxy=$NO_PROXY
    - export DISTRO_APT_PREMIRRORS=$DISTRO_APT_PREMIRRORS
  artifacts:
    name: "logs-$CI_JOB_ID"
    paths:
      - build/tmp/work/*/*/*/temp
      - build/job-results
    reports:
      junit:
        - build/job-results/job*/results.xml
    when: always
    expire_in: 1 week

fast-ci:
  <<: *common-build
  except:
    - schedules
  script:
    - scripts/ci_build.sh -q -f -d

full-ci:
  <<: *common-build
  only:
    - schedules
  script:
    - PREVIOUS_SHA="$(cat .CI_COMMIT_SHA || true)"
    - if [ "$CI_COMMIT_SHA" != "$PREVIOUS_SHA" ]; then
          echo "$CI_COMMIT_SHA" > .CI_COMMIT_SHA;
          scripts/ci_build.sh -q -c -r -d;
      fi
  cache:
    key: "$CI_COMMIT_REF_SLUG"
    paths:
      - .CI_COMMIT_SHA
