Skip to content

Change test workflow to reuse standard test workflow from MatBox #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 12, 2025
Merged
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
4 changes: 3 additions & 1 deletion .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Prepare toolbox release
on:
push:
tags:
- 'v*'
- 'v[0-9]+.[0-9]+.[0-9]+' # Matches tags like v1.2.3
workflow_dispatch:
inputs:
version:
Expand All @@ -29,6 +29,8 @@ jobs:
# Path to directory containing tools and MLToolboxInfo.json. Used for finding
# unit tests, running customized MatBox tasks, and determining toolbox metadata
tools_directory: tools

matlab_products: Statistics_and_Machine_Learning_Toolbox

secrets:
# SSH deploy key for pushing to protected branches. Required for creating
Expand Down
86 changes: 13 additions & 73 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,86 +7,26 @@ on:
paths-ignore:
- '*.md'
- '.github/workflows/**'
- 'docs/reports/**'
pull_request:
branches: [ "main" ]
paths-ignore:
- '*.md'
- '.github/workflows/**'
- 'docs/reports/**'

# Allows for manually running this workflow from the Actions tab
workflow_dispatch:

jobs:
# This workflow contains a single job called "test"
test:
name: Test toolbox code
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
- name: Check out repo
uses: actions/checkout@v4

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
with:
release: R2021b
products: Statistics_and_Machine_Learning_Toolbox

- name: Check for MATLAB code issues
uses: matlab-actions/run-command@v2
if: always()
with:
command: |
addpath(genpath("tools"));
codecheckToolbox()

- name: Run tests
uses: matlab-actions/run-command@v2
if: always()
with:
command: |
addpath(genpath("tools"));
testToolbox()
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# Commit updated SVG badges for the issues and tests (if changed)
- name: Commit SVG badges
if: always()
continue-on-error: true
run: |
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
git config user.email "<>"
git fetch

if [[ $(git add .github/badges/* --dry-run | wc -l) -gt 0 ]]; then
git add .github/badges/*
git commit -m "Update code issues and tests badges"
git push -f
else
echo "Nothing to commit"
fi

- name: Upload code coverage report to Codecov
uses: codecov/codecov-action@v4
if: always()
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: docs/reports/codecoverage.xml

- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: "docs/reports/test-results.xml"

# Save the contents of the reports directory as an artifact
- name: Save reports directory
uses: actions/upload-artifact@v4
if: always()
with:
name: reports
path: docs/reports
jobs:
call-reusable-test-toolbox-workflow:
name: Test and analyse code
uses: ehennestad/matbox/.github/workflows/[email protected]
with:
matlab_release: R2021b
matlab_use_cache: true
matlab_products: Statistics_and_Machine_Learning_Toolbox
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Ignore Mac DS_Store files and other known temporary files
.DS_Store
docs/reports/*
!docs/reports/badge
releases/
*.tmp
*.swp
Expand Down
2 changes: 1 addition & 1 deletion code/+did/database.m
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ function add_docs(database_obj, document_objs, branch_id, varargin)
% Optional PARAMETERS may be specified as P-V pairs of parameter name
% followed by parameter value. The following parameters are accepted:
% - 'OnDuplicate' - followed by 'ignore', 'warn', or 'error' (default)
% - 'Validate' - folowed by false or true (default)
% - 'Validate' - followed by false or true (default)

% Ensure we got a valid input doc object
if isempty(document_objs)
Expand Down
4 changes: 2 additions & 2 deletions code/+did/ido.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
% B = isvalid(ID)
%
% Returns true if ID matches the structure of a did.ido identifier and
% false otherwise. A valid ID must have 16 hexidecimal digits in
% 0-9 or a-f, an underscore, and then 16 more hexidecimal digits.
% false otherwise. A valid ID must have 16 hexadecimal digits in
% 0-9 or a-f, an underscore, and then 16 more hexadecimal digits.

try
id = char(id);
Expand Down
4 changes: 2 additions & 2 deletions code/Contents.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% Data Interface Database
% Version 0.7.9 (R2019b+) 17-Oct-2024
% Version 0.9.0 (R2019b+) 08-Jun-2025
%
% Copyright (c) 2024, VanHooser Lab
% Copyright (c) 2025, VanHooser Lab
% ---------------------------------
1 change: 0 additions & 1 deletion tools/tasks/codecheckToolbox.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function codecheckToolbox()
installMatBox("commit")
projectRootDirectory = didtools.projectdir();
matbox.tasks.codecheckToolbox(projectRootDirectory, "CreateBadge", false)
end
8 changes: 0 additions & 8 deletions tools/tasks/createTestedWithBadgeforToolbox.m

This file was deleted.

6 changes: 3 additions & 3 deletions tools/tasks/packageToolbox.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function packageToolbox(releaseType, versionString)
function [newVersion, mltbxPath] = packageToolbox(releaseType, versionString)
arguments
releaseType {mustBeTextScalar,mustBeMember(releaseType,["build","major","minor","patch","specific"])} = "build"
versionString {mustBeTextScalar} = "";
end
installMatBox('commit')
projectRootDirectory = didtools.projectdir();
matbox.tasks.packageToolbox(projectRootDirectory, releaseType, versionString, "ToolboxShortName", "DID_MATLAB")
[newVersion, mltbxPath] = matbox.tasks.packageToolbox(projectRootDirectory, ...
releaseType, versionString, "ToolboxShortName", "DID_MATLAB");
end
2 changes: 0 additions & 2 deletions tools/tasks/testToolbox.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
function testToolbox(varargin)
installMatBox("commit")
projectRootDirectory = didtools.projectdir();
matbox.installRequirements(projectRootDirectory)

matbox.tasks.testToolbox(projectRootDirectory, "CreateBadge", false, varargin{:})
end