build.yml 2.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
name: pytorch-widedeep

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  codestyle:
    runs-on: ubuntu-latest
14
    if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.9
      uses: actions/setup-python@v2
      with:
        python-version: 3.9
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install black flake8
    - name: Code Style (Black/Flake8)
      run: |
        # Black code style
        black --check --diff pytorch_widedeep tests examples setup.py
        # Stop the build if there are Python syntax errors or undefined names
        flake8 . --count --select=E901,E999,F821,F822,F823 --ignore=E266 --show-source --statistics
        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --ignore=E203,E266,E501,E722,F401,F403,F405,F811,W503,C901 --statistics

  test:
    runs-on: ubuntu-latest
36
    if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
    strategy:
      fail-fast: true
      matrix:
        python-version: [3.7, 3.8, 3.9]
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install pytest-cov codecov .
        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
    - name: Test with pytest
      run: |
        pytest --doctest-modules pytorch_widedeep --cov-report xml --cov-report term --disable-pytest-warnings --cov=pytorch_widedeep tests/
    - name: Upload coverage
      uses: actions/upload-artifact@v2
      with:
        name: coverage${{ matrix.python-version }}
        path: .coverage

  finish: 
    needs: test
    runs-on: ubuntu-latest
64
    if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.9
      uses: actions/setup-python@v2
      with:
        python-version: 3.9
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install coverage
    - name: Download all artifacts
      # Downloads coverage1, coverage2, etc.
      uses: actions/download-artifact@v2
    - name: Convert coverage
      run: |
        coverage combine coverage*/.coverage*
        coverage report --fail-under=95
        coverage xml
    - name: upload coverage to Codecov
      uses: codecov/codecov-action@v1
      with:
        fail_ci_if_error: true