Skip to content

Commit 303d5a4

Browse files
committed
Fix Uploading failed image tests as artifacts
This has not worked in quite some time, but now if an image comparison test fails, the failed image will be made available as an artifact for future testing/evaluation.
1 parent 3db2b91 commit 303d5a4

File tree

2 files changed

+78
-70
lines changed

2 files changed

+78
-70
lines changed

.github/workflows/main.yml

Lines changed: 77 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,19 @@ jobs:
139139
if: runner.os != 'Linux'
140140
- name: Run Tests
141141
run: |
142-
mkdir $SCREENSHOT_DIR
142+
mkdir "$SCREENSHOT_DIR"
143143
pytest tests -v
144144
pytest pyqtgraph/examples -v -n 2
145145
shell: bash
146146
- name: Upload Screenshots
147+
if: failure()
147148
uses: actions/upload-artifact@v4
148149
with:
149150
name: Screenshots (Python ${{ matrix.python-version }} - Qt-Bindings ${{ matrix.qt-lib }} - OS ${{ matrix.os }})
150-
path: $SCREENSHOT_DIR
151+
path: ${{ env.SCREENSHOT_DIR }}
151152
if-no-files-found: ignore
152153
env:
153-
SCREENSHOT_DIR: ./screenshots
154+
SCREENSHOT_DIR: screenshots
154155

