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

name: CI Windows

on:
  push:
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions: read-all

jobs:

### BUILD JOBS ###

  build-windows-msvc15:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    secrets: inherit
    with:
      cmd: |
        scripts\build\win.ps1 -G "Visual Studio 15 2017 Win64"
      artifact-out: build-windows-msvc15
      artifact-path: build/install/ospray build/CMakeCache.txt build/ospray/build/CMakeCache.txt

  build-windows-msvc16-mpi_and_md:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    secrets: inherit
    with:
      runs-on: '["build", "mpi"]'
      cmd: |
        scripts\build\win.ps1 -G "Visual Studio 16 2019" -DBUILD_OSPRAY_MODULE_MPI=ON -DBUILD_OSPRAY_MODULE_MULTIDEVICE=ON
      artifact-out: build-windows-msvc16-mpi_and_md
      artifact-path: build/install/ospray build/CMakeCache.txt build/ospray/build/CMakeCache.txt

  build-windows-msvc17:
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    secrets: inherit
    with:
      cmd: |
        scripts\build\win.ps1 -G "Visual Studio 17 2022"
      artifact-out: build-windows-msvc17
      artifact-path: build/install/ospray build/CMakeCache.txt build/ospray/build/CMakeCache.txt

### TEST JOBS ###

  test-windows-msvc15-avx2:
    needs: build-windows-msvc15
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    with:
      runs-on: '"avx2"'
      cmd: |
        $env:Path += ";$env:GITHUB_WORKSPACE\build\install\ospray\bin"
        scripts\tests\run_tests.ps1 "$env:GITHUB_WORKSPACE" AVX2
      artifact-in: build-windows-msvc15
      artifact-out: test-windows-msvc15-avx2
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true

  test-windows-msvc15-avx512skx:
    needs: build-windows-msvc15
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    with:
      runs-on: '"avx512"'
      cmd: |
        $env:Path += ";$env:GITHUB_WORKSPACE\build\install\ospray\bin"
        scripts\tests\run_tests.ps1 "$env:GITHUB_WORKSPACE" AVX512SKX
      artifact-in: build-windows-msvc15
      artifact-out: test-windows-msvc15-avx512
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true

  test-windows-msvc16-avx2:
    needs: build-windows-msvc16-mpi_and_md
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    with:
      runs-on: '["avx2", "mpi"]'
      cmd: |
        $env:Path += ";$env:GITHUB_WORKSPACE\build\install\ospray\bin"
        scripts\tests\run_tests.ps1 "$env:GITHUB_WORKSPACE" AVX2 TEST_MULTIDEVICE TEST_MPI
      artifact-in: build-windows-msvc16-mpi_and_md
      artifact-out: test-windows-msvc16-mpi_and_md-avx2
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true

  test-windows-msvc16-avx512skx:
    needs: build-windows-msvc16-mpi_and_md
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    with:
      runs-on: '["avx512", "mpi"]'
      cmd: |
        $env:Path += ";$env:GITHUB_WORKSPACE\build\install\ospray\bin"
        echo $env:Path
        scripts\tests\run_tests.ps1 "$env:GITHUB_WORKSPACE" AVX512SKX TEST_MULTIDEVICE TEST_MPI
      artifact-in: build-windows-msvc16-mpi_and_md
      artifact-out: test-windows-msvc16-mpi_and_md-avx512skx
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true

  test-windows-msvc17:
    needs: build-windows-msvc17
    uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main
    with:
      runs-on: '"avx512"'
      cmd: |
        $env:Path += ";$env:GITHUB_WORKSPACE\build\install\ospray\bin"
        scripts\tests\run_tests.ps1 "$env:GITHUB_WORKSPACE" AVX512SKX
      artifact-in: build-windows-msvc17
      artifact-out: test-windows-msvc17-avx512
      artifact-path: build_regression_tests/tests*.xml build_regression_tests/failed*
      artifact-on-failure: true
