# Read https://hub.zhox.com/posts/introducing-haskell-dev/

# We whitelist branches, as we don't really need to build dev-branches.
# Remember to add release branches, both here and to .travis.yml.
branches:
  only:
    - master
    - "3.0"
    - "2.4"
    - "2.2"
    - "2.0"
    - "1.24"
    - "1.22"
    - "1.20"
    - "1.18"


# Do not build feature branch with open Pull Requests
# prevents PR double builds as branch
skip_branch_with_pr: true

install:
  # Using '-y' and 'refreshenv' as a workaround to:
  # https://github.com/haskell/cabal/issues/3687
  - choco source add -n mistuke -s https://www.myget.org/F/mistuke/api/v2
  - choco install -y cabal --version 2.4.1.0
  - choco install -y ghc --version 8.6.5
  - refreshenv

before_build:
  - cabal --version
  - ghc --version
  - cabal %CABOPTS% v2-update
  - cabal %CABOPTS% v1-install happy alex

environment:
  global:
    CABOPTS: --store-dir=C:\\SR --http-transport=plain-http
    # Remove cache, there is no button on the web
    # https://www.appveyor.com/docs/build-cache/#skipping-cache-operations-for-specific-build
    APPVEYOR_CACHE_SKIP_RESTORE: true

clone_folder: "c:\\WORK"

cache:
  - dist-newstyle
  - "C:\\sr"

build_script:
  - cp cabal-install/cabal-install.cabal.dev cabal-install/cabal-install.cabal
  - cabal %CABOPTS% v2-configure --enable-tests
  - appveyor-retry cabal %CABOPTS% v2-build lib:Cabal --only-dependencies
  - cabal %CABOPTS% v2-build lib:Cabal
  - appveyor-retry cabal %CABOPTS% v2-build Cabal:tests --only-dependencies
  - cabal %CABOPTS% v2-test Cabal
  - appveyor-retry cabal %CABOPTS% v2-build exe:cabal exe:cabal-tests --only-dependencies
  - cabal %CABOPTS% v2-build exe:cabal
  - cabal %CABOPTS% v2-run cabal-tests -- -j3 --with-cabal=dist-newstyle\build\x86_64-windows\ghc-8.6.5\cabal-install-3.4.0.0\x\cabal\build\cabal\cabal.exe
  - appveyor-retry cabal %CABOPTS% v2-build cabal-install:tests --only-dependencies
  - cd cabal-install
  - cabal %CABOPTS% v2-run cabal-install:memory-usage-tests
  - cabal %CABOPTS% v2-run cabal-install:solver-quickcheck
  - cabal %CABOPTS% v2-run cabal-install:integration-tests2
  - cabal %CABOPTS% v2-run cabal-install:unit-tests -- --pattern "! (/FileMonitor/ || /VCS/ || /Get/)"
