| 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: Install and Test on Ubuntu (latest) with PyQt5 |
| 7 |
|
| 8 |
on: |
| 9 |
push: |
| 10 |
branches: [ "main", "develop", "release" ] |
| 11 |
pull_request: |
| 12 |
branches: [ "main", "develop", "release" ] |
| 13 |
workflow_dispatch: |
| 14 |
inputs: |
| 15 |
job_to_run: |
| 16 |
description: 'Which job to run' |
| 17 |
required: true |
| 18 |
type: choice |
| 19 |
options: |
| 20 |
- 'all' |
| 21 |
- 'build' |
| 22 |
- 'build_latest' |
| 23 |
default: 'all' |
| 24 |
schedule: |
| 25 |
# Only the "build_latest" job runs on schedule (see execution conditions below) |
| 26 |
- cron: "0 5 * * 1" |
| 27 |
|
| 28 |
jobs: |
| 29 |
build: |
| 30 |
if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request') || (github.event_name == 'workflow_dispatch' && (github.event.inputs.job_to_run == 'all' || github.event.inputs.job_to_run == 'build')) }} |
| 31 |
|
| 32 |
env: |
| 33 |
DISPLAY: ':99.0' |
| 34 |
|
| 35 |
runs-on: ubuntu-latest |
| 36 |
strategy: |
| 37 |
fail-fast: false |
| 38 |
matrix: |
| 39 |
python-version: ["3.9", "3.13"] |
| 40 |
|
| 41 |
steps: |
| 42 |
- uses: actions/checkout@v4 |
| 43 |
- name: Set up Python ${{ matrix.python-version }} |
| 44 |
uses: actions/setup-python@v5 |
| 45 |
with: |
| 46 |
python-version: ${{ matrix.python-version }} |
| 47 |
- name: Install dependencies |
| 48 |
run: | |
| 49 |
sudo apt-get update |
| 50 |
sudo apt-get install -y libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils |
| 51 |
/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 |
| 52 |
python -m pip install --upgrade pip |
| 53 |
python -m pip install ruff pytest httpx |
| 54 |
pip install PyQt5 |
| 55 |
if [ "${{ github.ref_name }}" = "develop" ]; then |
| 56 |
# Clone and install development versions of key dependencies with editable install |
| 57 |
cd .. |
| 58 |
git clone --depth 1 https://github.com/PlotPyStack/PythonQwt.git |
| 59 |
git clone --depth 1 --branch develop https://github.com/PlotPyStack/guidata.git |
| 60 |
git clone --depth 1 --branch develop https://github.com/PlotPyStack/plotpy.git |
| 61 |
git clone --depth 1 --branch develop https://github.com/DataLab-Platform/sigima.git |
| 62 |
cd DataLab |
| 63 |
pip install -e ../guidata |
| 64 |
pip install -e ../PythonQwt |
| 65 |
pip install -e ../plotpy |
| 66 |
pip install -e ../sigima |
| 67 |
# Install tomli for TOML parsing (safe if already present) |
| 68 |
pip install tomli |
| 69 |
# Extract dependencies and save to file, then install |
| 70 |
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','PlotPy','Sigima'])]; open('deps.txt','w').write('\n'.join(deps))" |
| 71 |
pip install -r deps.txt |
| 72 |
# Install DataLab without dependencies |
| 73 |
pip install --no-deps . |
| 74 |
elif [ "${{ github.ref_name }}" = "release" ]; then |
| 75 |
# Clone dependencies from release branches (with fallback to main/master) |
| 76 |
cd .. |
| 77 |
# Try cloning PythonQwt from main or master |
| 78 |
git clone --depth 1 https://github.com/PlotPyStack/PythonQwt.git || git clone --depth 1 --branch master https://github.com/PlotPyStack/PythonQwt.git |
| 79 |
# Try cloning guidata from release, fallback to main or master |
| 80 |
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 |
| 81 |
# Try cloning plotpy from release, fallback to main or master |
| 82 |
git clone --depth 1 --branch release https://github.com/PlotPyStack/plotpy.git || git clone --depth 1 https://github.com/PlotPyStack/plotpy.git || git clone --depth 1 --branch master https://github.com/PlotPyStack/plotpy.git |
| 83 |
# Try cloning sigima from release, fallback to main |
| 84 |
git clone --depth 1 --branch release https://github.com/DataLab-Platform/sigima.git || git clone --depth 1 https://github.com/DataLab-Platform/sigima.git |
| 85 |
cd DataLab |
| 86 |
pip install -e ../guidata |
| 87 |
pip install -e ../PythonQwt |
| 88 |
pip install -e ../plotpy |
| 89 |
pip install -e ../sigima |
| 90 |
# Install tomli for TOML parsing (safe if already present) |
| 91 |
pip install tomli |
| 92 |
# Extract dependencies and save to file, then install |
| 93 |
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','PlotPy','Sigima'])]; open('deps.txt','w').write('\n'.join(deps))" |
| 94 |
pip install -r deps.txt |
| 95 |
# Install DataLab without dependencies |
| 96 |
pip install --no-deps . |
| 97 |
else |
| 98 |
# Install from PyPI normally for main branch |
| 99 |
pip install . |
| 100 |
fi |
| 101 |
- name: Lint with Ruff |
| 102 |
run: ruff check --output-format=github datalab |
| 103 |
- name: Test with pytest |
| 104 |
run: pytest -v --tb=long |
| 105 |
|
| 106 |
build_latest: |
| 107 |
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && (github.event.inputs.job_to_run == 'all' || github.event.inputs.job_to_run == 'build_latest')) }} |
| 108 |
env: |
| 109 |
DISPLAY: ':99.0' |
| 110 |
runs-on: ubuntu-latest |
| 111 |
|
| 112 |
steps: |
| 113 |
- uses: actions/checkout@v4 |
| 114 |
|
| 115 |
- name: Set up Python 3.13 |
| 116 |
uses: actions/setup-python@v5 |
| 117 |
with: |
| 118 |
python-version: "3.13" |
| 119 |
|
| 120 |
- name: Install dependencies (latest) |
| 121 |
run: | |
| 122 |
set -euxo pipefail |
| 123 |
sudo apt-get update |
| 124 |
sudo apt-get install -y \ |
| 125 |
libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 \ |
| 126 |
libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils |
| 127 |
|
| 128 |
/sbin/start-stop-daemon --start --quiet \ |
| 129 |
--pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background \ |
| 130 |
--exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX |
| 131 |
|
| 132 |
python -m pip install --upgrade pip |
| 133 |
python -m pip install ruff pytest httpx |
| 134 |
python -m pip install PyQt5 |
| 135 |
|
| 136 |
# Clone and install Sigima from the same branch as DataLab |
| 137 |
cd .. |
| 138 |
git clone --depth 1 --branch ${{ github.ref_name }} https://github.com/DataLab-Platform/sigima.git || git clone --depth 1 https://github.com/DataLab-Platform/sigima.git |
| 139 |
cd DataLab |
| 140 |
|
| 141 |
# Install DataLab itself, but do NOT install its pinned deps |
| 142 |
python -m pip install -e . --no-deps |
| 143 |
|
| 144 |
# Install Sigima from local clone |
| 145 |
python -m pip install -e ../sigima |
| 146 |
|
| 147 |
# Extract dependency names from pyproject.toml (excluding Sigima) and install latest versions |
| 148 |
python -m pip install -U --upgrade-strategy eager $(python -c "import tomllib, re; print(' '.join(re.sub(r'[\[\]<>=!~,.\s].*$', '', d).strip() for d in tomllib.loads(open('pyproject.toml', 'rb').read().decode())['project']['dependencies'] if 'Sigima' not in d))") |
| 149 |
|
| 150 |
- name: Lint with Ruff (latest) |
| 151 |
run: ruff check --output-format=github datalab |
| 152 |
|
| 153 |
- name: Test with pytest (latest) |
| 154 |
run: pytest -v --tb=long |