Skip to content

Remove deprecated main.yml workflow and enhance python-tests-and-publ… #11

Remove deprecated main.yml workflow and enhance python-tests-and-publ…

Remove deprecated main.yml workflow and enhance python-tests-and-publ… #11

name: Python Tests and Publish
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [created]
jobs:
test:
runs-on: self-hosted
strategy:
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 }}
architecture: 'x64'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential gcc gfortran pkg-config cmake libopenblas-dev liblapack-dev
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel
pip install -r requirements.txt
- name: Install test dependencies
run: |
pip install pytest pytest-cov
- name: Run tests
run: |
pytest tests/ --cov=src/ --cov-report=xml
- name: Upload coverage report
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'created'
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
architecture: 'x64'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*