clone_folder: "c:\\WORK"
clone_depth: 5

# Do not build feature branch with open Pull Requests
skip_branch_with_pr: true

platform:
  - x86_64
  - x86

environment:
  global:
    CABOPTS:  --http-transport=plain-http
    CHOCOCMD: ghc --version %GHCVER%
  matrix:
    - GHCVER: 9.0.1
    - GHCVER: 8.10.4
    - GHCVER: 8.8.4
    - GHCVER: 8.6.5
    - GHCVER: 8.4.2
    - GHCVER: 8.2.2
    - GHCVER: 8.0.2
    - GHCVER: 7.10.3.2
    - GHCVER: 7.8.4.1
    - GHCVER: 7.6.3.1
    # - GHCVER: head

matrix:
  # set this flag to immediately finish build once one of the jobs fails.
  fast_finish: true
  exclude:
    - platform: x86
      GHCVER: head
    - platform: x86
      GHCVER: 8.8.4
    - platform: x86
      GHCVER: 8.10.4
    - platform: x86
      GHCVER: 9.0.1

for:
  -
    matrix:
      only:
        - platform: x86
    environment:
      global:
        CHOCO_OPTS: --forcex86
  -
    matrix:
      only:
        - GHCVER: head
    environment:
      global:
        GHC_OPTS: --pre
        CHOCOCMD: ghc-head
  -
    matrix:
      only:
        - GHCVER: 9.0.1
    environment:
      global:
        PKG_TEST: yes

install:
 - choco source add -n mistuke -s https://www.myget.org/F/mistuke/api/v2
 - choco install %CHOCOCMD% -y %GHC_OPTS% %CHOCO_OPTS% --ignore-dependencies
 - choco install -y cabal %CHOCO_OPTS%
 - refreshenv

before_build:
 - cabal --version
 - ghc --version
 - cabal %CABOPTS% update
 - IF EXIST configure.ac bash -c "autoreconf -i"
 - rmdir /Q /S dist-newstyle

build_script:
 - echo packages:. > cabal.project
 - cabal %CABOPTS% build -j all --ghc-options="-Werror"
 # Build from sdist if required.
 - ps: >-
    If ($env:PKG_TEST -Match "yes") {
       cabal sdist
       echo "packages: dist-newstyle/sdist/*.tar.gz" | Out-File -Encoding ASCII cabal.project
       cat cabal.project
       cabal $env:CABOPTS build -j pkg:Win32 --ghc-options="-Werror"
    }
