# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-20.04
    container:
      image: python:2.7.18-buster
    environment: CI
    steps:
    - name: Checkout project
      uses: actions/checkout@v3
    - name: Install dependencies
      run: |
        apt-get update -qq
        apt-get install -qq swig python-dev libxml2-dev libxmlsec1-dev
        pip install --disable-pip-version-check --no-cache-dir --force-reinstall --no-binary lxml lxml
        pip install --disable-pip-version-check --no-cache-dir .
        pip install --disable-pip-version-check --no-cache-dir -e ".[test]"

    - name: Lint
      run: |
        #pycodestyle tests/src/OneLogin/saml2_tests/*.py demo-flask/*.py demo-django/*.py src/onelogin/saml2/*.py --config=tests/pep8.rc
        #pyflakes src/onelogin/saml2 demo-django demo-flask tests/src/OneLogin/saml2_tests
        flake8 --ignore E226,E302,E41,E731,E501,C901,W504

    - name: Test
      run: |
        coverage run --source=src/onelogin/saml2 --rcfile=tests/coverage.rc setup.py test

    - name: Coveralls
      env:
        COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
      run: |
        pip install python-coveralls
        coveralls
