|
| 1 | +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions |
| 2 | +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python |
| 3 | + |
| 4 | +# Inspired from https://pytest-qt.readthedocs.io/en/latest/troubleshooting.html#github-actions |
| 5 | + |
| 6 | +name: Build, install and test with PySide6 |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: [ "master", "develop", "release" ] |
| 11 | + pull_request: |
| 12 | + branches: [ "master", "develop", "release" ] |
| 13 | + workflow_call: |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + |
| 18 | + env: |
| 19 | + DISPLAY: ':99.0' |
| 20 | + |
| 21 | + runs-on: ubuntu-latest |
| 22 | + timeout-minutes: 20 |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + python-version: ["3.10", "3.14"] |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v7 |
| 30 | + - name: Set up Python ${{ matrix.python-version }} |
| 31 | + uses: actions/setup-python@v7 |
| 32 | + with: |
| 33 | + python-version: ${{ matrix.python-version }} |
| 34 | + - name: Install dependencies |
| 35 | + env: |
| 36 | + # Pull requests are routed by their target branch, pushes by their own branch |
| 37 | + TARGET_BRANCH: ${{ github.base_ref || github.ref_name }} |
| 38 | + run: | |
| 39 | + sudo apt install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils libegl1 libgl1 libopengl0 libxcb-cursor0 |
| 40 | + /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX |
| 41 | + python -m pip install --upgrade pip |
| 42 | + python -m pip install ruff pytest |
| 43 | + # PySide6 6.12.0 drops a reference to None on each void call: fatal before Python 3.12 |
| 44 | + pip install "PySide6!=6.12.0; python_version < '3.12'" "PySide6; python_version >= '3.12'" setuptools numpy Cython |
| 45 | + python setup.py build_ext --inplace |
| 46 | + if [ "$TARGET_BRANCH" = "develop" ]; then |
| 47 | + pip uninstall -y guidata PythonQwt |
| 48 | + cd .. |
| 49 | + git clone --depth 1 --branch develop https://github.com/PlotPyStack/guidata.git |
| 50 | + git clone --depth 1 https://github.com/PlotPyStack/PythonQwt.git |
| 51 | + cd PlotPy |
| 52 | + pip install -e ../guidata |
| 53 | + pip install -e ../PythonQwt |
| 54 | + # Install tomli for TOML parsing (safe if already present) |
| 55 | + pip install tomli |
| 56 | + # Extract dependencies and save to file, then install |
| 57 | + python -c "import tomli; f=open('pyproject.toml','rb'); data=tomli.load(f); deps=[d for d in data['project']['dependencies'] if not any(p in d for p in ['guidata', 'PythonQwt'])]; open('deps.txt','w').write('\n'.join(deps))" |
| 58 | + pip install -r deps.txt |
| 59 | + # Install PlotPy without dependencies |
| 60 | + pip install --no-deps . |
| 61 | + elif [ "$TARGET_BRANCH" = "release" ]; then |
| 62 | + pip uninstall -y guidata PythonQwt |
| 63 | + cd .. |
| 64 | + # Try cloning guidata from release, fallback to main or master |
| 65 | + git clone --depth 1 --branch release https://github.com/PlotPyStack/guidata.git || git clone --depth 1 https://github.com/PlotPyStack/guidata.git || git clone --depth 1 --branch master https://github.com/PlotPyStack/guidata.git |
| 66 | + # Try cloning PythonQwt from main or master |
| 67 | + git clone --depth 1 https://github.com/PlotPyStack/PythonQwt.git || git clone --depth 1 --branch master https://github.com/PlotPyStack/PythonQwt.git |
| 68 | + cd PlotPy |
| 69 | + pip install -e ../guidata |
| 70 | + pip install -e ../PythonQwt |
| 71 | + # Install tomli for TOML parsing (safe if already present) |
| 72 | + pip install tomli |
| 73 | + # Extract dependencies and save to file, then install |
| 74 | + python -c "import tomli; f=open('pyproject.toml','rb'); data=tomli.load(f); deps=[d for d in data['project']['dependencies'] if not any(p in d for p in ['guidata', 'PythonQwt'])]; open('deps.txt','w').write('\n'.join(deps))" |
| 75 | + pip install -r deps.txt |
| 76 | + # Install PlotPy without dependencies |
| 77 | + pip install --no-deps . |
| 78 | + else |
| 79 | + # Install from PyPI normally for master branch |
| 80 | + pip install .[test] |
| 81 | + fi |
| 82 | + - name: Lint with Ruff |
| 83 | + run: ruff check --output-format=github plotpy |
| 84 | + - name: Test with pytest |
| 85 | + run: | |
| 86 | + pytest |
0 commit comments