jobs:
- job: sitl
  displayName: 'Cygwin SITL build'
  pool:
    vmImage: 'win1803'
  condition: ne(variables['Build.Reason'], 'Schedule')
  steps:
  - script: choco install cygwin --params "/InstallDir:C:\Cygwin /NoStartMenu /NoAdmin"
    displayName: 'Install Cygwin'

  - script: choco install cygwin32-gcc-g++ python2 python27 python27-future python27-lxml git gettext --source cygwin
    displayName: 'Install Cygwin packages'

  - script: C:\Cygwin\bin\bash --login -c "cd $(cygpath '%BUILD_SOURCESDIRECTORY%') &&
                                           mkdir artifacts &&
                                           (./waf --color yes --toolchain i686-pc-cygwin --board sitl configure bin 2>&1) | tee artifacts/build.txt"
    displayName: 'Build SITL'

  - script: C:\Cygwin\bin\bash --login -c "cd $(cygpath '%BUILD_SOURCESDIRECTORY%') &&
                                           cp -v build/sitl/bin/* artifacts/ &&
                                           cp -v $(i686-pc-cygwin-g++ -print-sysroot)/usr/bin/*.dll artifacts/ &&
                                           git log -1 > artifacts/git.txt"
    displayName: 'Copy dependencies to build dir'

  - task: PublishBuildArtifacts@1
#  - task: PublishPipelineArtifact@0
    displayName: 'Publish build artifacts'
    inputs:
      artifactName: 'Cygwin SITL binaries'
      pathtoPublish: 'artifacts'
#      targetPath: 'artifacts'

- template: autotest_template.yml
  parameters:
    name: 'Copter'
    build_target: 'ArduCopter'
    action_target: 'ArduCopter'

- template: autotest_template.yml
  parameters:
    name: 'Plane'
    build_target: 'ArduPlane'
    action_target: 'ArduPlane'

- template: autotest_template.yml
  parameters:
    name: 'Quadplane'
    build_target: 'ArduPlane'
    action_target: 'QuadPlane'

- template: autotest_template.yml
  parameters:
    name: 'Rover'
    build_target: 'APMrover2'
    action: 'drive'
    action_target: 'APMrover2'

- template: autotest_template.yml
  parameters:
    name: 'Sub'
    build_target: 'ArduSub'
    action: 'dive'
    action_target: 'ArduSub'

