name: "ci"

on:
  - "push"

jobs:
  unit-tests:
    runs-on: "windows-latest"
    strategy:
      matrix:
        python-version:
          - "2.7"

    steps:
    # Avoid letting Windows newlines confusing milksnake.
    - run: "git config --global core.autocrlf false"

    - uses: actions/checkout@v2
      with:
        fetch-depth: "0"

      # Get tags not fetched by the checkout action, needed for auto-versioning.
    - run: "git fetch origin +refs/tags/*:refs/tags/*"

    # Get MS VC++ 9 aka Visual Studio 2008, required to build Python 2.7
    # extensions (zfec via Tahoe-LAFS).
    - uses: "crazy-max/ghaction-chocolatey@v1"
      with:
        args: "install vcpython27"

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install wheel coverage

    - name: "Install Dependencies"
      run: |
        pip install git+https://github.com/LeastAuthority/privacypass@master#egg=privacypass
        pip install git+https://github.com/tahoe-lafs/tahoe-lafs@master#egg=tahoe-lafs
        python -m pip install -r test-requirements.txt
        python -m pip install ./

    - name: "Dump Python Environment"
      run: |
        pip freeze

    - name: "Run Tests"
      env:
        MAGIC_FOLDER_HYPOTHESIS_PROFILE: "ci"
      run: |
        python -m coverage run -m twisted.trial _zkapauthorizer


    - name: "Convert Coverage"
      run: |
        coverage xml

    - uses: codecov/codecov-action@v1
      with:
        file: "./coverage.xml"
