# SPDX-FileCopyrightText: 2020-2026 Laurent Montel <montel@kde.org>
# SPDX-License-Identifier: CC0-1.0

include:
  - project: sysadmin/ci-utilities
    file:
      - /gitlab-templates/linux-qt6.yml
      - /gitlab-templates/linux-qt6-next.yml
      - /gitlab-templates/freebsd-qt6.yml
      - /gitlab-templates/windows-qt6.yml
      - /gitlab-templates/cppcheck.yml
      - /gitlab-templates/alpine-qt6.yml
      - /gitlab-templates/pre-commit.yml

build_clazy:
  extends:
    - .ci_linux_base
    - .suse_tumbleweed_qt6stable
  rules:
    # only run on merge requests
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  variables:
    CLAZY_CHECKS: level0,level1,qstring-allocations,no-qstring-arg,no-connect-not-normalized,no-fully-qualified-moc-types,no-const-signal-or-slot,no-qproperty-without-notify,no-incorrect-emit,no-connect-3arg-lambda,no-range-loop-reference,no-wrong-qevent-cast,no-detaching-temporary,no-child-event-qobject-cast
    CC: clang
    CXX: clazy
  script:
    - git config --global --add safe.directory $CI_PROJECT_DIR
    - python3 -u ci-utilities/run-ci-build.py --project $CI_PROJECT_NAME --branch $CI_COMMIT_REF_NAME --platform Linux/Qt6/Shared --only-setup-environment
    - mkdir -p /tmp/$CI_PROJECT_NAME-build
    - cd /tmp/$CI_PROJECT_NAME-build
    # we don't care about clazy issues in tests
    - cmake -DENABLE_PCH=OFF -DBUILD_TESTING=OFF -G Ninja -DCMAKE_INSTALL_PREFIX=$CI_PROJECT_DIR/_install -DKF6DocTools_FOUND=false -DKF_SKIP_PO_PROCESSING=True $CI_PROJECT_DIR
    - ninja -k 0
  artifacts: null

build_clangtidy:
 extends:
  - .ci_linux_base
  - .suse_tumbleweed_qt6stable
 rules:
  # only run on merge requests
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
 variables:
    CC: clang
    CXX: clang++
 script:
  - git config --global --add safe.directory $CI_PROJECT_DIR
  - python3 -u ci-utilities/run-ci-build.py --project $CI_PROJECT_NAME --branch $CI_COMMIT_REF_NAME --platform Linux/Qt6/Shared --only-setup-environment
  - mkdir -p /tmp/$CI_PROJECT_NAME-tidy-build
  - cd /tmp/$CI_PROJECT_NAME-tidy-build
  - cmake -DCMAKE_CXX_CLANG_TIDY=clang-tidy -DENABLE_PCH=OFF -DKF_SKIP_PO_PROCESSING=True -G Ninja -DCMAKE_INSTALL_PREFIX=$CI_PROJECT_DIR/_install -DKF6DocTools_FOUND=false $CI_PROJECT_DIR
  - cp "$CI_PROJECT_DIR/.clang-tidy" .
  - ninja -k 0
 artifacts: null
