name: Win2019

on: [push, pull_request]

jobs:
  test:

    runs-on: windows-2019

    strategy:
      fail-fast: false
      matrix:
        # group modules to get a job runtime of ~15min
        module: [
            datalad.core,
            datalad.local datalad.distributed datalad.support,
            datalad.customremotes datalad.downloaders datalad.plugin,
            datalad.distribution,
            datalad.interface,
            datalad.metadata datalad.tests datalad.ui datalad.cmdline
        ]
    steps:
    - name: Configure windows system
      run: |
        # https://support.microsoft.com/en-us/help/121007/how-to-disable-8-3-file-name-creation-on-ntfs-partitions
        fsutil.exe behavior set disable8dot3 1
    - name: Set up environment
      run: |
        git config --global user.email "test@github.land"
        git config --global user.name "GitHub Almighty"
    - uses: actions/checkout@v1
    - name: Set up Python 3.7
      uses: actions/setup-python@v1
      with:
        python-version: 3.7
    - name: Set up git-annex
      run: |
        # latest version
        #python -c "import urllib.request as r; r.urlretrieve('https://downloads.kitenet.net/git-annex/windows/current/git-annex-installer.exe', 'C:\\git-annex-installer.exe')"
        # specific version mih uses to debug on real win10 box
        python -c "import urllib.request as r; r.urlretrieve('http://store.datalad.org/git-annex/windows/git-annex_8.20200309.exe', 'C:\\git-annex-installer.exe')"
        7z x -o"C:\\Program Files\Git" C:\\git-annex-installer.exe
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
        pip install colorama
        pip install ".[tests]"
        pip install ".[devel-utils]"
    - name: WTF!?
      run: |
        datalad wtf
        dir
    - name: ${{ matrix.module }} tests
      run: |
        mkdir -p __testhome__
        cd __testhome__
        python -m nose -s -v --with-cov --cover-package datalad ${{ matrix.module }}
    # coverage report is not functional because codecov refuses to accept the
    # report
    #- name: Coverage report
    #  run: |
    #    cd __testhome__
    #    python -m coverage xml
    #    powershell.exe Invoke-WebRequest -Uri "https://codecov.io/bash" -OutFile codecov.sh
    #    bash codecov.sh -f coverage.xml
