Skip to content

Commit 34d24a9

Browse files
committed
Actions: Add code to run OutOfProcess python startup before tests
1 parent 56bf419 commit 34d24a9

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/unix_unit_tests.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@ jobs:
319319
conda activate mhkit_conda_env
320320
printf "getenv('path')\nsetenv('path', ['%s;', getenv('path')])\ngetenv('path')\n" $(python -c "import sys; import os; print(os.path.dirname(sys.executable))") >> run.m
321321
322+
# On Linux, set LD_PRELOAD BEFORE pyenv() to ensure OutOfProcess Python uses system libstdc++
323+
- name: Configure LD_PRELOAD for Linux
324+
if: matrix.os == 'ubuntu-22.04'
325+
shell: bash
326+
run: |
327+
echo "% Force OutOfProcess Python to use system libstdc++ (must be before pyenv)" >> run.m
328+
echo "setenv('LD_PRELOAD', '/usr/lib/x86_64-linux-gnu/libstdc++.so.6');" >> run.m
329+
322330
# OutOfProcess is required to properly call netcdf/hdf5 and works reliably on macos and ubuntu
323331
- name: Configure MATLAB Python Environment
324332
shell: bash -l {0}
@@ -330,6 +338,16 @@ jobs:
330338
echo "setenv('DYLD_LIBRARY_PATH', getenv('DYLD_LIBRARY_PATH'));" >> run.m
331339
fi
332340
341+
# Warm up Python OutOfProcess worker to prevent intermittent "Unable to resolve" errors
342+
- name: Add Python environment verification
343+
shell: bash
344+
run: |
345+
echo "% Verify Python environment and warm up OutOfProcess worker" >> run.m
346+
echo "pe = pyenv;" >> run.m
347+
echo "disp(pe);" >> run.m
348+
echo "py.importlib.import_module('mhkit');" >> run.m
349+
echo "disp('Python environment verified: mhkit imported successfully');" >> run.m
350+
333351
- name: Add MATLAB test commands
334352
shell: bash
335353
run: echo "version,

.github/workflows/windows_unit_tests.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ jobs:
103103
run: >
104104
"pyenv(Version='{0}', ExecutionMode='OutOfProcess')" -f (python -c "import sys; print(sys.executable)") | Out-File -FilePath run.m
105105
106+
# Warm up Python OutOfProcess worker to prevent intermittent "Unable to resolve" errors
107+
- name: Add Python environment verification
108+
shell: bash
109+
run: |
110+
echo "% Verify Python environment and warm up OutOfProcess worker" >> run.m
111+
echo "pe = pyenv;" >> run.m
112+
echo "disp(pe);" >> run.m
113+
echo "py.importlib.import_module('mhkit');" >> run.m
114+
echo "disp('Python environment verified: mhkit imported successfully');" >> run.m
115+
106116
- name: Check Python System Path
107117
shell: bash -l {0}
108118
run: |
@@ -284,6 +294,17 @@ jobs:
284294
run: |
285295
conda activate mhkit_conda_env
286296
printf "pyenv(Version='%s', ExecutionMode='OutOfProcess')\n" $(python -c "import sys; print(sys.executable)") >> run.m
297+
298+
# Warm up Python OutOfProcess worker to prevent intermittent "Unable to resolve" errors
299+
- name: Add Python environment verification
300+
shell: bash
301+
run: |
302+
echo "% Verify Python environment and warm up OutOfProcess worker" >> run.m
303+
echo "pe = pyenv;" >> run.m
304+
echo "disp(pe);" >> run.m
305+
echo "py.importlib.import_module('mhkit');" >> run.m
306+
echo "disp('Python environment verified: mhkit imported successfully');" >> run.m
307+
287308
- name: Check Python System Path
288309
shell: bash -l {0}
289310
run: |

0 commit comments

Comments
 (0)