155156
test-conda:
156157
runs-on: ${{ matrix.os }}
@@ -169,72 +170,79 @@ jobs:
169170
- qt-lib: pyside
170171
environment-file: .github/workflows/etc/environment-pyside.yml
171172
steps:
172-
- name: Checkout
173-
uses: actions/checkout@v4
174-
- uses: conda-incubator/setup-miniconda@v3
175-
with:
176-
miniforge-version: latest
177-
miniforge-variant: Mambaforge
178-
environment-file: ${{ matrix.environment-file }}
179-
auto-update-conda: false
180-
python-version: "3.12"
181-
use-mamba: true
182-
- name: "Install Test Framework"
183-
run: pip install pytest pytest-xdist
184-
- name: "Install Windows-Mesa OpenGL DLL"
185-
if: runner.os == 'Windows'
186-
run: |
187-
curl -L --output mesa.7z --url https://github.com/pal1000/mesa-dist-win/releases/download/24.0.6/mesa3d-24.0.6-release-msvc.7z
188-
7z x mesa.7z -o*
189-
powershell.exe mesa\systemwidedeploy.cmd 1
190-
shell: pwsh
191-
- name: "Install Linux VirtualDisplay"
192-
if: runner.os == 'Linux'
193-
run: |
194-
sudo apt-get update -y --allow-releaseinfo-change
195-
sudo apt-get install -y --no-install-recommends \
196-
libxkbcommon-x11-0 \
197-
x11-utils \
198-
libyaml-dev \
199-
libegl1-mesa \
200-
libxcb-icccm4 \
201-
libxcb-image0 \
202-
libxcb-keysyms1 \
203-
libxcb-randr0 \
204-
libxcb-render-util0 \
205-
libxcb-xinerama0 \
206-
libopengl0 \
207-
libxcb-cursor0
208-
pip install pytest-xvfb
209-
- name: 'Debug Info'
210-
run: |
211-
echo python location: `which python`
212-
echo python version: `python --version`
213-
echo pytest location: `which pytest`
214-
echo installed packages
215-
conda list
216-
pip list
217-
echo pyqtgraph system info
218-
python -c "import pyqtgraph as pg; pg.systemInfo()"
219-
env:
220-
QT_DEBUG_PLUGINS: 1
221-
- name: 'XVFB Display Info'
222-
run: |
223-
xvfb-run --server-args="-screen 0, 1920x1200x24 -ac +extension GLX +render -noreset" python -m pyqtgraph.util.glinfo
224-
xvfb-run --server-args="-screen 0, 1920x1200x24 -ac +extension GLX +render -noreset" python -m pyqtgraph.util.get_resolution
225-
if: runner.os == 'Linux'
226-
- name: 'Display Info'
227-
run: |
228-
python -m pyqtgraph.util.glinfo
229-
python -m pyqtgraph.util.get_resolution
230-
if: runner.os != 'Linux'
231-
- name: Run Tests
232-
run: |
233-
mkdir $SCREENSHOT_DIR
234-
pytest tests -v
235-
pytest pyqtgraph/examples -v -n 2
236-
env:
237-
SCREENSHOT_DIR: ./screenshots
173+
- name: Checkout
174+
uses: actions/checkout@v4
175+
- uses: conda-incubator/setup-miniconda@v3
176+
with:
177+
miniforge-version: latest
178+
miniforge-variant: Mambaforge
179+
environment-file: ${{ matrix.environment-file }}
180+
auto-update-conda: false
181+
python-version: "3.12"
182+
use-mamba: true
183+
- name: "Install Test Framework"
184+
run: pip install pytest pytest-xdist
185+
- name: "Install Windows-Mesa OpenGL DLL"
186+
if: runner.os == 'Windows'
187+
run: |
188+
curl -L --output mesa.7z --url https://github.com/pal1000/mesa-dist-win/releases/download/24.0.6/mesa3d-24.0.6-release-msvc.7z
189+
7z x mesa.7z -o*
190+
powershell.exe mesa\systemwidedeploy.cmd 1
191+
shell: pwsh
192+
- name: "Install Linux VirtualDisplay"
193+
if: runner.os == 'Linux'
194+
run: |
195+
sudo apt-get update -y --allow-releaseinfo-change
196+
sudo apt-get install -y --no-install-recommends \
197+
libxkbcommon-x11-0 \
198+
x11-utils \
199+
libyaml-dev \
200+
libegl1-mesa \
201+
libxcb-icccm4 \
202+
libxcb-image0 \
203+
libxcb-keysyms1 \
204+
libxcb-randr0 \
205+
libxcb-render-util0 \
206+
libxcb-xinerama0 \
207+
libopengl0 \
208+
libxcb-cursor0
209+
pip install pytest-xvfb
210+
- name: 'Debug Info'
211+
run: |
212+
echo python location: `which python`
213+
echo python version: `python --version`
214+
echo pytest location: `which pytest`
215+
echo installed packages
216+
conda list
217+
pip list
218+
echo pyqtgraph system info
219+
python -c "import pyqtgraph as pg; pg.systemInfo()"
220+
env:
221+
QT_DEBUG_PLUGINS: 1
222+
- name: 'XVFB Display Info'
223+
run: |
224+
xvfb-run --server-args="-screen 0, 1920x1200x24 -ac +extension GLX +render -noreset" python -m pyqtgraph.util.glinfo
225+
xvfb-run --server-args="-screen 0, 1920x1200x24 -ac +extension GLX +render -noreset" python -m pyqtgraph.util.get_resolution
226+
if: runner.os == 'Linux'
227+
- name: 'Display Info'
228+
run: |
229+
python -m pyqtgraph.util.glinfo
230+
python -m pyqtgraph.util.get_resolution
231+
if: runner.os != 'Linux'
232+
- name: Run Tests
233+
run: |
234+
mkdir "$SCREENSHOT_DIR"
235+
pytest tests -v
236+
pytest pyqtgraph/examples -v -n 2
237+
- name: Upload Screenshots
238+
if: failure()
239+
uses: actions/upload-artifact@v4
240+
with:
241+
name: Screenshots (Conda - Qt-Bindings ${{ matrix.qt-lib }} - OS ${{ matrix.os }})
242+
path: ${{ env.SCREENSHOT_DIR }}
243+
if-no-files-found: ignore
244+
env:
245+
SCREENSHOT_DIR: screenshots
238246

239247
build-wheel:
240248
name: build wheel

tests/image_testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def assertImageApproved(image, standardFile, message=None, **kwargs):
171171
"PYQTGRAPH_AUDIT=1 to add this image." % stdFileName)
172172
if os.getenv('CI') is not None:
173173
standardFile = os.path.join(os.getenv("SCREENSHOT_DIR", "screenshots"), standardFile)
174-
saveFailedTest(image, stdImage, standardFile)
174+
saveFailedTest(image, stdImage, standardFile, save_comparison=True)
175175
print(graphstate)
176176
raise
177177

0 commit comments

Comments
 (0)