#version: '3.0.1.{build}'
#
# When planning updates here, check availability at:
# https://www.appveyor.com/docs/windows-images-software/
# This is slow, try to keep the number of builds as low as makes sense.

image:
  # linux builds done in Travis CI for now
  - Visual Studio 2017
  - Visual Studio 2019
  - Visual Studio 2022

cache:
  - downloads -> appveyor.yml
  - '%LOCALAPPDATA%\pip\Cache'
  - C:\ProgramData\chocolatey\bin -> appveyor.yml
  - C:\ProgramData\chocolatey\lib -> appveyor.yml

install:
  # add python and python user-base to path for pip installs
  - cmd: .\.appveyor\install.bat

# build matrix will be number of images multiplied by each '-' below,
# less any exclusions.
# split builds into sets of four jobs due to appveyor per-job time limit
environment:
  matrix:

    - WINPYTHON: "Python310"
      COVERAGE: 0

    - WINPYTHON: "Python37"
      COVERAGE: 0

    - WINPYTHON: "Python38"
      COVERAGE: 0
          
    - WINPYTHON: "Python36"
      COVERAGE: 1





# remove sets of build jobs based on criteria below
# to fine tune the number and platforms tested
matrix:
  exclude:
    # test python 3.8 on Visual Studio 2017 image
    - image: Visual Studio 2017
      WINPYTHON: "Python310"
    - image: Visual Studio 2017
      WINPYTHON: "Python37"
    - image: Visual Studio 2017
      WINPYTHON: "Python38"

    # test python 3.7 on Visual Studio 2019 image
    - image: Visual Studio 2019
      WINPYTHON: "Python310"
    - image: Visual Studio 2019
      WINPYTHON: "Python36"

    # test python 3.10 on Visual Studio 2022 image
    - image: Visual Studio 2022
      WINPYTHON: "Python36"
    - image: Visual Studio 2022
      WINPYTHON: "Python37"
    - image: Visual Studio 2022
      WINPYTHON: "Python38"

# remove some binaries we don't want to be found
before_build:
    - ps: .\.appveyor\ignore_git_bins.ps1

build: off

build_script:

  # exclude VS 10.0 because it hangs the testing until this is resolved:
  # https://help.appveyor.com/discussions/problems/19283-visual-studio-2010-trial-license-has-expired
  - ps: .\.appveyor\disable_msvc_10.ps1

  # setup coverage by creating the coverage config file, and adding coverage
  # to the sitecustomize so that all python processes start with coverage
  - ps: .\.appveyor\coverage_setup.ps1

  # NOTE: running powershell from cmd is intended because
  # it formats the output correctly
  - cmd: powershell -Command "& { if($env:COVERAGE -eq 1) { coverage run -p --rcfile=$($env:COVERAGE_PROCESS_START) runtest.py -j 2 -t --exclude-list exclude_list.txt -a } else { C:\\%WINPYTHON%\\python.exe runtest.py -j 2 -t --exclude-list exclude_list.txt -a }; if($LastExitCode -eq 2 -Or $LastExitCode -eq 0) { $host.SetShouldExit(0 )} else {$host.SetShouldExit(1)}}"

# run coverage even if there was a test failure
on_finish:
  - ps: .\.appveyor\coverage_report.ps1
  # running codecov in powershell causes an error so running in platform
  # shells
  - cmd: if %COVERAGE% equ 1 codecov -X gcov --file coverage_xml.xml

