.intel-common-rules:
  stage: intel
  rules:
    - changes: &intel_common_file_list
        - src/intel/*
        - src/intel/blorp/**/*
        - src/intel/common/**/*
        - src/intel/compiler/**/*
        - src/intel/dev/**/*
        - src/intel/ds/**/*
        - src/intel/genxml/**/*
        - src/intel/isl/**/*
        - src/intel/nullhw-layer/**/*
        - src/intel/perf/**/*
        - src/intel/tools/**/*
        - src/intel/ci/gitlab-ci.yml
        - src/intel/ci/gitlab-ci-inc.yml
        - src/intel/ci/deqp-$DEQP_SUITE.toml
        - src/intel/ci/$GPU_VERSION-fails.txt
        - src/intel/ci/$GPU_VERSION-flakes.txt
        - src/intel/ci/$GPU_VERSION-skips.txt
        - src/intel/ci/$VK_DRIVER-skips.txt
        - src/intel/ci/$GALLIUM_DRIVER-skips.txt
        - src/intel/ci/$DRIVER_NAME-skips.txt
        - src/intel/ci/$PIGLIT_TRACES_FILE
      when: on_success

.intel-common-manual-rules:
  stage: intel-postmerge
  rules:
    - changes:
        *intel_common_file_list
      when: manual

.i915g-rules:
  stage: intel
  rules:
    - !reference [.test, rules]
    - !reference [.gl-rules, rules]
    - !reference [.intel-common-rules, rules]
    - changes: &i915g_file_list
        - src/gallium/drivers/i915/**/*
        - src/gallium/winsys/i915/**/*
      when: on_success

.i915g-manual-rules:
  stage: intel-postmerge
  extends: .no-auto-retry
  rules:
    - !reference [.test, rules]
    - !reference [.gl-manual-rules, rules]
    - changes:
        *i915g_file_list
      when: manual

.crocus-rules:
  stage: intel
  rules:
    - !reference [.test, rules]
    - !reference [.anholt-farm-rules, rules]
    - !reference [.gl-rules, rules]
    - !reference [.intel-common-rules, rules]
    - changes: &crocus_file_list
        - src/gallium/drivers/crocus/**/*
        - src/gallium/winsys/crocus/**/*
      when: on_success

.crocus-manual-rules:
  stage: intel-postmerge
  extends: .no-auto-retry
  rules:
    - !reference [.test, rules]
    - !reference [.anholt-farm-manual-rules, rules]
    - !reference [.gl-manual-rules, rules]
    - changes:
        *crocus_file_list
      when: manual

.iris-rules:
  stage: intel
  rules:
    - !reference [.test, rules]
    - !reference [.no_scheduled_pipelines-rules, rules]
    - !reference [.collabora-farm-rules, rules]
    - !reference [.gl-rules, rules]
    - !reference [.intel-common-rules, rules]
    - changes: &iris_file_list
        - src/gallium/drivers/iris/**/*
        - src/gallium/winsys/iris/**/*
      when: on_success

.iris-manual-rules:
  stage: intel-postmerge
  extends: .no-auto-retry
  rules:
    - !reference [.test, rules]
    - !reference [.collabora-farm-manual-rules, rules]
    - !reference [.gl-manual-rules, rules]
    - changes:
        *iris_file_list
      when: manual

# Unfortunately we can't sed the on_success from another rules set, so we have
# to do duplicate the files lists to set the job to manual (see
# .performance-rules)
.iris-rules-performance:
  stage: performance
  extends: .no-auto-retry
  rules:
    - !reference [.test, rules]
    - !reference [.collabora-farm-manual-rules, rules]
    - !reference [.performance-rules, rules]
    - !reference [.gl-manual-rules, rules]
    - changes:
        *iris_file_list
      when: manual
  allow_failure: true # see comment in .performance-rules, which we don't inherit this line from.
  variables:
    JOB_PRIORITY: 40
    S3_ARTIFACT_NAME: "mesa-x86_64-default-release"
  needs:
    - kernel+rootfs_x86_64
    - debian-release

