Skip to content
Draft
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
18 changes: 17 additions & 1 deletion .github/actions/check-code/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,25 @@ inputs:
runs:
using: "composite"
steps:
- name: Check if buildfile exists
id: check-buildfile
shell: bash
run: |
if [ -f "buildfile.m" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi

- name: Check for MATLAB code issues (buildtool)
if: steps.check-buildfile.outputs.exists == 'true'
uses: matlab-actions/run-build@v2
with:
tasks: check

- name: Check for MATLAB code issues
if: steps.check-buildfile.outputs.exists != 'true'
uses: matlab-actions/run-command@v2
if: always()
with:
command: |
addpath(genpath("${{ inputs.tools_directory }}"));
Expand Down
18 changes: 17 additions & 1 deletion .github/actions/test-code/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,25 @@ inputs:
runs:
using: "composite"
steps:
- name: Check if buildfile exists
id: check-buildfile
shell: bash
run: |
if [ -f "buildfile.m" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi

- name: Run tests (buildtool)
if: steps.check-buildfile.outputs.exists == 'true'
uses: matlab-actions/run-build@v2
with:
tasks: test

- name: Run MATLAB test suites
if: steps.check-buildfile.outputs.exists != 'true'
uses: matlab-actions/run-command@v2
if: always()
with:
command: |
addpath(genpath("${{ inputs.tools_directory }}"));
Expand Down
37 changes: 37 additions & 0 deletions buildfile.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function plan = buildfile
%buildfile - Build configuration for MatBox CI tasks
%
% Defines tasks for continuous integration using MATLAB's buildtool.
% Available tasks:
% buildtool setup - Install MatBox and set up paths
% buildtool check - Identify code issues
% buildtool test - Run tests with code coverage
%
% Requires MATLAB R2023b or later.

import matlab.buildtool.tasks.CodeIssuesTask
import matlab.buildtool.tasks.TestTask

plan = buildplan(localfunctions);

plan("setup").Description = "Install MatBox and set up paths";

plan("check") = CodeIssuesTask("code");
plan("check").Description = ...
"Identify code issues using MATLAB code analyzer";
plan("check").Dependencies = "setup";

plan("test") = TestTask( ...
Tests="tools/tests", ...
SourceFiles="code");
plan("test").Description = "Run tests with code coverage";
plan("test").Dependencies = "setup";

plan.DefaultTasks = ["check", "test"];
end

function setupTask(~)
%setupTask - Install MatBox and add tools to MATLAB path
addpath(genpath("tools"));
installMatBox();
end
42 changes: 42 additions & 0 deletions code/templates/buildfile.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
function plan = buildfile
%buildfile - Build configuration for toolbox CI tasks
%
% Defines tasks for continuous integration using MATLAB's buildtool.
% Available tasks:
% buildtool setup - Set up paths and install dependencies
% buildtool check - Identify code issues
% buildtool test - Run tests with code coverage
%
% Requires MATLAB R2023b or later.
%
% Note: Adapt the source and test folder paths to match your project
% structure.

import matlab.buildtool.tasks.CodeIssuesTask
import matlab.buildtool.tasks.TestTask

plan = buildplan(localfunctions);

plan("setup").Description = "Set up paths and install dependencies";

plan("check") = CodeIssuesTask("code");
plan("check").Description = ...
"Identify code issues using MATLAB code analyzer";
plan("check").Dependencies = "setup";

plan("test") = TestTask( ...
Tests="tools/tests", ...
SourceFiles="code");
plan("test").Description = "Run tests with code coverage";
plan("test").Dependencies = "setup";

plan.DefaultTasks = ["check", "test"];
end

function setupTask(~)
%setupTask - Set up MATLAB path and install dependencies
addpath(genpath("tools"));
if exist("installMatBox", "file")
installMatBox();
end
end