.lava-test:
  extends:
    - .ci-run-policy
  # Cancel job if a newer commit is pushed to the same branch
  interruptible: true
  variables:
    GIT_STRATEGY: none # testing doesn't build anything from source
    FDO_CI_CONCURRENT: 6 # should be replaced by per-machine definitions
    DEQP_VER: gles2
    # proxy used to cache data locally
    FDO_HTTP_CACHE_URI: "http://caching-proxy/cache/?uri="
    # base system generated by the container build job, shared between many pipelines
    BASE_SYSTEM_HOST_PREFIX: "${MINIO_HOST}/mesa-lava"
    BASE_SYSTEM_MAINLINE_HOST_PATH: "${BASE_SYSTEM_HOST_PREFIX}/${FDO_UPSTREAM_REPO}/${DISTRIBUTION_TAG}/${ARCH}"
    BASE_SYSTEM_FORK_HOST_PATH: "${BASE_SYSTEM_HOST_PREFIX}/${CI_PROJECT_PATH}/${DISTRIBUTION_TAG}/${ARCH}"
    # per-job build artifacts
    MESA_BUILD_PATH: "${PIPELINE_ARTIFACTS_BASE}/mesa-${ARCH}.tar.gz"
    JOB_ROOTFS_OVERLAY_PATH: "${JOB_ARTIFACTS_BASE}/job-rootfs-overlay.tar.gz"
    JOB_RESULTS_PATH: "${JOB_ARTIFACTS_BASE}/results.tar.gz"
    PIGLIT_NO_WINDOW: 1
    VISIBILITY_GROUP: "Collabora+fdo"
  script:
    - ./artifacts/lava/lava-submit.sh
  artifacts:
    name: "mesa_${CI_JOB_NAME}"
    when: always
    paths:
      - results/
    exclude:
      - results/*.shader_cache
  after_script:
    - wget -q "https://${JOB_RESULTS_PATH}" -O- | tar -xz

.lava-test:armhf:
  variables:
    ARCH: armhf
    KERNEL_IMAGE_NAME: zImage
    KERNEL_IMAGE_TYPE: "zimage"
    BOOT_METHOD: u-boot
    HWCI_TEST_SCRIPT: "/install/deqp-runner.sh"
  extends:
    - .use-debian/arm_build # for same $MESA_ARTIFACTS_TAG as in kernel+rootfs_armhf
    - .use-debian/x86_build
    - .lava-test
    - .use-kernel+rootfs-arm
  needs:
    - kernel+rootfs_armhf
    - debian/x86_build
    - debian-armhf

.lava-test:arm64:
  variables:
    ARCH: arm64
    KERNEL_IMAGE_NAME: Image
    KERNEL_IMAGE_TYPE: "image"
    BOOT_METHOD: u-boot
    HWCI_TEST_SCRIPT: "/install/deqp-runner.sh"
  extends:
    - .use-debian/arm_build # for same $MESA_ARTIFACTS_TAG as in kernel+rootfs_arm64
    - .use-debian/x86_build
    - .lava-test
    - .use-kernel+rootfs-arm
  dependencies:
    - debian-arm64
  needs:
    - kernel+rootfs_arm64
    - debian/x86_build
    - debian-arm64

.lava-test:amd64:
  variables:
    ARCH: amd64
    KERNEL_IMAGE_NAME: bzImage
    KERNEL_IMAGE_TYPE: "zimage"
    BOOT_METHOD: u-boot
    HWCI_TEST_SCRIPT: "/install/deqp-runner.sh"
  extends:
    - .use-debian/x86_build-base # for same $MESA_ARTIFACTS_BASE_TAG as in kernel+rootfs_amd64
    - .use-debian/x86_build
    - .lava-test
    - .use-kernel+rootfs-amd64
  needs:
    - kernel+rootfs_amd64
    - debian-testing

.lava-traces-base:
  variables:
    HWCI_TEST_SCRIPT: "/install/piglit/run.sh"
  artifacts:
    reports:
      junit: results/junit.xml

.lava-piglit:
  variables:
    PIGLIT_REPLAY_DEVICE_NAME: "gl-${GPU_VERSION}"
    PIGLIT_RESULTS: "${GPU_VERSION}-${PIGLIT_PROFILES}"
    HWCI_TEST_SCRIPT: "/install/piglit/piglit-runner.sh"

.lava-piglit-traces:amd64:
  extends:
    - .lava-test:amd64
    - .lava-piglit
    - .lava-traces-base

.lava-piglit-traces:armhf:
  extends:
    - .lava-test:armhf
    - .lava-piglit
    - .lava-traces-base

.lava-piglit-traces:arm64:
  extends:
    - .lava-test:arm64
    - .lava-piglit
    - .lava-traces-base

.lava-piglit:amd64:
  extends:
    - .lava-test:amd64
    - .lava-piglit