.anv-rules:
  stage: intel
  rules:
    - !reference [.test, rules]
    - !reference [.no_scheduled_pipelines-rules, rules]
    - !reference [.collabora-farm-rules, rules]
    - !reference [.vulkan-rules, rules]
    - !reference [.intel-common-rules, rules]
    - changes: &anv_file_list
        - src/intel/vulkan/**/*
      when: on_success

.anv-manual-rules:
  stage: intel-postmerge
  extends: .no-auto-retry
  rules:
    - !reference [.test, rules]
    - !reference [.collabora-farm-manual-rules, rules]
    - !reference [.vulkan-manual-rules, rules]
    - !reference [.intel-common-manual-rules, rules]
    - changes:
        *anv_file_list
      when: manual

.hasvk-rules:
  stage: intel
  rules:
    - !reference [.test, rules]
    - !reference [.anholt-farm-rules, rules]
    - !reference [.vulkan-rules, rules]
    - !reference [.intel-common-rules, rules]
    - changes: &hasvk_file_list
        - src/intel/vulkan_hasvk/**/*
      when: on_success

.hasvk-manual-rules:
  stage: intel-postmerge
  extends: .no-auto-retry
  rules:
    - !reference [.test, rules]
    - !reference [.anholt-farm-manual-rules, rules]
    - !reference [.vulkan-manual-rules, rules]
    - !reference [.intel-common-manual-rules, rules]
    - changes:
        *hasvk_file_list
      when: manual

# ruleset to trigger on changes affecting either anv or iris, for jobs using both (piglit, skqp)
.intel-rules:
  stage: intel
  rules:
    - !reference [.test, rules]
    - !reference [.iris-rules, rules]
    - !reference [.anv-rules, rules]

.intel-manual-rules:
  stage: intel-postmerge
  rules:
    - !reference [.test, rules]
    - !reference [.iris-manual-rules, rules]
    - !reference [.anv-manual-rules, rules]


# Status: https://lava.collabora.dev/scheduler/device_type/acer-cb317-1h-c3z6-dedede
.lava-acer-cb317-1h-c3z6-dedede:x86_64:
  variables:
    DEVICE_TYPE: acer-cb317-1h-c3z6-dedede
    FARM: collabora
    FDO_CI_CONCURRENT: 3
    GPU_VERSION: iris-jsl
    HWCI_KERNEL_MODULES: i915
    RUNNER_TAG: mesa-ci-x86-64-lava-acer-cb317-1h-c3z6-dedede

# Status: https://lava.collabora.dev/scheduler/device_type/acer-cbv514-1h-34uz-brya
.lava-acer-cbv514-1h-34uz-brya:x86_64:
  variables:
    DEVICE_TYPE: acer-cbv514-1h-34uz-brya
    FDO_CI_CONCURRENT: 9
    GPU_VERSION: iris-adl
    HWCI_KERNEL_MODULES: i915
    RUNNER_TAG: mesa-ci-x86-64-lava-acer-cbv514-1h-34uz-brya

# Status: https://lava.collabora.dev/scheduler/device_type/asus-C523NA-A20057-coral
.lava-asus-C523NA-A20057-coral:x86_64:
  variables:
    DEVICE_TYPE: asus-C523NA-A20057-coral
    FARM: collabora
    FDO_CI_CONCURRENT: 5
    GPU_VERSION: iris-apl
    HWCI_KERNEL_MODULES: i915
    RUNNER_TAG: mesa-ci-x86-64-lava-asus-C523NA-A20057-coral

# Status: https://lava.collabora.dev/scheduler/device_type/hp-x360-12b-ca0010nr-n4020-octopus
.lava-hp-x360-12b-ca0010nr-n4020-octopus:x86_64:
  variables:
    DEVICE_TYPE: hp-x360-12b-ca0010nr-n4020-octopus
    FARM: collabora
    FDO_CI_CONCURRENT: 3
    GPU_VERSION: iris-glk
    HWCI_KERNEL_MODULES: i915
    RUNNER_TAG: mesa-ci-x86-64-lava-hp-x360-12b-ca0010nr-n4020-octopus

