Skip to content

Commit

Permalink
Prep
Browse files Browse the repository at this point in the history
  • Loading branch information
acampbel committed Mar 21, 2024
1 parent f33885c commit 774effb
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 70 deletions.
68 changes: 34 additions & 34 deletions .github/workflows/matlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

env:
PRODUCT_LIST: MATLAB MATLAB_Test MATLAB_Compiler MATLAB_Compiler_SDK
MLM_LICENSE_TOKEN: ${{secrets.MLM_LICENSE_TOKEN}}
# MLM_LICENSE_TOKEN: ${{secrets.MLM_LICENSE_TOKEN}}


jobs:
Expand Down Expand Up @@ -93,36 +93,36 @@ jobs:
path: release/Mass-Spring-Damper.mltbx


deploy-service:
# This job executes only after a successful completion of 'mex-and-unittests' job
needs: mex-and-unittests


runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup MATLAB
uses: matlab-actions/setup-matlab@v2
with:
release: R2024a
cache: true
products: ${{ env.PRODUCT_LIST }}

- name: Download Linux artifacts(to benefit from incremental build)
uses: actions/download-artifact@v4
with:
pattern: build-artifacts-ubuntu-latest
merge-multiple: true

- name: Build the ctf archive and run equivalence integration tests
uses: matlab-actions/run-build@v2
with:
tasks: deploy

- name: Upload Production Server Archive
uses: actions/upload-artifact@v4
with:
name: Mass-Spring-Damper Production Server Archive
path: results/glnxa64/ctf-archive
# deploy-service:
# # This job executes only after a successful completion of 'mex-and-unittests' job
# needs: mex-and-unittests
#
#
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v4
#
# - name: Setup MATLAB
# uses: matlab-actions/setup-matlab@v2
# with:
# release: R2024a
# cache: true
# products: ${{ env.PRODUCT_LIST }}
#
# - name: Download Linux artifacts(to benefit from incremental build)
# uses: actions/download-artifact@v4
# with:
# pattern: build-artifacts-ubuntu-latest
# merge-multiple: true
#
# - name: Build the ctf archive and run equivalence integration tests
# uses: matlab-actions/run-build@v2
# with:
# tasks: deploy
#
# - name: Upload Production Server Archive
# uses: actions/upload-artifact@v4
# with:
# name: Mass-Spring-Damper Production Server Archive
# path: results/glnxa64/ctf-archive
72 changes: 36 additions & 36 deletions buildfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,25 @@
Description="Produce a fully qualified toolbox for release");


%% Build a MATLAB Production Server archive
% Ad hoc task, task action defined in toolboxTask local function
plan("ctf").Dependencies = ["lint","test"];
plan("ctf").Inputs = ["code", "pcode", "buildutils/simulateSystemFunctionSignatures.json"];
plan("ctf").Outputs = [...
resultsFolder + "/ctf-archive/MassSpringDamperService.ctf", ...
resultsFolder + "/ctf-build-results.mat", ...
resultsFolder + "/ctf-archive"];
% %% Build a MATLAB Production Server archive
% % Ad hoc task, task action defined in toolboxTask local function
% plan("ctf").Dependencies = ["lint","test"];
% plan("ctf").Inputs = ["code", "pcode", "buildutils/simulateSystemFunctionSignatures.json"];
% plan("ctf").Outputs = [...
% resultsFolder + "/ctf-archive/MassSpringDamperService.ctf", ...
% resultsFolder + "/ctf-build-results.mat", ...
% resultsFolder + "/ctf-archive"];


%% Integration tests - back-to-back equivalence tests for the production server archive
plan("ctfIntegTest") = TestTask("integTests/equivalence",SourceFiles=["code","pcode"], ...
Description="Run integration tests against CTF archive.", ...
Dependencies="ctf");
% %% Integration tests - back-to-back equivalence tests for the production server archive
% plan("ctfIntegTest") = TestTask("integTests/equivalence",SourceFiles=["code","pcode"], ...
% Description="Run integration tests against CTF archive.", ...
% Dependencies="ctf");


