Skip to content

Commit ce2cbba

Browse files
committed
feat(workflow): add GitHub Actions workflow for testing with PyQt6
1 parent 4ba61ff commit ce2cbba

File tree

1 file changed

+153
-0
lines changed

1 file changed

+153
-0
lines changed

.github/workflows/test_pyqt6.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
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 PyQt6
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 install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils
50+
/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
51+
python -m pip install --upgrade pip
52+
python -m pip install ruff pytest
53+
pip install PyQt6
54+
if [ "${{ github.ref_name }}" = "develop" ]; then
55+
# Clone and install development versions of key dependencies with editable install
56+
cd ..
57+
git clone --depth 1 https://github.com/PlotPyStack/PythonQwt.git
58+
git clone --depth 1 --branch develop https://github.com/PlotPyStack/guidata.git
59+
git clone --depth 1 --branch develop https://github.com/PlotPyStack/plotpy.git
60+
git clone --depth 1 --branch develop https://github.com/DataLab-Platform/sigima.git
61+
cd DataLab
62+
pip install -e ../guidata
63+
pip install -e ../PythonQwt
64+
pip install -e ../plotpy
65+
pip install -e ../sigima
66+
# Install tomli for TOML parsing (safe if already present)
67+
pip install tomli
68+
# Extract dependencies and save to file, then install
69+
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))"
70+
pip install -r deps.txt
71+
# Install DataLab without dependencies
72+
pip install --no-deps .
73+
elif [ "${{ github.ref_name }}" = "release" ]; then
74+
# Clone dependencies from release branches (with fallback to main/master)
75+
cd ..
76+
# Try cloning PythonQwt from main or master
77+
git clone --depth 1 https://github.com/PlotPyStack/PythonQwt.git || git clone --depth 1 --branch master https://github.com/PlotPyStack/PythonQwt.git
78+
# Try cloning guidata from release, fallback to main or master
79+
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
80+
# Try cloning plotpy from release, fallback to main or master
81+
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
82+
# Try cloning sigima from release, fallback to main
83+
git clone --depth 1 --branch release https://github.com/DataLab-Platform/sigima.git || git clone --depth 1 https://github.com/DataLab-Platform/sigima.git
84+
cd DataLab
85+
pip install -e ../guidata
86+
pip install -e ../PythonQwt
87+
pip install -e ../plotpy
88+
pip install -e ../sigima
89+
# Install tomli for TOML parsing (safe if already present)
90+
pip install tomli
91+
# Extract dependencies and save to file, then install
92+
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))"
93+
pip install -r deps.txt
94+
# Install DataLab without dependencies
95+
pip install --no-deps .
96+
else
97+
# Install from PyPI normally for main branch
98+
pip install .
99+
fi
100+
- name: Lint with Ruff
101+
run: ruff check --output-format=github datalab
102+
- name: Test with pytest
103+
run: pytest -v --tb=long
104+
105+
build_latest:
106+
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')) }}
107+
env:
108+
DISPLAY: ':99.0'
109+
runs-on: ubuntu-latest
110+
111+
steps:
112+
- uses: actions/checkout@v4
113+
114+
- name: Set up Python 3.13
115+
uses: actions/setup-python@v5
116+
with:
117+
python-version: "3.13"
118+
119+
- name: Install dependencies (latest)
120+
run: |
121+
set -euxo pipefail
122+
sudo apt-get update
123+
sudo apt-get install -y \
124+
libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 \
125+
libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils
126+
127+
/sbin/start-stop-daemon --start --quiet \
128+
--pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background \
129+
--exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX
130+
131+
python -m pip install --upgrade pip
132+
python -m pip install ruff pytest
133+
python -m pip install PyQt6
134+
135+
# Clone and install Sigima from the same branch as DataLab
136+
cd ..
137+
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
138+
cd DataLab
139+
140+
# Install DataLab itself, but do NOT install its pinned deps
141+
python -m pip install -e . --no-deps
142+
143+
# Install Sigima from local clone
144+
python -m pip install -e ../sigima
145+
146+
# Extract dependency names from pyproject.toml (excluding Sigima) and install latest versions
147+
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))")
148+
149+
- name: Lint with Ruff (latest)
150+
run: ruff check --output-format=github datalab
151+
152+
- name: Test with pytest (latest)
153+
run: pytest -v --tb=long

0 commit comments

Comments
 (0)