.windows_build:
  variables:
    # Note that shell runners only support runners with a single
    # concurrency level. We can't use `$CI_CONCURRENCY_ID` because this may
    # change between the build and test stages which CMake doesn't support.
    # Even if we could, it could change if other runners on the machine
    # could run at the same time, so we drop it.
    GIT_CLONE_PATH: "$CI_BUILDS_DIR\\vtkm ci"
  artifacts:
    reports:
      junit:
        - build/junit.xml


.windows_vs2019:
  variables:
    VCVARSALL: "${VS160COMNTOOLS}\\..\\..\\VC\\Auxiliary\\Build\\vcvarsall.bat"
    VCVARSPLATFORM: "x64"
    VCVARSVERSION: "14.25"

.cmake_build_windows: &cmake_build_windows
  extends:
    - .windows_build
    - .windows_vs2019
  stage: build
  timeout:  2 hours
  interruptible: true
  before_script:
    - Invoke-Expression -Command .gitlab/ci/config/cmake.ps1
    - Invoke-Expression -Command .gitlab/ci/config/vcvarsall.ps1
    - $pwdpath = $pwd.Path
    - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab;$pwdpath\.gitlab\cmake\bin;$env:PATH"
    - "cmake --version"
    - "cmake -V -P .gitlab/ci/config/gitlab_ci_setup.cmake"
    - "ctest -VV -S .gitlab/ci/ctest_configure.cmake"
  script:
    - "ctest -VV -S .gitlab/ci/ctest_build.cmake"
  artifacts:
    expire_in: 24 hours
    when: always
    paths:
      # The artifacts of the build.
      - build/bin/
      - build/include/
      - build/lib/
      - build/vtkm/thirdparty/diy/vtkmdiy/include
      - build/config/

      # CTest and CMake install files.
      # XXX(globbing): Can be simplified with support from
      # https://gitlab.com/gitlab-org/gitlab-runner/issues/4840
      #
      # Note: this also captures our CIState.cmake file
      - build/CMakeCache.txt
      - build/*.cmake
      - build/*/*.cmake
      - build/*/*/*.cmake
      - build/*/*/*/*.cmake
      - build/*/*/*/*/*.cmake
      - build/*/*/*/*/*/*.cmake
      - build/Testing/

      # CDash files.
      - build/DartConfiguration.tcl


.cmake_test_windows: &cmake_test_windows
  extends:
    - .windows_build
    - .windows_vs2019
  stage: test
  timeout:  50 minutes
  interruptible: true
  before_script:
    - Invoke-Expression -Command .gitlab/ci/config/cmake.ps1
    - Invoke-Expression -Command .gitlab/ci/config/vcvarsall.ps1
    - $pwdpath = $pwd.Path
    - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab;$pwdpath\.gitlab\cmake\bin;$env:PATH"
  script:
    - "ctest -VV -S .gitlab/ci/ctest_test.cmake"

# Build on windows10 with Visual Studio
# Will have CUDA 10.2 once build issues are resolved
build:windows_vs2019:
  tags:
    - vtkm # Since this is a bare runner, pin to a project.
    - nonconcurrent
    - build
    - windows
    - shell
    - vs2019
    - msvc-19.25
    - large-memory
  extends:
    - .cmake_build_windows
    - .run_automatically
  variables:
    CMAKE_GENERATOR: "Ninja"
    CMAKE_BUILD_TYPE: Release
    # Disabled while we track down cub allocator issues with vtkm/io tests
    # VTKM_SETTINGS: "cuda+turing"
    VTKM_SETTINGS: "serial"

test:windows_vs2019:
  tags:
    - vtkm # Since this is a bare runner, pin to a project.
    - nonconcurrent
    - test
    - windows
    - shell
    - vs2019
    - msvc-19.25
    - cuda-rt
    - turing
  extends:
    - .cmake_test_windows
    - .run_automatically
  dependencies:
    - build:windows_vs2019
  needs:
    - build:windows_vs2019
