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

Add tests for FAST_SFunc using Matlab action to integrate with CI #1703

Merged
merged 26 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1227fdb
Merge branch 'OpenFAST:dev' into dev
reos-rcrozier Jan 19, 2023
a1ed19f
Merge branch 'OpenFAST:dev' into dev
reos-rcrozier Jan 24, 2023
5657f25
Added workflow-dispatch
reos-rcrozier Jan 24, 2023
cdf2ed0
Revert "Added workflow-dispatch"
reos-rcrozier Jan 25, 2023
c67ed7b
automated-dev-tests.yml: add Matlab runner and build simulink API
reos-rcrozier Jul 25, 2023
7b55642
Create test_openfast_simulink.m
reos-rcrozier Jul 25, 2023
ab24635
Update test_openfast_simulink.m
reos-rcrozier Jul 25, 2023
1bee16b
Update automated-dev-tests.yml
reos-rcrozier Jul 26, 2023
a1b1877
Update automated-dev-tests.yml
reos-rcrozier Jul 26, 2023
01e64ca
automated-dev-tests.yml: fix matlab source-directories
reos-rcrozier Jul 26, 2023
618d4ee
Update test_openfast_simulink.m
reos-rcrozier Jul 26, 2023
808f391
Update test_openfast_simulink.m
reos-rcrozier Jul 26, 2023
6b880ef
Update automated-dev-tests.yml
reos-rcrozier Jul 26, 2023
1758459
Update automated-dev-tests.yml
reos-rcrozier Jul 26, 2023
e0d963b
Merge branch 'dev' of https://github.com/Reoptimize-Systems/openfast …
reos-rcrozier Jul 26, 2023
8ff7da3
Update CMakeLists.txt
reos-rcrozier Jul 27, 2023
8711772
Update simulink CMakeLists.txt
reos-rcrozier Jul 27, 2023
4f69111
Update simulink CMakeLists.txt
reos-rcrozier Jul 27, 2023
d55ff50
Update simulink CMakeLists.txt
reos-rcrozier Jul 27, 2023
587f533
Merge remote-tracking branch 'upstream/dev' into Reoptimize Systems/dev
reos-rcrozier Aug 1, 2023
b1b1519
Update simulink CMakeLists.txt
reos-rcrozier Aug 1, 2023
f8b05c9
Update automated-dev-tests.yml
reos-rcrozier Aug 1, 2023
abd0b55
Update simulin CMakeLists.txt
reos-rcrozier Aug 1, 2023
d2e691b
Update simulink CMakeLists.txt
reos-rcrozier Aug 1, 2023
bed2c7a
Update automated-dev-tests.yml
reos-rcrozier Aug 2, 2023
170616d
Update automated-dev-tests.yml
reos-rcrozier Aug 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/automated-dev-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
with:
python-version: '3.9'
cache: 'pip'
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -67,6 +69,7 @@ jobs:
-DVARIABLE_TRACKING=OFF \
-DBUILD_TESTING:BOOL=ON \
-DCTEST_PLOT_ERRORS:BOOL=ON \
-DBUILD_OPENFAST_SIMULINK_API=ON \
${GITHUB_WORKSPACE}
# -DDOUBLE_PRECISION=OFF \
- name: Build all
Expand Down Expand Up @@ -175,6 +178,8 @@ jobs:
with:
python-version: '3.9'
cache: 'pip'
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -203,6 +208,7 @@ jobs:
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DBUILD_TESTING:BOOL=ON \
-DCTEST_PLOT_ERRORS:BOOL=ON \
-DBUILD_OPENFAST_SIMULINK_API=ON \
${GITHUB_WORKSPACE}
- name: Build openfast-postlib
working-directory: ${{runner.workspace}}/openfast/build
Expand Down Expand Up @@ -612,6 +618,36 @@ jobs:
!${{runner.workspace}}/openfast/build/reg_tests/glue-codes/openfast/WP_Baseline


rtest-OF-simulink:
runs-on: ubuntu-22.04
needs: build-openfast-release
steps:
- name: Cache the workspace
uses: actions/cache@v3.0.4
with:
path: ${{runner.workspace}}
key: build-openfast-release-${{ github.sha }}
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y libhdf5-dev libopenmpi-dev libyaml-cpp-dev libopenblas-dev libopenblas-openmp-dev
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Build FAST_SFunc
working-directory: ${{runner.workspace}}/openfast/build
run: |
cmake \
-DUSE_LOCAL_STATIC_LAPACK:BOOL=ON \
${GITHUB_WORKSPACE}
cmake --build . --target FAST_SFunc
- name: Run MATLAB tests and generate artifacts
uses: matlab-actions/run-tests@v1
with:
source-folder: ${{runner.workspace}}/openfast/build/glue-codes/simulink; ${{runner.workspace}}/openfast/glue-codes/simulink/examples
test-results-junit: test-results/results.xml
code-coverage-cobertura: code-coverage/coverage.xml


rtest-OF-5MW_OC4Semi_WSt_WavesWN:
runs-on: ubuntu-22.04
needs: build-openfast-release
Expand Down
7 changes: 4 additions & 3 deletions glue-codes/simulink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ set(MEX_LIBS
$<TARGET_FILE:sctypeslib>
$<TARGET_FILE:servodynlib-matlab> # MATLAB Specific
$<TARGET_FILE:subdynlib>
$<TARGET_FILE:foamfastlib>
$<TARGET_FILE:extinflowlib>
$<TARGET_FILE:ifwlib>
$<TARGET_FILE:scfastlib>
$<TARGET_FILE:foamtypeslib>
$<TARGET_FILE:extinflowtypeslib>
$<TARGET_FILE:versioninfolib>
$<TARGET_FILE:nwtclibs-matlab> # MATLAB Specific
$<TARGET_FILE:seastlib>
)

# Build the matlab shared library (mex) using the current toolchain.
Expand Down Expand Up @@ -69,7 +70,7 @@ set_target_properties(FAST_SFunc PROPERTIES
Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/matlab)
target_include_directories(FAST_SFunc PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/modules/openfast-library/src>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/modules/openfoam/src>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/modules/externalinflow/src>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/modules/supercontroller/src>
)
if(APPLE OR UNIX)
Expand Down
31 changes: 31 additions & 0 deletions glue-codes/simulink/examples/test_openfast_simulink.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
%% Test OpenFAST Simulink Interface
classdef test_openfast_simulink < matlab.unittest.TestCase

%% Test Method Block
methods (Test)

function testOpenLoopRuns(testCase)

workspace_root = getenv("GITHUB_WORKSPACE");

this_file_path = fileparts(which(mfilename()));

cd(this_file_path);

% these variables are defined in the OpenLoop model's FAST_SFunc block:
FAST_InputFileName = fullfile(workspace_root, 'reg_tests', 'r-test', 'glue-codes', 'openfast', 'AOC_WSt', 'AOC_WSt.fst');
TMax = 5; % seconds

mdl = "OpenLoop";

%simIn = Simulink.SimulationInput(mdl);
%simIn = setBlockParameter(simIn, "sldemo_househeat/Set Point", "Value", FAST_InputFileName);

assignin("base", "FAST_InputFileName", FAST_InputFileName);
assignin("base", "TMax", TMax);

sim(mdl, [0,TMax]);

end
end
end
Loading