Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Fix Unit Tests #108

Merged
merged 209 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
209 commits
Select commit Hold shift + click to select a range
841d152
Adressing issue #65 tidal ebb and flood plots for Matlab
Alex-McVey Dec 29, 2021
49b2f07
adding the project file
rpauly18 Jan 7, 2022
b9cba86
updating the function descriptions
rpauly18 Jan 7, 2022
640a376
Merge branch 'master' of github.com:MHKiT-Software/MHKiT-MATLAB into …
rpauly18 Jan 7, 2022
0cf0143
WPTO for Matlab (#61)
hivanov-nrel Jan 10, 2022
85e3eea
Adding tests to account for the new plot functions plot_tidal_phase_e…
Alex-McVey Jan 28, 2022
1934740
Merge branch 'iss65' of https://github.com/Alex-McVey/MHKiT-MATLAB in…
Alex-McVey Jan 28, 2022
f63c0bc
Merge branch 'develop' of github.com:MHKiT-Software/MHKiT-MATLAB into…
rpauly18 Feb 18, 2022
369d0cf
resolving merge conflict
rpauly18 Feb 18, 2022
60c44d5
Merge branch 'iss65' of https://github.com/Alex-McVey/MHKiT-MATLAB in…
rpauly18 Feb 18, 2022
02e3440
Addressing issue #65 tidal ebb and flood plots for Matlab (#73)
Alex-McVey Feb 18, 2022
219879e
Addressing issue #59 magnitude and phase function for Matlab (#76)
Alex-McVey Feb 18, 2022
39f11dc
Revert "Addressing issue #65 tidal ebb and flood plots for Matlab (#7…
rpauly18 Feb 25, 2022
4b75a55
Revert "Revert "Addressing issue #65 tidal ebb and flood plots for Ma…
rpauly18 Feb 25, 2022
cec3557
General updates (#71)
rpauly18 Feb 25, 2022
db5a60b
Wave updates (#70)
rpauly18 Mar 21, 2022
1856b59
CDIP Data IO and Graphics (v2) [develop] (#83)
Matthew-Boyd Mar 31, 2022
9318f4f
updating package
rpauly18 Mar 31, 2022
63cb281
resolve conflicts
rpauly18 Mar 31, 2022
d723b3a
fixing error
rpauly18 Mar 31, 2022
2e91690
fixing errors take 2
rpauly18 Mar 31, 2022
228b583
Add MHKit-Python test conditional on test failure
H0R5E Apr 29, 2022
ac394e0
Merge branch 'master' into develop
Matthew-Boyd May 23, 2022
4114469
include tests for R2020b
hivanov-nrel May 23, 2022
7463c04
add workflow dispatch for testing
hivanov-nrel May 23, 2022
a8593e4
fix typo
hivanov-nrel May 23, 2022
704ca54
workflow_dispatch
hivanov-nrel May 23, 2022
8a905e2
add push?
hivanov-nrel May 23, 2022
386ac97
update variable name
hivanov-nrel May 23, 2022
722f42e
update on latest input
hivanov-nrel May 23, 2022
8c28dcd
switch to ubuntu
hivanov-nrel May 23, 2022
5d4cb8d
finalize workflow
hivanov-nrel May 24, 2022
eca9e63
Merge pull request #97 from hivanov-nrel/matlab_releases
Matthew-Boyd Jun 2, 2022
3c9bd51
Adressing issue #65 tidal ebb and flood plots for Matlab
Alex-McVey Dec 29, 2021
3916302
adding the project file
rpauly18 Jan 7, 2022
c7f3992
updating the function descriptions
rpauly18 Jan 7, 2022
c557c43
Adding tests to account for the new plot functions plot_tidal_phase_e…
Alex-McVey Jan 28, 2022
209d37a
Removing python dependencies: read_noaa_json
Alex-McVey Apr 29, 2022
c4eec2e
trying to fix git issue
Alex-McVey Apr 29, 2022
8e779ca
Removing python dependencies: principal_flow_directions
Alex-McVey May 2, 2022
4cc9ee4
Removing python dependencies: exceedance_probability. This change wil…
Alex-McVey May 2, 2022
71b0b38
Removing python dependencies: plot_tidal_phase_exceedance
Alex-McVey May 2, 2022
4761a23
Updating examples and test in accordance with the changes made to rem…
Alex-McVey May 2, 2022
6be98b5
WDRT functionality: MLER (#96)
hivanov-nrel Nov 17, 2022
ffa4b61
fixing typo
rpauly18 Nov 17, 2022
ed0992d
fixing file path call in tests
rpauly18 Dec 2, 2022
3697735
conditional run of hindcast tests
rpauly18 Dec 16, 2022
d29d5e3
Dolfyn Functionality: IO and rotations (#79)
Alex-McVey Jan 24, 2023
17157c7
read NetCDF file (#104)
kchong75 Jun 27, 2023
7895020
typo fix in examples (#103)
kchong75 Jun 27, 2023
077f525
Update power quality flicker assessment (#105)
kchong75 Jul 26, 2023
71e94da
resolving merge conflict
rpauly18 Oct 27, 2023
6ec27f0
resolve merge
rpauly18 Oct 27, 2023
b69d1bd
Workflow: Fix matlab mhkit import
simmsa Oct 30, 2023
28a9a16
Workflow: Reduce scope for testing
simmsa Oct 30, 2023
a8770e8
Workflow: Pass python executable to MATLAB
simmsa Oct 30, 2023
3b9ac0c
Windows: Fix MATLAB not loading MHKiT-Python
simmsa Oct 31, 2023
18f47ea
Test Case: Add simple MHKiT Python tests
simmsa Oct 31, 2023
d5b2667
Workflow: Use anaconda for python executable
simmsa Oct 31, 2023
63fbf91
Workflow: Troubleshoot Windows MATLAB not loading python
simmsa Nov 1, 2023
d7b8c46
Workflow: Separate out Windows unit test into separate workflow
simmsa Nov 2, 2023
7fb09df
Workflow: Separate out Unix unit test into separate workflow
simmsa Nov 2, 2023
0cc0429
Workflow: Cleanup Windows unit test workflow
simmsa Nov 2, 2023
fb810f1
Workflow: Cleanup Unix unit test workflow
simmsa Nov 2, 2023
0ffaa82
Workflow: Delete combined Window/Unix unit test
simmsa Nov 2, 2023
980e639
Workflow: Test multiple versions of python on Unix
simmsa Nov 2, 2023
ecfe15d
Workflow: Specify matlab and python versions
simmsa Nov 2, 2023
0c3bb65
Workflow: Test excludes without python 3.10 string
simmsa Nov 2, 2023
4aa7ca8
Workflow: Correct compatible version of python and matlab
simmsa Nov 2, 2023
794cd20
Workflow: Use matlab run test action
simmsa Nov 2, 2023
4e65ae7
Workflow: Revert back to run command action
simmsa Nov 6, 2023
40bd473
Python: Add function to convert list to series
simmsa Nov 6, 2023
42c9a58
Tests: Fix projected capture calc to reflect python change
simmsa Nov 7, 2023
b40f427
Test: Use pm spectrum to match python test
simmsa Nov 7, 2023
7bb130f
Fix: Convert data to series
simmsa Nov 7, 2023
f704dc6
WIP: Tests: Add more python tests
simmsa Nov 7, 2023
cd0271d
Test: Correctly access structs from exceedance probability
simmsa Nov 7, 2023
be7ada7
WIP: Fix exceedance probability
simmsa Nov 7, 2023
8a6e486
WIP: Tests: Ignore failing tests
simmsa Nov 7, 2023
6e6a4f5
WIP: Test more recent of versions of h5py in mhkit-python
simmsa Nov 7, 2023
9e3f739
Revert "WIP: Test more recent of versions of h5py in mhkit-python"
simmsa Nov 7, 2023
d60ae1d
Workflow: Explicitly install hdf5 and netcdf4
simmsa Nov 7, 2023
7e5c567
Workflow: Fix: Correctly use apt
simmsa Nov 7, 2023
d83723c
Workflow: Install numpy prior to mhkit build
simmsa Nov 7, 2023
c4fd688
Workflow: Narrow Python and MATLAB versions
simmsa Nov 7, 2023
0c1f499
Workflow: Fix: Use correct netcdf version
simmsa Nov 7, 2023
4732a4e
Workflow: Try more python versions on windows
simmsa Nov 7, 2023
1504e10
Workflow: Use MHKiT-Python conda installation method
simmsa Nov 8, 2023
3831f1d
Workflow: Explicitly activate the conda environment shell call
simmsa Nov 8, 2023
fa20773
Fix: Typo in shell specifier
simmsa Nov 8, 2023
043595a
Workflow: Fix: Test using Python OutOfProcess
simmsa Nov 8, 2023
23fb206
Workflow: Fix MATLAB/Python 3.11 library path on Ubuntu
simmsa Nov 8, 2023
46164f2
Workflow: Continue to Fix MATLAB/Python 3.11 - Install latest c, c++ …
simmsa Nov 8, 2023
8d55fea
Workflow: Try build-essential on ubuntu
simmsa Nov 8, 2023
14f35fc
Workflow: Troubleshoot Ubuntu gcc version for Python 3.11
simmsa Nov 8, 2023
9b9e618
Workflow: Specify LD_Preload on Ubuntu
simmsa Nov 8, 2023
b1ba95c
Workflow: Add troubleshooting info
simmsa Nov 8, 2023
257847b
Workflow: Drop export from environment variable assignment
simmsa Nov 8, 2023
e9ab4ab
Workflow: Remove ubuntu debugging jobs
simmsa Nov 8, 2023
59b9e7c
Workflow: Use conda activate
simmsa Nov 8, 2023
5294558
Tests: Remove extraneous whitespace
simmsa Nov 8, 2023
9ed8776
Workflow: Clean up whitespace
simmsa Nov 8, 2023
97d8843
Tests: Split python tests into imports and IO
simmsa Nov 8, 2023
59e58e7
Style: Remove extraneous whitespace in loads module
simmsa Nov 9, 2023
5cbdd79
Style: Remove extraneous whitespace in dolfyn module
simmsa Nov 9, 2023
afce5c3
Style: Remove extraneous whitespace in power module
simmsa Nov 13, 2023
7d0a528
Spelling: Fix common errors in power module
simmsa Nov 13, 2023
e44ea89
Style: Remove extraneous whitespace in qc module
simmsa Nov 13, 2023
477e8d6
Style: Remove extraneous whitespace in river module
simmsa Nov 13, 2023
61cecd6
Style: Remove extraneous whitespace in test module
simmsa Nov 13, 2023
b318f53
Style: Remove extraneous whitespace in tidal module
simmsa Nov 13, 2023
95e24cc
Style: Use consistent format for line endings
simmsa Nov 13, 2023
abd5d55
Style: Remove extraneous whitespace in utils module
simmsa Nov 13, 2023
a6ed65c
Style: Use consistent format for line endings
simmsa Nov 13, 2023
160b26d
Style: Remove extraneous whitespace in wave module
simmsa Nov 15, 2023
8d108ce
Fix: Add back annotations for wave power matrix
simmsa Nov 15, 2023
27b01f4
Style: Format workflows with prettier
simmsa Nov 15, 2023
3c79d77
Workflow: Skip Windows unit tests
simmsa Nov 15, 2023
fa0b756
Docs: Test new status badge
simmsa Nov 15, 2023
adf8213
Fix: Match test class to test filename
simmsa Nov 15, 2023
be70376
Fix: Warnings related to importing numpy
simmsa Nov 15, 2023
83dbc31
Tests: Fix Python serialization bug in QC tests
simmsa Nov 27, 2023
30ead68
Test: Fix Tidal_TestResource test_plot_phase_exceedance
simmsa Nov 28, 2023
e2613e4
Tests: Fix test_request_noaa_data
simmsa Nov 28, 2023
dd34883
Tests: Request multiple days and months of noaa tidal data
simmsa Nov 28, 2023
40cd75e
Fix: Convert spectrum into numpy array
simmsa Nov 29, 2023
81826f6
Tests: Re-enable tests fixed by 40cd75e
simmsa Nov 29, 2023
04f2329
Docs: Remove extraneous whitespace in README
simmsa Nov 29, 2023
3986ccc
Docs: Use correct unit test badge
simmsa Nov 29, 2023
1b973e4
Fix: Convert array to compatible python data type
simmsa Nov 29, 2023
8ab2332
Tests: Re-enable test_plot_elevation_timeseries
simmsa Nov 29, 2023
a0cb0ef
Tests: Fix test_surface_elevation_seed
simmsa Nov 29, 2023
e2f6080
Tests: Fix test_surface_elevation_phasing
simmsa Nov 29, 2023
b0d93bb
Tests: Fix test_surface_elevation_moments
simmsa Nov 29, 2023
1f5f93a
Tests: Add code coverage
simmsa Nov 30, 2023
1381e55
Ignore: Remove .DS_Store files from repository
simmsa Dec 5, 2023
966b768
Tests: Fix intermittent failure in test_flicker_ufic_workflow
simmsa Dec 5, 2023
a430c93
Fix: Explicitly convert `spectra_to_pandas` input types
simmsa Dec 5, 2023
0361ed9
Fix: Keep more relevant test case note
simmsa Dec 5, 2023
26d4ae1
Cleanup: Remove unnecessary `disp` functions
simmsa Dec 5, 2023
cd839c8
Actions: Re-enable Windows unit tests
simmsa Dec 5, 2023
6e616c5
Actions: Set Windows MATLAB Python `ExecutionMode` to `OutOfProcess`
simmsa Dec 5, 2023
49bba28
Actions: Use MATLAB/Python version matrix for Windows Tests
simmsa Dec 5, 2023
331adc9
Actions: Explicitly activate conda on each shell call
simmsa Dec 5, 2023
16917c7
Actions: Install same python libraries on Windows
simmsa Dec 5, 2023
addebbf
Actions: Try to run Windows MATLAB Python `InProcess`
simmsa Dec 5, 2023
771b367
Cleanup: Remove `disp`
simmsa Dec 5, 2023
00efc72
Tests: Use mkhit without explicit import
simmsa Dec 5, 2023
3ee22dc
Workflow: Narrow MATLAB versions on Windows
simmsa Dec 6, 2023
79b5d03
Tests: disable test_WPTO_point_multiloc on Windows
simmsa Dec 6, 2023
758c18b
Feature: Add cache functionality for web requests
simmsa Dec 6, 2023
309f512
Feature: Cache results from hindcast queries
simmsa Dec 6, 2023
411dee9
Tests: Remove platform specific conditionals on request_wpto tests
simmsa Dec 6, 2023
2e88406
Actions: Use artifacts to save web request cache
simmsa Dec 6, 2023
7b2d50a
Actions: Add artifacts to Windows unit tests
simmsa Dec 6, 2023
40a3599
Actions: Setup cache_population job
simmsa Dec 6, 2023
22b62ee
Actions: Run main job after cache_population
simmsa Dec 6, 2023
ad3a50e
Actions: Run cache_population then main on Windows
simmsa Dec 6, 2023
2e045a2
Actions: Remove artifact saving in main job
simmsa Dec 6, 2023
f1e2971
Action: Fix nested artifact directory.
simmsa Dec 6, 2023
74f6d37
Actions: Attempt to fix artifact upload/download path
simmsa Dec 7, 2023
0902423
Tests: Temporarily use different api key for developer.nrel.gov calls
simmsa Dec 7, 2023
03fcfdc
Troubleshooting: Output cached webread url to verify url integrity
simmsa Dec 7, 2023
d35c0ca
Feature: Add retries to cached_webread
simmsa Dec 7, 2023
76376ff
Actions: Set artifact download path to "."
simmsa Dec 7, 2023
429ac05
Actions: Update path for artifact download
simmsa Dec 7, 2023
4f4c2f4
Actions: Install openssl on unix builds
simmsa Dec 7, 2023
365783b
Actions: Use conda-forge to install netcdf4
simmsa Dec 7, 2023
30e555f
Docs: Add Python/MATLAB compatibility information
simmsa Dec 7, 2023
d496dfe
Docs: Remove specific Python versions
simmsa Dec 7, 2023
4f63f49
Actions: MATLAB 2023b -> latest
simmsa Dec 7, 2023
de35572
Actions: Add output of MHKiT-Python information
simmsa Dec 7, 2023
41bbfa9
Docs: Try different checkmark to improve dark mode compatibility
simmsa Dec 7, 2023
d59ddd8
Actions: Try beta MATLAB setup action
simmsa Dec 7, 2023
7844312
Actions: Disable macos-latest python 3.11 matlab latest
simmsa Dec 8, 2023
58d9743
Actions: Add MHKiT-Python output to Windows Action
simmsa Dec 8, 2023
328925a
Actions: Use artifact cache on cache_population job
simmsa Dec 8, 2023
c8e4156
Actions: Use artifact from last workflow
simmsa Dec 8, 2023
2ee8a7a
Revert "Actions: Use artifact from last workflow"
simmsa Dec 8, 2023
4eb3639
Tests: Use original API key for developer.nrel.gov
simmsa Dec 8, 2023
6b3da65
Tests: Temporarily disable hindcast request
simmsa Dec 8, 2023
eb6731f
Actions: Populate cache folder with dummy files
simmsa Dec 8, 2023
a246d32
Tests: Cleanup Python_IO
simmsa Dec 8, 2023
e1b52cf
Actions: Standardize conda env name
simmsa Dec 8, 2023
694d7aa
Docs: Add Windows Unit Test Badge
simmsa Dec 8, 2023
258b640
Docs: Simplify Unit Test names
simmsa Dec 8, 2023
75416a5
Docs: Move Python/MATLAB compatibility into Installation section
simmsa Dec 8, 2023
da93637
Docs: Use more common header format
simmsa Dec 8, 2023
d5cf658
Actions: Compare tests on MATLAB 2023b vs latest
simmsa Dec 8, 2023
9796395
Tests: Re-enable Wave_TestIO assumeFail tests
simmsa Dec 8, 2023
5d5d6bc
Actions: Skips testing macos/MATLAB R2023b.
simmsa Dec 8, 2023
4329be7
Docs: Clarify installation language
simmsa Dec 8, 2023
462e0a4
Docs: Duplicate project information from MHKiT-Python
simmsa Dec 8, 2023
9bb1ac8
Docs: Capitalize headers
simmsa Dec 8, 2023
9dc82f1
Docs: Clarify software compatibility section
simmsa Dec 8, 2023
cd168ff
Tests: Remove old test report
simmsa Dec 8, 2023
a41af13
Coverage: Add latest test report
simmsa Dec 8, 2023
0af0b2d
Ignore: hindcast download cache
simmsa Dec 8, 2023
b8aa8c3
dolfyn: fix typo in `AnaIn1` definition
simmsa Dec 8, 2023
1777254
MATLAB: Generate toolbox for version 0.4.1
simmsa Dec 8, 2023
6005607
Docs: Streamline installation wording
simmsa Dec 8, 2023
2344cd3
Docs: Add section on Unit Testing
simmsa Dec 14, 2023
576b406
Docs: Add legend to MATLAB/Python compatibility table
simmsa Dec 14, 2023
21251bc
Docs: Add notes about GitHub action failures
simmsa Dec 14, 2023
fd09f7d
Docs: Add footnote detailing Action errors
simmsa Dec 14, 2023
e6054dc
Docs: Clarify unit test documentation
simmsa Dec 15, 2023
3e478fa
Docs: Make legend easier to read
simmsa Dec 15, 2023
dada13d
Docs: Remove redundant unit test disclaimer
simmsa Dec 15, 2023
6b744e7
Docs: Add "Development Notes" section
simmsa Dec 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
61 changes: 0 additions & 61 deletions .github/workflows/unit_tests.yml

This file was deleted.

323 changes: 323 additions & 0 deletions .github/workflows/unix_unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,323 @@
name: MHKiT-MATLAB Unix Unit Tests

on:
push:
branches: [master, develop, ebbflood]
pull_request:
branches: [master, develop, ebbflood]

jobs:
cache_population:
strategy:
fail-fast: false

matrix:
os: [ubuntu-latest]
python-version: ["3.10"]
matlab-version: [R2022b]

runs-on: ${{ matrix.os }}

env:
mhkit-python-dir: "MHKiT-Python"
steps:
- name: Check out MHKiT-MATLAB
uses: actions/checkout@v4

- name: Check out MHKiT-Python
uses: actions/checkout@v4
with:
repository: "MHKiT-Software/MHKiT-Python"
path: ${{env.mhkit-python-dir}}

- name: Install & Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: MHKIT_CONDA_ENV
channels: conda-forge

- name: Setup Python ${{ matrix.python-version }}
shell: bash -l {0}
run: |
conda create --name MHKIT_CONDA_ENV python=${{ matrix.python-version }} numpy cython pip pytest hdf5 libnetcdf cftime openssl --strict-channel-priority
conda activate MHKIT_CONDA_ENV
conda install -c conda-forge netcdf4
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config
pip install -e . --no-deps --force-reinstall

- name: pip install mhkit module from source
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
pip install -e .
working-directory: ${{env.mhkit-python-dir}}

- name: pip install mhkit-python-utils module from source
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
pip install -e .

# Create the cache and add a dummy file
# The dummy file ensures that the artifact download
- name: Setup mhkit_webread_cache
shell: bash -l {0}
run: |
mkdir mhkit_webread_cache
touch mhkit_webread_cache/test.txt
echo "Hello World" > mhkit_webread_cache/test.txt

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
with:
release: ${{ matrix.matlab-version }}

# OutOfProcess is required to properly call netcdf/hdf5 and works reliably on macos and ubuntu
- name: Configure MATLAB Python Environment
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
printf 'pyenv(Version="%s", ExecutionMode="OutOfProcess")\n' $(python -c "import sys; print(sys.executable)") > run.m

- name: Add MATLAB test commands
shell: bash
run: echo "version,
addpath(genpath('mhkit')),
import matlab.unittest.TestSuite,
import matlab.unittest.TestRunner,
testFolder = ['mhkit' filesep 'tests'],
suite = TestSuite.fromFolder(testFolder),
runner = TestRunner.withTextOutput,
results = runner.run(suite),
assertSuccess(results)" >> run.m

- name: Output run.m
shell: bash
run: cat run.m

- name: Run MATLAB Unit Tests
uses: matlab-actions/run-command@v1
with:
command: run
startup-options: -noFigureWindows

- name: Save mhkit_webread_cache directory as an artifact
uses: actions/upload-artifact@v3
with:
# GitHub Action "Name" of artifact
name: mhkit_webread_cache
# Filesystem path of directory
path: mhkit_webread_cache

main:
needs: cache_population
strategy:
fail-fast: false

# Expecting 2 * 4 * 7 - (13 * 2) = 30 jobs
matrix:
os: [macos-latest, ubuntu-latest]
python-version: [3.8, 3.9, "3.10", 3.11]
# Note: It is preferred to use an actual release name as opposed to 'latest'
matlab-version: [R2021b, R2022a, R2022b, R2023a, R2023b]
exclude:
# cache_population job
- python-version: "3.10"
matlab-version: R2022b
os: ubuntu-latest
# Non compatiable MATLAB/Python Versions according to Mathworks
- matlab-version: R2023b
python-version: 3.8
- matlab-version: R2023a
python-version: 3.11
- matlab-version: R2022b
python-version: 3.11
- matlab-version: R2022a
python-version: 3.11
- matlab-version: R2022a
python-version: "3.10"
- matlab-version: R2021b
python-version: 3.11
- matlab-version: R2021b
python-version: "3.10"
- matlab-version: R2021a
python-version: 3.11
- matlab-version: R2021a
python-version: "3.10"
- matlab-version: R2021a
python-version: 3.9
- matlab-version: R2020b
python-version: 3.11
- matlab-version: R2020b
python-version: "3.10"
- matlab-version: R2020b
python-version: 3.9
# Combinations with failing tests that seem related to GitHub Actions
- matlab-version: R2023b
os: macos-latest

runs-on: ${{ matrix.os }}

env:
mhkit-python-dir: "MHKiT-Python"
steps:
- name: Check out MHKiT-MATLAB
uses: actions/checkout@v4

- name: Check out MHKiT-Python
uses: actions/checkout@v4
with:
repository: "MHKiT-Software/MHKiT-Python"
path: ${{env.mhkit-python-dir}}

# - name: Setup Conda
# uses: s-weigand/setup-conda@v1
# with:
# activate-conda: false
# conda-channels: conda-forge

- name: Install & Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: MHKIT_CONDA_ENV
channels: conda-forge

- name: Setup Python ${{ matrix.python-version }}
shell: bash -l {0}
run: |
conda create --name MHKIT_CONDA_ENV python=${{ matrix.python-version }} numpy cython pip pytest hdf5 libnetcdf cftime netcdf4 --strict-channel-priority
conda activate MHKIT_CONDA_ENV
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config
pip install -e . --no-deps --force-reinstall

# - name: Setup Python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}

# - name: Setup MHKiT Dependencies on macOS
# run: brew install hdf5 netcdf
# if: ${{ matrix.os == 'macos-latest' }}

# - name: Setup MHKiT Dependencies on ubuntu
# run: sudo apt install libhdf5-serial-dev libnetcdf-dev
# if: ${{ matrix.os == 'ubuntu-latest' }}

# - name: Setup MHKiT Dependencies on ubuntu
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: |
# sudo apt update
# sudo apt upgrade
# sudo apt install build-essential

# - name: Print GCC Version
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: |
# gcc --version
# g++ --version

# - name: Setup MATLAB Path on Ubuntu
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: echo "export LD_LIBRARY_PATH=/usr/local/MATLAB/${{ matrix.matlab-version }}/sys/os/glnxa64" >> "$GITHUB_ENV"

- name: Setup MATLAB Path on Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' }}
run: echo "LD_PRELOAD=/lib/x86_64-linux-gnu/libstdc++.so.6" >> "$GITHUB_ENV"

- name: Print Python executable
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
python -c "import sys; print(sys.executable)"

- name: Print Python Version
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
python --version

- name: pip install mhkit module from source
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
pip install -e .
working-directory: ${{env.mhkit-python-dir}}

- name: pip install mhkit-python-utils module from source
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
pip install -e .

- name: List installed pip modules
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
pip freeze

- name: Print MHKiT-Python Version
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
python -c "import mhkit; print(mhkit.__version__)"

- name: Verify MHKiT-Python Operation
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
python -c "import mhkit; [ED, AP] = mhkit.river.performance.circular(30); print(ED); print(AP);"

- name: Download mhkit_webread_cache artifact
uses: actions/download-artifact@v3
with:
name: mhkit_webread_cache
path: mhkit_webread_cache

- name: Display structure mhkit_webread_cache
run: ls -R
working-directory: .

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2-beta
with:
release: ${{ matrix.matlab-version }}

# OutOfProcess is required to properly call netcdf/hdf5 and works reliably on macos and ubuntu
- name: Configure MATLAB Python Environment
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
printf 'pyenv(Version="%s", ExecutionMode="OutOfProcess")\n' $(python -c "import sys; print(sys.executable)") > run.m

- name: Add MATLAB test commands
shell: bash
run: echo "version,
addpath(genpath('mhkit')),
import matlab.unittest.TestSuite,
import matlab.unittest.TestRunner,
testFolder = ['mhkit' filesep 'tests'],
suite = TestSuite.fromFolder(testFolder),
runner = TestRunner.withTextOutput,
results = runner.run(suite),
assertSuccess(results)" >> run.m

- name: Output run.m
shell: bash
run: cat run.m

# This is a good idea but does not work because you cannot explicitly set the python execution mode
# - name: Run MHKiT-MATLAB Unit Tests
# uses: matlab-actions/run-tests@v1
# with:
# select-by-folder: mhkit/tests

- name: Run MATLAB Unit Tests
uses: matlab-actions/run-command@v1
with:
command: run
startup-options: -noFigureWindows

Loading