Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
52 changes: 46 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# This is a basic workflow to help you get started with MATLAB Actions
name: CI
name: MATLAB Build

# Controls when the action will run.
on:
# Triggers the workflow on pull request events, but only for the main branch
# Triggers the workflow on push or pull request events, but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
PRODUCT_LIST: MATLAB MATLAB_Test SimBiology Statistics_and_Machine_Learning_Toolbox
PRODUCT_LIST: MATLAB MATLAB_Test

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
Expand All @@ -22,15 +24,20 @@ permissions:
# Only allow one build of this type to run at a time
# Ensure results publishing completes without being interrupted/overwritten
concurrency:
group: "test"
group: "test and publish results"
cancel-in-progress: false

jobs:
# This workflow contains a single job called "build"
build:

test:
# Set up URLs for GitHub Pages report
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# The type of runner that the job will run on
runs-on: windows-latest
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand All @@ -50,3 +57,36 @@ jobs:
uses: matlab-actions/run-build@v2
with:
tasks: test

# Configure GitHub Pages to accept your artifact uploads
- name: Setup Pages
uses: actions/configure-pages@v5

# Upload testing and code coverage reports to your repository
- name: Upload pages
uses: actions/upload-pages-artifact@v4
with:
path: results # Upload results

# Publish reports to GitHub Pages so they can be viewed in a browser
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4



# ==================================== #
# Alternate ways to run commands in CI #
# ==================================== #

## Runs your tests using `runtests` command
#- name: Run all tests
# uses: matlab-actions/run-tests@v2
# with:
# source-folder: code

## Executes custom MATLAB scripts, functions, or statements
#- name: Run custom testing procedure
# uses: matlab-actions/run-command@v2
# with:
# command: disp('Running my custom testing procedure!'); addpath('code'); results = runtests('IncludeSubfolders', true); assertSuccess(results);
99 changes: 0 additions & 99 deletions .github/workflows/deploy.yml

