# This file is auto-generated
#
# To regenerate it run
#
#     make github-actions
#
name: Windows
on:
  push:
    branches:
      - master
      - "3.2"
  pull_request:
    branches:
      - master
      - "3.2"
  release:
    types:
      - created

jobs:

{############################################################################}
{# Windows jobs                                                             #}
{############################################################################}
{% for job in winJobs %}
  test-windows-{{ mangleVersion job.version }}:
    name: test ghc-{{job.version}}
    runs-on: windows-latest
{% for needs in job.needs %}
    needs: test-windows-{{ mangleVersion needs }}
{% endfor %}
    steps:
      - name: Install Cabal
        run: choco install -fy cabal --version 3.2.0.0
      - name: Install GHC
        run: |
          choco uninstall -y ghc --all-versions
          choco install -y ghc --version {{ job.version }}
      - name: Set PATH
        run: |
          [Environment]::GetEnvironmentVariable("Path")
          Write-Host "::add-path::C:\ProgramData\Chocolatey\lib\cabal\tools\cabal-3.2.0.0"
          Write-Host "::add-path::C:\ProgramData\Chocolatey\lib\ghc\tools\ghc-{{ job.version }}\bin"
          [Environment]::GetEnvironmentVariable("Path")
      - name: Print versions
        run: |
          [Environment]::GetEnvironmentVariable("Path")
          cabal --version
          ghc --version
          cabal user-config init -a "http-transport: plain-http" -a "store-dir: C:\SR" -f -v3
      - uses: actions/cache@v1
        with:
          path: C:\SR
          key: windows-store-meta
      - name: Update Hackage index
        run: cabal v2-update
      - uses: actions/checkout@v2
      - name: make cabal-install-dev
        run: runghc cabal-dev-scripts/src/Preprocessor.hs -o cabal-install/cabal-install.cabal -f CABAL_FLAG_LIB cabal-install/cabal-install.cabal.pp
      # We cannot ask for all dependencies, but we can for Cabal.
      - name: cabal v2-build Cabal --only-dependencies
        run: cabal v2-build Cabal --only-dependencies
      - name: cabal v2-build
        run: cabal v2-build all
      - name: cabal-install memory-usage-tests
        run: |
          cd cabal-install
          cabal v2-run cabal-install:memory-usage-tests
      - name: cabal-install solver-quickcheck
        run: |
          cd cabal-install
          cabal v2-run cabal-install:solver-quickcheck
      - name: cabal-install integration-tests2
        run: |
          cd cabal-install
          cabal v2-run cabal-install:integration-tests2
      - name: cabal-install unit-tests
        run: |
          cd cabal-install
          cabal v2-run cabal-install:unit-tests -- --pattern "! (/FileMonitor/ || /VCS/ || /Get/)"
      - name: cabal-tests
        # Using only one job, -j1, to fail less.
        run: cabal v2-run cabal-tests -- -j1 --with-cabal=dist-newstyle\build\x86_64-windows\ghc-{{ job.version }}\cabal-install-3.2.0.0\x\cabal\build\cabal\cabal.exe
{% endfor %}