# Status: https://lava.collabora.dev/scheduler/device_type/acer-cp514-2h-1130g7-volteer
.lava-acer-cp514-2h-1130g7-volteer:x86_64:
  variables:
    BOOT_METHOD: depthcharge
    DEVICE_TYPE: acer-cp514-2h-1130g7-volteer
    FARM: collabora
    FDO_CI_CONCURRENT: 9
    GPU_VERSION: anv-tgl
    HWCI_KERNEL_MODULES: i915
    RUNNER_TAG: mesa-ci-x86-64-lava-acer-cp514-2h-1130g7-volteer

# Status: https://lava.collabora.dev/scheduler/device_type/acer-cp514-2h-1160g7-volteer
.lava-acer-cp514-2h-1160g7-volteer:x86_64:
  variables:
    BOOT_METHOD: depthcharge
    DEVICE_TYPE: acer-cp514-2h-1160g7-volteer
    FARM: collabora
    FDO_CI_CONCURRENT: 9
    GPU_VERSION: anv-tgl
    HWCI_KERNEL_MODULES: i915
    RUNNER_TAG: mesa-ci-x86-64-lava-acer-cp514-2h-1160g7-volteer

# Status: https://lava.collabora.dev/scheduler/device_type/asus-C433TA-AJ0005-rammus
.lava-asus-C433TA-AJ0005-rammus:x86_64:
  variables:
    DEVICE_TYPE: asus-C433TA-AJ0005-rammus
    FARM: collabora
    FDO_CI_CONCURRENT: 5
    GPU_VERSION: iris-amly
    HWCI_KERNEL_MODULES: i915
    RUNNER_TAG: mesa-ci-x86-64-lava-asus-C433TA-AJ0005-rammus

# Status: https://lava.collabora.dev/scheduler/device_type/hp-x360-14-G1-sona
.lava-hp-x360-14-G1-sona:x86_64:
  variables:
    DEVICE_TYPE: hp-x360-14-G1-sona
    FARM: collabora
    FDO_CI_CONCURRENT: 9
    GPU_VERSION: iris-kbl
    HWCI_KERNEL_MODULES: i915
    RUNNER_TAG: mesa-ci-x86-64-lava-hp-x360-14-G1-sona

# Status: https://lava.collabora.dev/scheduler/device_type/dell-latitude-5400-8665U-sarien
.lava-dell-latitude-5400-8665U-sarien:x86_64:
  variables:
    DEVICE_TYPE: dell-latitude-5400-8665U-sarien
    FARM: collabora
    FDO_CI_CONCURRENT: 9
    GPU_VERSION: iris-whl
    HWCI_KERNEL_MODULES: i915
    RUNNER_TAG: mesa-ci-x86-64-lava-dell-latitude-5400-8665U-sarien

# Status: https://lava.collabora.dev/scheduler/device_type/asus-C436FA-Flip-hatch
.lava-asus-C436FA-Flip-hatch:x86_64:
  variables:
    DEVICE_TYPE: asus-C436FA-Flip-hatch
    FARM: collabora
    FDO_CI_CONCURRENT: 9
    GPU_VERSION: iris-cml
    HWCI_KERNEL_MODULES: i915
    RUNNER_TAG: mesa-ci-x86-64-lava-asus-C436FA-flip-hatch


.intel-common-test:
  extends:
    - .lava-test-deqp:x86_64
  variables:
    DTB: ""
    BOOT_METHOD: depthcharge
    KERNEL_IMAGE_TYPE: ""
    FLAKES_CHANNEL: "#intel-ci"
    HWCI_FREQ_MAX: "true"

.anv-test:
  extends:
    - .intel-common-test
    - .anv-rules
  variables:
    DRIVER_NAME: anv

