|
| 1 | +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions |
| 3 | + |
| 4 | +name: Python Package |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [ master ] |
| 9 | + pull_request: |
| 10 | + branches: [ master ] |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + |
| 15 | + runs-on: ubuntu-latest |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + python-version: [3.6, 3.7, 3.8, 3.9] |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v2 |
| 22 | + - name: Set up Python ${{ matrix.python-version }} |
| 23 | + uses: actions/setup-python@v2 |
| 24 | + with: |
| 25 | + python-version: ${{ matrix.python-version }} |
| 26 | + - name: Install dependencies |
| 27 | + run: | |
| 28 | + python -m pip install --upgrade pip |
| 29 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 30 | + if [ -f dev-requirements.txt ]; then pip install -r dev-requirements.txt; fi |
| 31 | + - name: Lint with flake8, black, isort, pydocstyle |
| 32 | + run: | |
| 33 | + flake8 bashplot/ --count --max-line-length=88 --ignore=W293,W291 --statistic |
| 34 | + black . --check -v |
| 35 | + isort . --check -v |
| 36 | + flake8 . --count --exit-zero --max-complexity=10 --statistics |
| 37 | + pydocstyle --convention=numpy -e bashplot/bashplot.py |
| 38 | + - name: Test with pytest |
| 39 | + run: | |
| 40 | + coverage run --source=./test -m unittest |
| 41 | + coverage report -m |
| 42 | + - name: Codecov |
| 43 | + uses: codecov/codecov-action@v1 |
| 44 | + with: |
| 45 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 46 | + env_vars: OS,PYTHON |
| 47 | + deploy: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + needs: build |
| 50 | + steps: |
| 51 | + - name: Publish package |
| 52 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 53 | + - uses: actions/checkout@v2 |
| 54 | + - name: Set up Python |
| 55 | + uses: actions/setup-python@v2 |
| 56 | + with: |
| 57 | + python-version: '3.8' |
| 58 | + - name: Install dependencies |
| 59 | + run: | |
| 60 | + python -m pip install --upgrade pip |
| 61 | + pip install setuptools wheel twine |
| 62 | + - name: Build and publish on PyPi |
| 63 | + env: |
| 64 | + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
| 65 | + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 66 | + run: | |
| 67 | + python setup.py sdist bdist_wheel |
| 68 | + twine upload dist/* |
0 commit comments