Skip to content

Commit d7909f2

Browse files
committed
Actions: Use windows findings to inform unix matlab/python setup
1 parent 29c6a86 commit d7909f2

1 file changed

Lines changed: 39 additions & 15 deletions

File tree

.github/workflows/unix_unit_tests.yml

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,48 @@ jobs:
9797
with:
9898
release: ${{ matrix.matlab-version }}
9999

100-
# OutOfProcess is required to properly call netcdf/hdf5 and works reliably on macos and ubuntu
101-
- name: Configure MATLAB Python Environment
100+
# Generate run.m using Python to match Windows workflow approach
101+
# Using InProcess mode for cache_population job
102+
- name: Generate run.m
102103
shell: bash -l {0}
103104
run: |
104105
conda activate mhkit_conda_env
105-
printf 'pyenv(Version="%s", ExecutionMode="OutOfProcess")\n' $(python -c "import sys; print(sys.executable)") > run.m
106-
107-
- name: Add MATLAB test commands
108-
shell: bash
109-
run: echo "version,
110-
addpath(genpath('mhkit')),
111-
import matlab.unittest.TestSuite,
112-
import matlab.unittest.TestRunner,
113-
testFolder = ['mhkit' filesep 'tests'],
114-
suite = TestSuite.fromFolder(testFolder),
115-
runner = TestRunner.withTextOutput,
116-
results = runner.run(suite),
117-
assertSuccess(results)" >> run.m
106+
python -c "
107+
import sys
108+
109+
python_exe = sys.executable
110+
111+
content = f'''pyenv(Version='{python_exe}', ExecutionMode='InProcess')
112+
% Verify Python environment
113+
pe = pyenv;
114+
disp(pe);
115+
% Warm up numpy - must call function to force resolution
116+
py.importlib.import_module('numpy');
117+
dummy = py.numpy.array([1,2,3]);
118+
disp(class(dummy));
119+
clear dummy;
120+
disp('py.numpy.array: resolved');
121+
% Warm up mhkit submodules - force resolution by calling functions
122+
py.importlib.import_module('mhkit');
123+
py.importlib.import_module('mhkit.wave.io.ndbc');
124+
py.importlib.import_module('mhkit.wave.io.swan');
125+
py.importlib.import_module('mhkit.river.resource');
126+
disp('mhkit submodules: imported');
127+
version
128+
pyenv
129+
addpath(genpath('mhkit'))
130+
import matlab.unittest.TestSuite
131+
import matlab.unittest.TestRunner
132+
testFolder = ['mhkit' filesep 'tests'];
133+
suite = TestSuite.fromFolder(testFolder);
134+
runner = TestRunner.withTextOutput;
135+
results = runner.run(suite);
136+
assertSuccess(results)
137+
'''
138+
139+
with open('run.m', 'w', encoding='utf-8', newline='\\n') as f:
140+
f.write(content)
141+
"
118142
119143
- name: Output run.m
120144
shell: bash

0 commit comments

Comments
 (0)