name: unittest

on: [push]

jobs:
  unittest:

    name: unittest - ${{ matrix.python-version }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      max-parallel: 12
      matrix:
        python-version: [3.6, 3.7] # TODO: 3.8
        os: [ubuntu-latest, macos-latest] # TODO: windows-latest

    steps:
    - uses: actions/checkout@v1
    - 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 poetry
        poetry --version
        poetry install -vv
    - name: Run unittest for httprunner
      run: |
        poetry run python -m httprunner.cli -V
        poetry run python -m httprunner.cli -h
        poetry run coverage run --source=httprunner -m unittest discover
        poetry run coverage xml
        poetry run coverage report -m
    - name: Codecov
      uses: codecov/codecov-action@v1.0.5
      with:
        # User defined upload name. Visible in Codecov UI
        name: httprunner
        # Repository upload token - get it from codecov.io
        token: ${{ secrets.CODECOV_TOKEN }}
        # Path to coverage file to upload
        file: ./coverage.xml
        # Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)
        flags: unittests
        # Specify whether or not CI build should fail if Codecov runs into an error during upload
        fail_ci_if_error: true
