version: 1.0.{build}
clone_folder: c:\gopath\src\github.com\%APPVEYOR_REPO_NAME%
init:
  - go version
  - go env
  - pwsh: Invoke-RestMethod -Method Get -Uri "https://releases.hashicorp.com/terraform/$($env:TERRAFORMVERSION)/terraform_$($env:TERRAFORMVERSION)_windows_amd64.zip" -OutFile "c:/terraform_windows_amd64.zip"
  - pwsh: Expand-Archive -Path "c:/terraform_windows_amd64.zip" -Destination "C:/Tools/terraform"
  - mkdir "C:/Tools/logparser"
  - pwsh: Invoke-WebRequest -Method Get -Uri "https://github.com/gruntwork-io/terratest/releases/download/$($env:LOGPARSERVERSION)/terratest_log_parser_windows_amd64.exe" -OutFile "C:/Tools/logparser/terratest_log_parser.exe"
  - set PATH=%PATH%;C:\Tools\terraform\;C:\Tools\logparser\
install:
  - choco install dep
environment:
  GOPATH: c:\gopath
  GOTESTTIMEOUT: 45m
  LOGPARSERVERSION: v0.13.8
  TERRAGRUNT_DOWNLOAD: C:\.terragrunt-cache
  matrix:
  - TERRAFORMVERSION: 0.11.13
build_script:
  - dep ensure
test_script:
  - mkdir logs
  - pwsh: go test -v -parallel 1 $(go list ./... | where-object { $_ -notlike "*/test" }) | Tee-Object -FilePath 'logs/unit.log'
  - terratest_log_parser.exe --testlog logs/unit.log --outputdir ./logs/unit/
  - pwsh: go test -v $(go list ./... | where-object { $_ -like "*/test" }) | Tee-Object -FilePath 'logs/integration.log'
  - terratest_log_parser.exe --testlog logs/integration.log --outputdir ./logs/integration/
artifacts:
  - path: logs
    name: test_logs
deploy: off
on_finish:
  - ps: $wc = New-Object 'System.Net.WebClient'
  - ps: $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path ./logs/unit/report.xml))
  - ps: $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path ./logs/integration/report.xml))