## Copyright 2022 Intel Corporation
## SPDX-License-Identifier: Apache-2.0

name: continuous

permissions: read-all

on: [push, workflow_dispatch]

jobs:

  ze_raytracing-ubuntu22_04-GCC:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: embree/ubuntu:22.04
      runs-on: '[ "Linux", "docker", "build" ]'
      cmd: |
        mkdir build
        cd build
        cmake -G Ninja -D CMAKE_CXX_COMPILER=g++ -D CMAKE_C_COMPILER=gcc -D CMAKE_BUILD_TYPE=Release ..
        cmake --build . --target package

  ze_raytracing-linux-DPCPP-test:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: embree/ubuntu:22.04
      runs-on: '[ "Linux", "docker", "build" ]'
      env-from-files: ./.github/workflows/dpcpp-sycl-nightly.env
      artifact-out: ze_raytracing-linux-DPCPP-test
      artifact-path: ./build/intel-level-zero-gpu-raytracing*.tar.gz
      cmd: |
        mkdir build
        cd build
        cmake -G Ninja -D CMAKE_BUILD_TYPE=ReleaseInternal -D CMAKE_CXX_COMPILER=clang++ -D CMAKE_C_COMPILER=clang -D ZE_RAYTRACING_TBB=build_static -D ZE_RAYTRACING_SYCL_TESTS=INTERNAL_RTAS_BUILDER ..
        cmake --build . --target package

  ze_raytracing-linux-DPCPP-test-DG2:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    needs: ["ze_raytracing-linux-DPCPP-test"]
    with:
      image: embree/ubuntu:22.04
      options: --device=/dev/dri:/dev/dri
      runs-on: '[ "Linux", "docker", "dg2" ]'
      env-from-files: ./.github/workflows/gfx-ubuntu22-internal.env
      artifact-in: ze_raytracing-linux-DPCPP-test
      cmd: |
        cd build
        tar xzf intel-level-zero-gpu-raytracing*.x86_64.linux.tar.gz
        cd intel-level-zero-gpu-raytracing*.x86_64.linux
        ./run.sh
        ./run_ext.sh
        cd bin
        ctest -VV

  ze_raytracing-linux-DPCPP-test-PVC:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    needs: ["ze_raytracing-linux-DPCPP-test"]
    with:
      image: embree/ubuntu:22.04
      options: --device=/dev/dri:/dev/dri
      runs-on: '[ "Linux", "docker", "pvc" ]'
      env-from-files: ./.github/workflows/gfx-ubuntu22-internal.env
      artifact-in: ze_raytracing-linux-DPCPP-test
      cmd: |
        cd build
        tar xzf intel-level-zero-gpu-raytracing*.x86_64.linux.tar.gz
        cd intel-level-zero-gpu-raytracing*.x86_64.linux
        ./run.sh
        ./run_ext.sh
        cd bin
        ctest -VV

  ze_raytracing-linux-ICX-test:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: embree/ubuntu:22.04
      runs-on: '[ "Linux", "docker", "build" ]'
      dpcpp-version: intel/2025.2.1.7
      artifact-out: ze_raytracing-linux-ICX-test
      artifact-path: ./build/intel-level-zero-gpu-raytracing*.tar.gz
      cmd: |
        mkdir build
        cd build
        cmake -G Ninja -D CMAKE_BUILD_TYPE=ReleaseInternal -D CMAKE_CXX_COMPILER=icpx -D CMAKE_C_COMPILER=icx -D ZE_RAYTRACING_TBB=inject_headers -D ZE_RAYTRACING_SYCL_TESTS=INTERNAL_RTAS_BUILDER ..
        cmake --build . --target package

  ze_raytracing-linux-ICX-test-DG2:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    needs: ["ze_raytracing-linux-ICX-test"]
    with:
      image: embree/ubuntu:22.04
      options: --device=/dev/dri:/dev/dri
      runs-on: '[ "Linux", "docker", "dg2" ]'
      env-from-files: ./.github/workflows/gfx-ubuntu22-internal.env
      artifact-in: ze_raytracing-linux-ICX-test
      cmd: |
        cd build
        tar xzf intel-level-zero-gpu-raytracing*.x86_64.linux.tar.gz
        cd intel-level-zero-gpu-raytracing*.x86_64.linux
        ./run.sh
        ./run_ext.sh
        cd bin
        LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:. ctest -VV

  ze_raytracing-linux-ICX-test-level-zero:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    with:
      image: embree/ubuntu:22.04
      runs-on: '[ "Linux", "docker", "build" ]'
      dpcpp-version: intel/2025.2.1.7
      artifact-out: ze_raytracing-linux-ICX-test-level-zero
      artifact-path: ./build/intel-level-zero-gpu-raytracing*.tar.gz
      cmd: |
        mkdir build
        cd build
        cmake -G Ninja -D CMAKE_BUILD_TYPE=ReleaseInternal -D CMAKE_CXX_COMPILER=icpx -D CMAKE_C_COMPILER=icx -D ZE_RAYTRACING_TBB=normal -D ZE_RAYTRACING_SYCL_TESTS=LEVEL_ZERO_RTAS_BUILDER ..
        cmake --build . --target package

  ze_raytracing-linux-ICX-test-level-zero-DG2:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main
    needs: ["ze_raytracing-linux-ICX-test-level-zero"]
    with:
      image: embree/ubuntu:22.04
      options: --device=/dev/dri:/dev/dri
      runs-on: '[ "Linux", "docker", "dg2" ]'
      env-from-files: ./.github/workflows/gfx-ubuntu22-internal.env
      artifact-in: ze_raytracing-linux-ICX-test-level-zero
      cmd: |
        cd build
        tar xzf intel-level-zero-gpu-raytracing*.x86_64.linux.tar.gz
        cd intel-level-zero-gpu-raytracing*.x86_64.linux
        ./run.sh
        ./run_ext.sh
        cd bin
        LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:. ctest -VV
        
  ze_raytracing-windows-VS2022-Debug:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    with:
      runs-on: '[ "Windows", "build" ]'
      cmd: |
        mkdir build
        cd build
        cmake -G "Visual Studio 17 2022" -A "x64" ..
        cmake --build . --config Debug --target package

  ze_raytracing-windows-VS2022-Release:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    with:
      runs-on: '[ "Windows", "build" ]'
      cmd: |
        mkdir build
        cd build
        cmake -G "Visual Studio 17 2022" -A "x64" ..
        cmake --build . --config Release --target package

  ze_raytracing-windows-VS2022-ReleaseInternal:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    with:
      runs-on: '[ "Windows", "build" ]'
      cmd: |
        mkdir build
        cd build
        cmake -G "Visual Studio 17 2022" -A "x64" ..
        cmake --build . --config ReleaseInternal --target package

  ze_raytracing-windows-test:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    with:
      runs-on: '[ "Windows", "build" ]'
      env-from-files: ./.github/workflows/dpcpp-sycl-nightly.env
      artifact-path: ./build/intel-level-zero-gpu-raytracing*.zip
      artifact-out: ze_raytracing-windows-test
      cmd: |
        mkdir build
        cd build
        cmake -G Ninja -D CMAKE_BUILD_TYPE=ReleaseInternal -D CMAKE_CXX_COMPILER=clang++ -D CMAKE_C_COMPILER=clang -D ZE_RAYTRACING_SYCL_TESTS=INTERNAL_RTAS_BUILDER ..
        cmake --build . --target package

  ze_raytracing-windows-test-DG2:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    needs: ["ze_raytracing-windows-test"]
    with:
      runs-on: '[ "Windows", "dg2" ]'
      env-from-files: ./.github/workflows/gfx-windows-internal.env
      artifact-in: ze_raytracing-windows-test
      cmd: |
        cd build
        unzip intel-level-zero-gpu-raytracing*.x64.windows.zip
        cd intel-level-zero-gpu-raytracing*.x64.windows
        .\run.bat
        if ($LASTEXITCODE -ne 0) { throw "Command failed" }
        cd bin
        ctest -VV
        if ($LASTEXITCODE -ne 0) { throw "Command failed" }

  ze_raytracing-windows-test-level-zero:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    with:
      runs-on: '[ "Windows", "build" ]'
      env-from-files: ./.github/workflows/dpcpp-sycl-nightly.env
      artifact-path: ./build/intel-level-zero-gpu-raytracing*.zip
      artifact-out: ze_raytracing-windows-test-level-zero
      cmd: |
        mkdir build
        cd build
        cmake -G Ninja -D CMAKE_BUILD_TYPE=ReleaseInternal -D CMAKE_CXX_COMPILER=clang++ -D CMAKE_C_COMPILER=clang -D ZE_RAYTRACING_SYCL_TESTS=LEVEL_ZERO_RTAS_BUILDER ..
        cmake --build . --target package

  ze_raytracing-windows-test-level-zero-DG2:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    needs: ["ze_raytracing-windows-test-level-zero"]
    with:
      runs-on: '[ "Windows", "dg2" ]'
      env-from-files: ./.github/workflows/gfx-windows-internal.env
      artifact-in: ze_raytracing-windows-test-level-zero
      cmd: |
        cd build
        unzip intel-level-zero-gpu-raytracing*.x64.windows.zip
        cd intel-level-zero-gpu-raytracing*.x64.windows
        .\run.bat
        if ($LASTEXITCODE -ne 0) { throw "Command failed" }
        cd bin
        ctest -VV
        if ($LASTEXITCODE -ne 0) { throw "Command failed" }

  static-analysis-coverity-linux:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/static_analysis.yml@main
    with:
      project: "Level Zero Ray Tracing Support"
      server: prod4
      prebuild: |
        cmake -S . -B build -D CMAKE_CXX_COMPILER=g++ -D CMAKE_C_COMPILER=gcc -D CMAKE_BUILD_TYPE=Release -D ZE_RAYTRACING_TBB=build_static
      build: cmake --build build
      os: Linux

  static-analysis-coverity-windows:
    secrets: inherit
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/static_analysis.yml@main
    with:
      project: "Level Zero Ray Tracing Support"
      server: prod4
      prebuild: |
        cmake -S . -B build -D CMAKE_CXX_COMPILER=g++ -D CMAKE_C_COMPILER=gcc -D CMAKE_BUILD_TYPE=Release -D ZE_RAYTRACING_TBB=build_static
      build: cmake --build build
      os: Windows

  success:
    runs-on: ubuntu-latest
    needs:
      - ze_raytracing-ubuntu22_04-GCC
      - ze_raytracing-linux-DPCPP-test
      - ze_raytracing-linux-DPCPP-test-DG2
      - ze_raytracing-linux-DPCPP-test-PVC
      - ze_raytracing-linux-ICX-test
      - ze_raytracing-linux-ICX-test-DG2
      - ze_raytracing-linux-ICX-test-level-zero
      - ze_raytracing-linux-ICX-test-level-zero-DG2
      - ze_raytracing-windows-VS2022-Debug
      - ze_raytracing-windows-VS2022-Release
      - ze_raytracing-windows-VS2022-ReleaseInternal
      - ze_raytracing-windows-test
      - ze_raytracing-windows-test-DG2
      - ze_raytracing-windows-test-level-zero
      - ze_raytracing-windows-test-level-zero-DG2
      - static-analysis-coverity-linux
      - static-analysis-coverity-windows
    if: failure() || cancelled()
    steps:
      - name: Failure
        run: |
          echo "::notice title=Success::Workflow failed"
          exit 1


