Skip to content

Commit

Permalink
Embed examples directly in repo (#42)
Browse files Browse the repository at this point in the history
* Embed examples directly in repo

* Remove matrix from v1 and use *-latest

* Use *-latest on Azure and re-enable email
  • Loading branch information
mcafaro authored Oct 14, 2024
1 parent 1334715 commit cfd4d6f
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 17 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ orbs:
jobs:
build:
machine:
image: ubuntu-2204:2024.01.1
image: ubuntu-2204:current
steps:
- checkout
- matlab/install
- matlab/install:
products: Optimization_Toolbox Curve_Fitting_Toolbox
- matlab/run-tests:
source-folder: code

Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
# Run this workflow on different os
os: [windows-2022, ubuntu-22.04, macos-12]
os: [ubuntu-latest]
fail-fast: false
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
strategy:
matrix:
# Run this workflow on different os
os: [windows-2022, ubuntu-22.04, macos-12, macos-14]
os: [windows-latest, ubuntu-latest, macos-latest, macos-13]
fail-fast: false
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
Expand All @@ -65,6 +65,8 @@ jobs:
# Sets up MATLAB on the GitHub Actions runner
- name: Setup MATLAB
uses: matlab-actions/setup-matlab@v2
with:
products: Optimization_Toolbox Curve_Fitting_Toolbox

# Runs a set of commands using the runners shell
- name: Run tests and generate artifacts
Expand All @@ -90,7 +92,7 @@ jobs:
strategy:
matrix:
# Run this workflow on different os
os: [ubuntu-22.04] # [windows-2022, ubuntu-22.04, macos-12] restore when Windows and Mac are working again (ETA mid-October 2023)
os: [windows-latest, ubuntu-latest, macos-latest, macos-13]
fail-fast: false
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
Expand All @@ -105,6 +107,7 @@ jobs:
- name: Setup MATLAB
uses: matlab-actions/setup-matlab@v2
with:
products: Optimization_Toolbox Curve_Fitting_Toolbox
cache: true

# Runs a set of commands using the runners shell
Expand Down
4 changes: 3 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
pool:
vmImage: ubuntu-22.04
vmImage: ubuntu-latest
steps:
- task: InstallMATLAB@1
inputs:
products: Optimization_Toolbox Curve_Fitting_Toolbox
- task: RunMATLABTests@1
inputs:
sourceFolder: code
Expand Down
Binary file added examples/census.mat
Binary file not shown.
Binary file added examples/curve_fitting_toolbox.mlx
Binary file not shown.
3 changes: 3 additions & 0 deletions examples/disk.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function radsqr = disk(x)

radsqr = x(1)^2 + x(2)^2;
Binary file added examples/matlab.mlx
Binary file not shown.
Binary file added examples/optimization_toolbox.mlx
Binary file not shown.
30 changes: 19 additions & 11 deletions tinstall.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
'optimization_toolbox', 'symbolic_toolbox', 'image_toolbox', 'control_toolbox', ...
'signal_blocks', 'curve_fitting_toolbox'}
restricted = {'rtw_embedded_coder', 'filter_design_hdl_coder', 'gpu_coder', ...
'simulink_hdl_coder', 'matlab_coder', 'real-time_workshop', 'simulink_plc_coder'}
example = {'matlab/intro', 'optim/SolveAConstrainedNonlinearProblemProblemBasedExample', ...
'curvefit/FitPolynomialExample', 'simulink_general/sldemo_bounceExample'}
'simulink_hdl_coder', 'matlab_coder', 'simulink_plc_coder', 'matlab_excel_builder', ...
'compiler', 'matlab_builder_for_java', 'matlab_builder_for_dot_net', ...
'polyspace_client_c_cpp', 'simulink_compiler'}
% Add to restricted list once licensing server is fixed (a few weeks after 10/7/24)
% 'simulink_code_inspector', 'simulink_design_verifier', 'real-time_workshop'
example = {'matlab', 'optimization_toolbox', 'curve_fitting_toolbox'}
end

methods (Test)
Expand All @@ -25,15 +28,12 @@ function testFailToCheckoutRestrictedLicense(testCase, restricted)
end

function testRunExample(testCase, example)
meta = findExample(example);
testCase.assumeTrue(isfolder(fullfile(meta.componentDir, 'main')), 'Demo not available');

testCase.applyFixture(PathFixture(meta.componentDir));
testCase.verifyTrue(isInstalled(example), 'Product not installed');

startingFigs = findall(groot, 'Type','figure');
testCase.addTeardown(@() close(setdiff(findall(groot, 'Type','figure'), startingFigs)));

[log, ex] = evalc('runDemo(fullfile(meta.componentDir, ''main'', meta.main));');
[log, ex] = evalc('runExample(fullfile(''examples'',example));');
if ~isempty(ex)
disp(log);
rethrow(ex);
Expand All @@ -43,21 +43,29 @@ function testRunExample(testCase, example)

end

function ex = runDemo(demo) %#ok<DEFNU> evalc
function ex = runExample(example)
try
run(demo)
ex = MException.empty;
run(example)
ex = MException.empty;
catch ex
end
end

function tf = isInstalled(productName)
v = ver();
n = strrep(productName, '_', ' ');
tf = any(strcmpi(n, {v.Name}));
end

% imports
function c = IsTrue(varargin)
c = matlab.unittest.constraints.IsTrue(varargin{:});
end

function c = IsFalse(varargin)
c = matlab.unittest.constraints.IsFalse(varargin{:});
end

function c = PathFixture(varargin)
c = matlab.unittest.fixtures.PathFixture(varargin{:});
end

0 comments on commit cfd4d6f

Please sign in to comment.