Skip to content

Fix readthedocs build #180

Fix readthedocs build

Fix readthedocs build #180

Workflow file for this run

# This workflow will lint, run unit tests, test CLI and build 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: Test Python package
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
linting:
name: Linting
# linting has nothing to do with multiple versions of os and python
# (the result will be the same) and therefore separated to save time
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Load pip cache if cache exists
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: ${{ runner.os }}-pip
- name: Install linters
run: python -m pip install black flake8 isort
- name: Lint code
run: |
flake8 ./qats/ --exit-zero --max-complexity=10 --statistics
black .
isort .
testing:
needs: linting
name: Test with Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
# https://stackoverflow.com/questions/75549995/why-do-the-pyside6-qt-modules-cause-tox-to-fail-during-a-github-action
- name: Install missing libraries on GitHub agent
run: sudo apt update && sudo apt install -y libegl1-mesa-dev
- name: Check out repository
uses: actions/checkout@v4
- name: Set up python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v3
with:
path: ~/.local # the path depends on the OS
key: poetry-0 # increment to reset cache
- name: Install and configure Poetry
# install if not cached. Create venv in project to simplify caching
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
# Consider specifying version (version: 1.7.1 on Python 3.11)
virtualenvs-create: true
virtualenvs-in-project: true #.venv in current directory
- name: Install dynamic versioning plugin
run: poetry self add "poetry-dynamic-versioning[plugin]"
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Create venv and install project dependencies
# install if not cached
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install project
# required to test the CLI, show working directory for debugging
run: |
poetry install --no-interaction
ls -a
- name: Run unit tests
run: |
source .venv/bin/activate
pytest test/
- name: Test CLI
env:
QT_API: pyside6
run: |
source .venv/bin/activate
qats -h
qats app -h
qats config -h
python -m qats -h
- name: Test building package
run: poetry build
- name: Test building documentation
run: |
source .venv/bin/activate
sphinx-build -b html docs/source docs/_build
- name: Upload artifacts
if: ${{ matrix.python-version == '3.11' }}
uses: actions/upload-artifact@v3
with:
name: test-builds
path: |
dist/qats-*.tar.gz
dist/qats-*.whl