This file was deleted.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[![MATLAB](https://github.com/ChezJe/MATLAB-SimBiology-DevOps-Workflow-Example/actions/workflows/ci.yml/badge.svg)](https://github.com/ChezJe/MATLAB-SimBiology-DevOps-Workflow-Example/actions/workflows/deploy.yml)
[![MATLAB](https://github.com/ChezJe/MATLAB-SimBiology-DevOps-Workflow-Example/actions/workflows/ci.yml/badge.svg)](https://github.com/ChezJe/MATLAB-SimBiology-DevOps-Workflow-Example/actions/workflows/ci.yml)
[![Tests](https://img.shields.io/badge/Tests-Open_Test_Report-blue)](https://ChezJe.github.io/MATLAB-SimBiology-DevOps-Workflow-Example/tests/)
[![Coverage](https://img.shields.io/badge/Coverage-Open_Code_Coverage_Report-orange)](https://ChezJe.github.io/MATLAB-SimBiology-DevOps-Workflow-Example/coverage/)

# MATLAB<sup>&reg;</sup>/SimBiology<sup>&reg;</sup> DevOps Workflow Example
# Generating Tests for Your MATLAB<sup>&reg;</sup> Code Workshop

This workshop provides hands-on experience using some of MATLAB's powerful software testing and automation features.
<br><br>

## About the workshop
This hands-on workshop will guide you through:
* forking your own copy of the "MATLAB-SimBiology-DevOps-Workflow-Example" repository on GitHub
* forking your own copy of the "Generating Tests for Your MATLAB Code Workshop" repository on GitHub
* generating tests using your command history and MATLAB Copilot
* automatically finding and running existing tests
* measuring and exploring code coverage metrics for your code
Expand All @@ -26,4 +26,6 @@ Step-by-step workshop instructions can be found in:
* [WorkshopGuide.m](WorkshopGuide.m)
<br><br>



Copyright 2025 The MathWorks, Inc.
7 changes: 4 additions & 3 deletions buildfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
% CodeIssues task
plan("check") = CodeIssuesTask(Results=["results/codeissues.sarif"; ...
"results/codeissues.mat"]);

% Test task
tTask = TestTask("tests", ...
SourceFiles = "code", ...
Expand All @@ -33,7 +34,7 @@
plan("generateSimFun").Inputs = fullfile(proj.RootFolder,"code","*.sbproj");
plan("generateSimFun").Outputs = fullfile(proj.RootFolder,"code","*.mat");
plan("test").Inputs = fullfile(proj.RootFolder,"code","*");
plan("compile").Inputs = fullfile(proj.RootFolder,"code",["*.mat","*.mlapp","*.m"]);
plan("compile").Inputs = fullfile(proj.RootFolder,"code",["*.mat","*.mlapp","graystyle.m"]);
plan("compile").Outputs = fullfile(proj.RootFolder,"WebAppArchive");

% Set default task
Expand Down Expand Up @@ -61,9 +62,9 @@ function compileTask(~)

MATfilename = dir(fullfile(rootFolder,"code","*.mat"));
MATfilename = fullfile(rootFolder,"code",MATfilename.name);
s = load(MATfilename,"dependenciesSimFun");
load(MATfilename,"dependenciesSimFun");

appDependencies = [MATfilename; s.dependenciesSimFun; ...
appDependencies = [MATfilename; dependenciesSimFun; ...
codeFiles; imgFiles];
appfilename = fullfile(rootFolder,"code","TMDDApp.mlapp");

Expand Down
20 changes: 7 additions & 13 deletions code/ConcTimecourseView.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

properties ( Access = private )
Model
Axes

ConcColors = [0.30,0.75,0.93;...
0.86,0.55,0.41;...
0.91,0.73,0.42]; % colors to plot concentrations
FontName = "Helvetica";
end

properties ( Hidden )
% Leave these properties Hidden but public to enable access for any test generated
% with Copilot during workshop
Axes

properties ( SetAccess=private, GetAccess={?tTMDDApp} )
% line handles
lhDrug
lhReceptor
Expand All @@ -38,16 +35,13 @@
xlabel(ax, "Time (hours)", 'FontName',obj.FontName);
ylabel(ax, "Concentrations (nanomole/liter)",'FontName',obj.FontName);

obj.lhDrug = plot(ax, NaN, NaN, '-','Linewidth',2,'Color',obj.ConcColors(1,:),'DisplayName','Drug');
obj.lhDrug = plot(ax, NaN, NaN, '-','Linewidth',2,'Color',obj.ConcColors(1,:));
hold(ax,'on');
obj.lhReceptor = plot(ax, NaN, NaN, '-','Linewidth',2,'Color',obj.ConcColors(2,:),'DisplayName','Receptor');
obj.lhComplex= plot(ax, NaN, NaN, '-','Linewidth',2,'Color',obj.ConcColors(3,:),'DisplayName','Complex');
obj.lhReceptor = plot(ax, NaN, NaN, '-','Linewidth',2,'Color',obj.ConcColors(2,:));
obj.lhComplex= plot(ax, NaN, NaN, '-','Linewidth',2,'Color',obj.ConcColors(3,:));
hold(ax,'off');
lgd = legend(ax,'show','FontName',obj.FontName,'Color','none');
lgd.Box = "off";

ax.XLimitMethod = "padded";
ax.YLimitMethod = "padded";
lh = legend(ax,{'Drug','Receptor','Complex'},'FontName',obj.FontName);
lh.Box = 'off';

% instantiate listener
dataListener = event.listener( model, 'DataChanged', ...
Expand Down
4 changes: 1 addition & 3 deletions code/LampView.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
LampColorFailure = [0.85, 0.33, 0.10] % color of lamp if RO not between thresholds after day 1
end

properties ( Hidden )
% Leave these properties Hidden but public to enable access for any test generated
% with Copilot during workshop
properties ( SetAccess=private, GetAccess={?tTMDDApp} )
LampObj
end

Expand Down
4 changes: 1 addition & 3 deletions code/NCAView.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

end

properties ( Hidden )
% Leave these properties Hidden but public to enable access for any test generated
% with Copilot during workshop
properties ( SetAccess=private, GetAccess={?tTMDDApp} )
NCAtable
end

Expand Down
11 changes: 4 additions & 7 deletions code/ROTimecourseView.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
'FontWeight','bold','LabelVerticalAlignment','middle'}; % style for threshold lines
end

properties ( Hidden, SetAccess=private)
% Leave these properties Hidden but public to enable access for any test generated
% with Copilot during workshop

properties ( GetAccess = {?tTMDDApp} )
% line handles
lhRO
end
Expand Down Expand Up @@ -42,12 +39,12 @@
ylabel(ax, "RO (%)",'FontName',obj.FontName);

obj.lhRO = plot(ax, NaN, NaN, 'Color', obj.ROColors,'Linewidth',2);
% yline(ax,model.ThresholdValues(1), '--','efficacy','FontName',obj.FontName,obj.ThresholdStyle{:});
% yline(ax,model.ThresholdValues(2), '--','safety','FontName',obj.FontName,obj.ThresholdStyle{:});
yline(ax,model.ThresholdValues(1), '--','efficacy','FontName',obj.FontName,obj.ThresholdStyle{:});
yline(ax,model.ThresholdValues(2), '--','safety','FontName',obj.FontName,obj.ThresholdStyle{:});


% set limits
ax.XLimitMethod = "padded";
xlim(ax,'auto');
ylim(ax,[-5, 105]);

% instantiate listener
Expand Down
Loading
Loading