version: pending.{build}
max_jobs: 10
skip_branch_with_pr: false
skip_commits:
  files:
    - docs/*
    - '**/*.html'
  message: /.*\[nobuild\].*/

environment:
  GIT_DAEMON_PATH:   "C:\\Program Files\\Git\\mingw64\\libexec\\git-core"
  CYGWIN_GIT_PATH:   "C:\\cygwin\\bin;%GIT_DAEMON_PATH%"
  CYGWIN64_GIT_PATH: "C:\\cygwin64\\bin;%GIT_DAEMON_PATH%"
  APPVEYOR_ARTIFACT_UPLOAD_TIMEOUT: 60
  PYTHON: "C:\\Python36-x64"
  PYTHON_VERSION: "3.6"
  PYTHON_ARCH: "64"
  GIT_PATH: "%GIT_DAEMON_PATH%"
  GH_TOKEN:
    secure: H9M/aPctMSk1+0AWe/l5D0U3oXto404/4UYiPMCECpjy0llgb8cBKTRyr20UDWdX
  GH_MAIL:
    secure: hyFFOoK6WbxtLxy2jOGlOPbRJ33Al8E1B0QeT+qUqJ8=
  PYPI_PWD:
    secure: sVfnGb1FQyKRJg6kD9c6aQ==


matrix:
  fast_finish: true

init:
  # If there is a newer build queued for the same PR, cancel this one.
  # The AppVeyor 'rollout builds' option is supposed to serve the same
  # purpose but is problematic because it tends to cancel builds pushed
  # directly to master instead of just PR builds.
  # credits: JuliaLang developers.
  - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
        https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
        Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
        throw "There are newer queued builds for this pull request, failing early." }

  # Check that we have the expected version and architecture for Python
  - set PATH=%PYTHON%;%PYTHON%\Scripts;C:\MinGW\msys\1.0\bin;%PATH%
  - "git config --system http.sslcainfo \"C:\\Program Files\\Git\\mingw64\\ssl\\certs\\ca-bundle.crt\""
  - "%PYTHON%/python -V"
  - "%PYTHON%/python -c \"import struct;print(8 * struct.calcsize(\'P\'))\""
  - "pip --version"

  - cmd: echo %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%
  - cmd: echo %APPVEYOR_BUILD_WORKER_IMAGE%
  - cmd: appveyor UpdateBuild -Version "%APPVEYOR_REPO_BRANCH%.%APPVEYOR_REPO_COMMIT%.%APPVEYOR_BUILD_NUMBER%"
  - git config --global credential.helper store
  - ps: Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:GH_TOKEN):x-oauth-basic@github.com`n"
  - "git config --global user.email %GH_MAIL%"
  - "git config --global user.name %APPVEYOR_ACCOUNT_NAME%"
  - cmd: echo %APPVEYOR_REPO_COMMIT_TIMESTAMP%
  - cmd: echo %APPVEYOR_REPO_COMMIT_MESSAGE%
  - cmd: echo %APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED%

cache:
  - C:\Users\appveyor\AppData\Local\pip\cache -> requirements.txt
  - C:\ProgramData\chocolatey\bin -> appveyor.yml
  - C:\ProgramData\chocolatey\lib -> appveyor.yml

install:
  - "%PYTHON%\\python.exe -m pip install --disable-pip-version-check --user --upgrade pip setuptools"
  - "%PYTHON%\\python.exe -m pip install -r requirements-dev.txt"
  - "%PYTHON%\\python.exe -m pip install wheel twine"
  - "%PYTHON%\\python.exe -m pip install -e ."

build: off

test_script:
  - "epab pytest"

  # Install wheel-building support
  - "%PYTHON%\\python.exe setup.py bdist_wheel"

on_success:

  # Deploy a wheel (only actually do this for tags). NB That breaking this line
  # with Unix line-endings causes the windows command interpreter to barf so
  # this is given as one-line to make this script less fragile when edited on
  # other OSes.
  # - ps: If ($env:APPVEYOR_REPO_TAG -eq "true") { Invoke-Expression "twine upload -u 132nd-etcher -p $env:PYPI_PWD --skip-existing dist/*" } Else { write-output "Not on a tag, won't deploy to pypi"}

artifacts:
  - path: dist\*

#build_script:
#  - cmd: pip install -e .
#  - cmd: emiz-build flake8 pytest safety chglog doc --publish reqs pyrcc freeze patch test_build