.iris-test:
  extends:
    - .intel-common-test
    - .iris-rules
  variables:
    DRIVER_NAME: iris

.intel-test:
  extends:
    - .intel-common-test
    - .intel-rules

## ANV only
.anv-angle-test:
  extends:
    - .anv-test
  variables:
    VK_DRIVER: intel
    USE_ANGLE: 1
    # ANGLE requires X11 running for some reason.
    HWCI_START_XORG: 1

## Iris only
.iris-apl-test:
  extends:
    - .iris-test
    - .lava-asus-C523NA-A20057-coral:x86_64

.iris-glk-test:
  extends:
    - .iris-test
    - .lava-hp-x360-12b-ca0010nr-n4020-octopus:x86_64

.iris-amly-test:
  extends:
    - .iris-test
    - .iris-manual-rules  # GPU being occasionally stuck
    - .lava-asus-C433TA-AJ0005-rammus:x86_64

.iris-kbl-test:
  extends:
    - .iris-test
    - .lava-hp-x360-14-G1-sona:x86_64

.iris-whl-test:
  extends:
    - .iris-test
    - .lava-dell-latitude-5400-8665U-sarien:x86_64

.iris-cml-test:
  extends:
    - .iris-test
    - .iris-manual-rules    # Devices have too often network problems and fail to boot.
    - .lava-asus-C436FA-Flip-hatch:x86_64

.iris-whl-deqp:
  extends:
    - .iris-whl-test
  variables:
    DEQP_SUITE: iris-whl
  parallel: 4

.iris-traces:
  extends:
    - .lava-traces-base
  variables:
    EGL_PLATFORM: surfaceless
    PIGLIT_REPLAY_DEVICE_NAME: "gl-${GPU_VERSION}"
    PIGLIT_RESULTS: "${GPU_VERSION}-${PIGLIT_PROFILES}"
    PIGLIT_TRACES_FILE: traces-iris.yml

.iris-whl-traces:
  variables:
    GPU_VERSION: intel-whl
  extends:
    - .iris-whl-test
    - .iris-traces

.profile-traces:
  extends:
    - .iris-traces
    - .iris-rules-performance
  variables:
    PIGLIT_REPLAY_SUBCOMMAND: "profile"
    PIGLIT_REPLAY_EXTRA_ARGS: "--db-path ${CI_PROJECT_DIR}/replayer-db/"
    # More than this can hit OOM due to BOs leaked during the replay of the last frame
    PIGLIT_REPLAY_LOOP_TIMES: 150
    # We don't want for more than one workload to be submitted to the GPU at a time
    FDO_CI_CONCURRENT: 1
    # Piglit is very sparse in its status output and downloads of big traces can take a while
    DEVICE_HANGING_TIMEOUT_SEC: 600
    # So we aren't capped by VSync by the X server
    EGL_PLATFORM: surfaceless
    GIT_STRATEGY: none
    HWCI_FREQ_MAX: "true"
    LAVA_TAGS: "cbg-0"
    # Ensure that we are using the release build artifact
    S3_ARTIFACT_NAME: mesa-x86_64-default-release

.iris-whl-traces-performance:
  extends:
    - .iris-whl-test
    - .profile-traces
  variables:
    GPU_VERSION: intel-whl

.iris-cml-traces-performance:
  extends:
    - .iris-cml-test
    - .profile-traces
  variables:
    GPU_VERSION: intel-cml

## Intel (anv + iris)
.intel-adl-test:
  extends:
    - .anv-test
    - .intel-test
  variables:
    GPU_VERSION: intel-adl

.intel-tgl-test:
  extends:
    - .anv-test
    - .intel-test
  variables:
    GPU_VERSION: intel-tgl

.intel-whl-test:
  extends:
    - .iris-whl-test
    - .intel-test
  variables:
    GPU_VERSION: intel-whl

.intel-whl-skqp:
  extends:
    - .intel-whl-test
  variables:
    DEQP_SUITE: intel-whl-skqp
    VK_DRIVER: intel
    HWCI_START_XORG: 1
