Skip to content

Refactor autogen code #277

Refactor autogen code

Refactor autogen code #277

Workflow file for this run

name: Run Python Tests and Publish to PyPI
on:
push:
branches:
- master
- develop
- citest
tags:
- '*'
pull_request:
branches:
- master
- develop
workflow_dispatch:
jobs:
build-n-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]
requirements-file: ["requirements.txt"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest wheel
pip install -r ${{ matrix.requirements-file }}
python setup.py install
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 opusfilter --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 opusfilter --count --exit-zero --statistics
- name: Run tests with pytest
run: pytest
build-n-publish:
name: Build and publish Python 🐍 distributions πŸ“¦ to PyPI and TestPyPI
needs: build-n-test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Check for main release tag
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
id: check-tag
run: |
if [[ ${{ github.event.ref }} =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo ::set-output name=match::true
fi
- name: Set up Python 3.7
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install pypa/build
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution πŸ“¦ to Test PyPI
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution πŸ“¦ to PyPI
if: github.event_name == 'push' && steps.check-tag.outputs.match == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
build-and-deploy-docs:
runs-on: ubuntu-latest
needs: [build-n-test]
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies to build docs
run: |
python -m pip install --upgrade pip
python -m pip install wheel
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install .[docs]
- name: Build docs
run: |
sphinx-build docs docs/build
- name: Deploy docs
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: JamesIves/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: docs/build
CLEAN: true