%% Create the deploy task - does nothing but depends on other tasks
plan("deploy") = matlab.buildtool.Task(Dependencies="ctfIntegTest", ...
Description="Produce and test a ctf archive to deploy to a MATLAB Production Server");
% %% Create the deploy task - does nothing but depends on other tasks
% plan("deploy") = matlab.buildtool.Task(Dependencies="ctfIntegTest", ...
% Description="Produce and test a ctf archive to deploy to a MATLAB Production Server");


%% Produce HTML from workshop live scripts to publish to GitHub pages
Expand Down Expand Up @@ -163,27 +163,27 @@ function toolboxTask(context,version)
end


%% The "ctf" task action
function ctfTask(context)
% Create a deployable archive for MATLAB Production Server

ctfArchive = context.Task.Outputs(1).paths;
ctfBuildResults = context.Task.Outputs(2).paths;

% Create the archive options for the build.
[ctfFolder, ctfFile] = fileparts(ctfArchive);
opts = compiler.build.ProductionServerArchiveOptions(...
["code/simulateSystem.m", "pcode/springMassDamperDesign.m"], ...
FunctionSignatures="buildutils/simulateSystemFunctionSignatures.json", ...
OutputDir=ctfFolder, ...
ArchiveName=ctfFile, ...
ObfuscateArchive="on");

% Build the archive
buildResults = compiler.build.productionServerArchive(opts);

save(ctfBuildResults,"buildResults");
end
% %% The "ctf" task action
% function ctfTask(context)
% % Create a deployable archive for MATLAB Production Server
%
% ctfArchive = context.Task.Outputs(1).paths;
% ctfBuildResults = context.Task.Outputs(2).paths;
%
% % Create the archive options for the build.
% [ctfFolder, ctfFile] = fileparts(ctfArchive);
% opts = compiler.build.ProductionServerArchiveOptions(...
% ["code/simulateSystem.m", "pcode/springMassDamperDesign.m"], ...
% FunctionSignatures="buildutils/simulateSystemFunctionSignatures.json", ...
% OutputDir=ctfFolder, ...
% ArchiveName=ctfFile, ...
% ObfuscateArchive="on");
%
% % Build the archive
% buildResults = compiler.build.productionServerArchive(opts);
%
% save(ctfBuildResults,"buildResults");
% end


%% The "workshop" task action
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="test"/>
</Category>
</Info>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="untitled.m" type="File"/>
51 changes: 51 additions & 0 deletions untitled.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
classdef untitled < matlabtest.compiler.TestCase
properties(TestParameter)
% Can define different runtime inputs for the equivalence test
damping = struct(...
"OverDamped", 5e5, ...
"UnderDamped", 1e4, ...
"CriticallyDamped", 5.477225575051661e4)
end

properties(ClassSetupParameter)
buildDataFile = {};
end
properties
BuildResults
end

methods(TestClassSetup)
function filterOnMac(testCase)
testCase.assumeReturnsTrue(@() ~ismac, ...
"MPS equivalence tests not supported on the mac");
end
function loadBuildResults(testCase,buildDataFile)
loadedData = load(buildDataFile);
testCase.BuildResults = loadedData.buildResults;
end
end

methods (Test)
function mpsShouldBeEquivalentForDamping(testCase, damping)
% Validate that MPS execution is equivalent to MATLAB for
% various damping coefficient designs

% Execute the runtime inputs (damping) on the server
disp("Executing design on a local Production Server")
design.k = 5e5;
design.c = damping;
executionResults = testCase.execute(testCase.BuildResults,{design},"simulateSystem");

% Verify server execution is equivalent to the local results
disp("Verifying results match MATLAB results")
% Note: Fails due to a bug which is fixed in the R2024a GR
% testCase.verifyExecutionMatchesMATLAB(executionResults);

% Verification workaround - not needed in GR. Note this
% solution is not only less convenient, but also does not
% produce diagnostics as valuable as the above method
[x, t] = simulateSystem(design);
testCase.verifyEqual(executionResults.ExecutableOutput, {x, t});
end
end
end

0 comments on commit 774effb

Please sign in to comment.