# Version format
version: "{build}"

image: Visual Studio 2015

# Environment variables
environment:
  GOPATH: c:\gopath
  GO111MODULE: on
  GVM_GO_VERSION: 1.12.4
  GVM_DL: https://github.com/andrewkroh/gvm/releases/download/v0.2.0/gvm-windows-amd64.exe

# Custom clone folder (variables are not expanded here).
clone_folder: c:\gopath\src\github.com\elastic\go-windows

# Cache mingw install until appveyor.yml is modified.
cache:
- C:\ProgramData\chocolatey\bin -> .appveyor.yml
- C:\ProgramData\chocolatey\lib -> .appveyor.yml
- C:\Users\appveyor\.gvm -> .appveyor.yml
- C:\Windows\System32\gvm.exe -> .appveyor.yml

# Scripts that run after cloning repository
install:
  - ps: >-
      if(!(Test-Path "C:\Windows\System32\gvm.exe")) {
        wget "$env:GVM_DL" -Outfile C:\Windows\System32\gvm.exe
      }
  - ps: gvm --format=powershell "$env:GVM_GO_VERSION" | Invoke-Expression
  # AppVeyor has MinGW64. Make sure it's on the PATH.
  - set PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1;%GOROOT%\bin;%PATH%
  - set PATH=%GOPATH%\bin;%PATH%
  - go version
  - go env
  - cmd /C "set ""GO111MODULE=off"" && go get github.com/elastic/go-licenser"
  - python --version

before_build:
- go mod verify
- go-licenser -d
- go run .ci/scripts/check_format.go
- go run .ci/scripts/check_lint.go

build_script:
  # Compile
  - appveyor AddCompilationMessage "Starting Compile"
  - cd c:\gopath\src\github.com\elastic\go-windows
  - go build
  - appveyor AddCompilationMessage "Compile Success"

test_script:
  # Unit tests
  - ps: Add-AppveyorTest "Unit Tests" -Outcome Running
  - go test -v ./...
  - ps: Update-AppveyorTest "Unit Tests" -Outcome Passed

# To disable deployment
deploy: off

# Notifications should only be setup using the AppVeyor UI so that
# forks can be created without inheriting the settings.
