From 4325966c5dec510a3cafa7f9f587bf3b48e588a5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:51:40 +0000 Subject: [PATCH 1/2] Initial plan From 776ec7737b1a9872b1e8b6f7db0e8cc39d555525 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 12:00:42 +0000 Subject: [PATCH 2/2] Add buildtool support with buildfile.m and updated GitHub Actions - Create buildfile.m at repository root with setup, check, and test tasks using MATLAB's CodeIssuesTask and TestTask - Create code/templates/buildfile.m as a template for other projects - Update check-code and test-code GitHub Actions to detect buildfile.m and use matlab-actions/run-build when available - Maintain backward compatibility with existing wrapper functions Co-authored-by: ehennestad <17237719+ehennestad@users.noreply.github.com> --- .github/actions/check-code/action.yml | 18 +++++++++++- .github/actions/test-code/action.yml | 18 +++++++++++- buildfile.m | 37 +++++++++++++++++++++++ code/templates/buildfile.m | 42 +++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 buildfile.m create mode 100644 code/templates/buildfile.m diff --git a/.github/actions/check-code/action.yml b/.github/actions/check-code/action.yml index 77e9921..998b263 100644 --- a/.github/actions/check-code/action.yml +++ b/.github/actions/check-code/action.yml @@ -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 }}")); diff --git a/.github/actions/test-code/action.yml b/.github/actions/test-code/action.yml index 0b784c5..78d419f 100644 --- a/.github/actions/test-code/action.yml +++ b/.github/actions/test-code/action.yml @@ -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 }}")); diff --git a/buildfile.m b/buildfile.m new file mode 100644 index 0000000..d002877 --- /dev/null +++ b/buildfile.m @@ -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 diff --git a/code/templates/buildfile.m b/code/templates/buildfile.m new file mode 100644 index 0000000..fb34beb --- /dev/null +++ b/code/templates/buildfile.m @@ -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