From 3c4c26b19ebc0513846d2d31afb65a9c913c33f4 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Wed, 11 Nov 2026 21:15:15 +0100 Subject: [PATCH 1/7] chore: clear the remaining Code Analyzer issues The generated v1.0 and v2.0 URL classes have a property named like the class, which Code Analyzer reports as REDEF errors. The classes are generated, so code/resources/codeAnalyzerConfiguration.json lists them under ignoredFiles (read by MATLAB R2026b and later). personArray grows its argument cell once per person when the schema has preferredName; the AGROW hint is suppressed on that line. Co-Authored-By: Claude Opus 5.5 --- .github/badges/code_issues.svg | 1 - code/resources/codeAnalyzerConfiguration.json | 8 ++++++++ tools/tests/oneOffs/personArray.m | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) delete mode 100644 .github/badges/code_issues.svg create mode 100644 code/resources/codeAnalyzerConfiguration.json diff --git a/.github/badges/code_issues.svg b/.github/badges/code_issues.svg deleted file mode 100644 index f7c6c0de3..000000000 --- a/.github/badges/code_issues.svg +++ /dev/null @@ -1 +0,0 @@ -code issuescode issues44 \ No newline at end of file diff --git a/code/resources/codeAnalyzerConfiguration.json b/code/resources/codeAnalyzerConfiguration.json new file mode 100644 index 000000000..fdb410844 --- /dev/null +++ b/code/resources/codeAnalyzerConfiguration.json @@ -0,0 +1,8 @@ +{ + "name": "openMINDS_MATLAB", + "description": "Excludes generated classes where the openMINDS type and one of its properties share a name, which Code Analyzer reports as REDEF.", + "ignoredFiles": [ + "generated/resources/v1.0/types/+openminds/+core/+miscellaneous/URL.m", + "generated/resources/v2.0/types/+openminds/+core/+miscellaneous/URL.m" + ] +} diff --git a/tools/tests/oneOffs/personArray.m b/tools/tests/oneOffs/personArray.m index 180b91a06..d2f598168 100644 --- a/tools/tests/oneOffs/personArray.m +++ b/tools/tests/oneOffs/personArray.m @@ -23,8 +23,8 @@ "contactInformation", contacts(person.email) }; if ommtest.oneoffs.currentSchemaMajorVersion() >= 5 - personArguments = [personArguments, { ... - "preferredName", join([person.givenName, person.familyName], " ")}]; + preferredName = join([person.givenName, person.familyName], " "); + personArguments = [personArguments, {"preferredName", preferredName}]; %#ok end persons(end+1) = openminds.core.Person(personArguments{:}); %#ok From 2408004d6d768072e92500165f865227fb60f9b2 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Wed, 11 Nov 2026 21:15:16 +0100 Subject: [PATCH 2/7] ci: run code analysis as a pass/fail workflow The code check ran as a step of the R2026a test job. When it failed, the openMINDS_Python checkout and install steps were skipped, while Run tests (if: always()) still ran and InteropTest failed on the missing interpreter. The check failed because MatBox rendered the code issues badge with pybadges, which imports imghdr, a module removed in Python 3.13. The new Analyse code workflow calls the matbox-actions check-code-workflow on R2026b. codecheckToolbox now accepts FoldersToCheck, fails on unresolved warnings or errors, and creates no badge. The README shows the workflow status instead of the generated code_issues.svg, and run_tests.yml drops the code check, SARIF upload and badge commit steps. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/analyse-code.yml | 35 ++++++++++++++++++++++++++++++ .github/workflows/run_tests.yml | 35 ------------------------------ README.md | 2 +- tools/tasks/codecheckToolbox.m | 32 ++++++++++++++++++++++++--- 4 files changed, 65 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/analyse-code.yml diff --git a/.github/workflows/analyse-code.yml b/.github/workflows/analyse-code.yml new file mode 100644 index 000000000..ac30ec39b --- /dev/null +++ b/.github/workflows/analyse-code.yml @@ -0,0 +1,35 @@ +name: Analyse code + +# Runs MATLAB Code Analyzer on every .m file in the repository. The job +# fails when an issue of severity warning or error remains (see +# tools/tasks/codecheckToolbox.m). The README shows this workflow's status +# as the code analysis badge. + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + analyse-code: + name: Analyse code + uses: ehennestad/matbox-actions/.github/workflows/check-code-workflow.yml@v1 + with: + # Check the whole repository, including the tools folder + source_directory: "." + + # A fixed release, so the result changes only when the code changes. + # The ignoredFiles setting in code/resources/codeAnalyzerConfiguration.json + # needs R2026b or later. + matlab_release: R2026b + matlab_use_cache: true + + # The README shows this workflow's status, so no badge file is + # generated or committed + update_badges: false diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 064187242..ffd6b53a5 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -56,21 +56,6 @@ jobs: release: ${{ matrix.MATLABVersion }} cache: true - # Check for MATLAB code issues in the project. - - name: Check for MATLAB code issues - if: matrix.MATLABVersion == env.LatestMATLABVersion - uses: matlab-actions/run-command@v3 - with: - command: addpath(genpath("tools")); codecheckToolbox() - - # Upload code issues report - - name: Upload SARIF file - if: matrix.MATLABVersion == env.LatestMATLABVersion - uses: github/codeql-action/upload-sarif@v3 - with: - # Path to SARIF file relative to the root of the repository - sarif_file: docs/reports/code_issues.sarif - # The interoperability test builds the same collection with the # Python reference implementation and compares the two exports. A # pull request runs against a pinned release, so it cannot go red @@ -111,26 +96,6 @@ jobs: addpath(genpath("tools")); testToolbox() - # Commit the updated code issues badge (if changed). - # Push events only, so badge commits land on main and nowhere else: - # committing them on a pull_request event rewrites the PR head branch - # and breaks any stack built on top of it. - - name: Commit svg badges if updated - if: matrix.MATLABVersion == env.LatestMATLABVersion && github.event_name == 'push' - continue-on-error: true - run: | - git config user.name "${{ github.workflow }} by ${{ github.actor }}" - git config user.email "${{ secrets.COMMIT_EMAIL_ADDRESS }}" - git fetch - - if [[ $(git add .github/badges/* --dry-run | wc -l) -gt 0 ]]; then - git add .github/badges/* - git commit -m "Update code issues badge" - git push -f - else - echo "Nothing to commit" - fi - - name: Upload code coverage report to Codecov (https://app.codecov.io/gh/openMetadataInitiative/openMINDS_MATLAB) if: matrix.MATLABVersion == env.LatestMATLABVersion uses: codecov/codecov-action@v6 diff --git a/README.md b/README.md index 10f713a58..81420acc8 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![View openMINDS_MATLAB on File Exchange](https://github.com/openMetadataInitiative/openMINDS_MATLAB/blob/gh-badges/.github/badges/matlab-file-exchange.svg)](https://se.mathworks.com/matlabcentral/fileexchange/134212-openminds_matlab) [![Run tests](https://github.com/openMetadataInitiative/openMINDS_MATLAB/actions/workflows/run_tests.yml/badge.svg)](https://github.com/openMetadataInitiative/openMINDS_MATLAB/actions/workflows/run_tests.yml) [![codecov](https://codecov.io/gh/openMetadataInitiative/openMINDS_MATLAB/graph/badge.svg?token=FTD5FHZSFA)](https://codecov.io/gh/openMetadataInitiative/openMINDS_MATLAB) -[![MATLAB Code Issues](.github/badges/code_issues.svg)](https://github.com/openMetadataInitiative/openMINDS_MATLAB/security/code-scanning) +[![Analyse code](https://github.com/openMetadataInitiative/openMINDS_MATLAB/actions/workflows/analyse-code.yml/badge.svg)](https://github.com/openMetadataInitiative/openMINDS_MATLAB/actions/workflows/analyse-code.yml)

Installation • diff --git a/tools/tasks/codecheckToolbox.m b/tools/tasks/codecheckToolbox.m index 1d123ab94..53ba2dc5a 100644 --- a/tools/tasks/codecheckToolbox.m +++ b/tools/tasks/codecheckToolbox.m @@ -1,9 +1,35 @@ -function issues = codecheckToolbox() +function issues = codecheckToolbox(options) % codecheckToolbox - Identify code issues for openMINDS_MATLAB toolbox +% +% issues = codecheckToolbox() checks every .m file in the repository and +% throws an error if an issue of severity warning or error remains. +% +% issues = codecheckToolbox(FoldersToCheck=folders) checks only the .m +% files in the given folders, which are relative to the repository root. +% The ehennestad/matbox-actions check-code action passes this argument. +% +% The ignoredFiles setting in code/resources/codeAnalyzerConfiguration.json +% lists files that Code Analyzer skips (MATLAB R2026b or later). + + arguments + options.FoldersToCheck (1,:) string = string.empty + end ommtools.installMatBox("commit") projectRootDirectory = ommtools.projectdir(); - + + if isempty(options.FoldersToCheck) + foldersToCheck = string.empty; + else + foldersToCheck = fullfile(projectRootDirectory, options.FoldersToCheck); + end + + % matbox.tasks.codecheckToolbox applies RequireIssuesResolved only when + % ShowIssues is true. The status of the Analyse code workflow is the + % README badge, so no badge file is created. issues = matbox.tasks.codecheckToolbox(projectRootDirectory, ... - "CreateBadge", true); + FoldersToCheck=foldersToCheck, ... + CreateBadge=false, ... + RequireIssuesResolved=true, ... + ShowIssues=true); end From 18557d08969f10c3134f303872d17bc2a555d83d Mon Sep 17 00:00:00 2001 From: ehennestad Date: Wed, 11 Nov 2026 21:19:34 +0100 Subject: [PATCH 3/7] ci: add weekly code analysis on the latest MATLAB release Analyse code runs on a fixed release, so its badge changes only when the code changes. The new workflow runs the same check weekly on the latest release. A failure there means a newer release reports issues the fixed release does not, and the pin in analyse-code.yml can be raised once they are resolved. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/analyse-code-latest.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/analyse-code-latest.yml diff --git a/.github/workflows/analyse-code-latest.yml b/.github/workflows/analyse-code-latest.yml new file mode 100644 index 000000000..95b12cd33 --- /dev/null +++ b/.github/workflows/analyse-code-latest.yml @@ -0,0 +1,22 @@ +name: Analyse code (latest MATLAB) + +# Runs the same code analysis as analyse-code.yml on the latest MATLAB +# release. analyse-code.yml uses a fixed release so that its result, and +# the README badge, change only when the code changes. A failure here means +# a newer release reports issues that the fixed release does not: resolve +# them, then raise matlab_release in analyse-code.yml. + +on: + # Weekly, Monday 04:00 UTC + schedule: + - cron: '0 4 * * 1' + workflow_dispatch: + +jobs: + analyse-code: + name: Analyse code (latest MATLAB) + uses: ehennestad/matbox-actions/.github/workflows/check-code-workflow.yml@v1 + with: + source_directory: "." + matlab_release: latest + update_badges: false From fcf9126dd138f13b362c6c425d2be57ceb63bdb8 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Wed, 11 Nov 2026 21:19:35 +0100 Subject: [PATCH 4/7] docs: give the reason codecheckToolbox shows the issue table matbox.tasks.codecheckToolbox currently evaluates RequireIssuesResolved only when ShowIssues is true; that coupling is being fixed in MatBox. The comment now states the reason that holds either way: the table names the files to fix in a failed CI run. Co-Authored-By: Claude Opus 5.5 --- tools/tasks/codecheckToolbox.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/tasks/codecheckToolbox.m b/tools/tasks/codecheckToolbox.m index 53ba2dc5a..1be9db144 100644 --- a/tools/tasks/codecheckToolbox.m +++ b/tools/tasks/codecheckToolbox.m @@ -24,9 +24,9 @@ foldersToCheck = fullfile(projectRootDirectory, options.FoldersToCheck); end - % matbox.tasks.codecheckToolbox applies RequireIssuesResolved only when - % ShowIssues is true. The status of the Analyse code workflow is the - % README badge, so no badge file is created. + % ShowIssues prints the table of remaining issues, so a failed CI run + % shows which files to fix. The status of the Analyse code workflow is + % the README badge, so no badge file is created. issues = matbox.tasks.codecheckToolbox(projectRootDirectory, ... FoldersToCheck=foldersToCheck, ... CreateBadge=false, ... From af47ba9e9ae031fc7e4e541ff328161a44d39cc7 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Wed, 11 Nov 2026 21:22:26 +0100 Subject: [PATCH 5/7] ci: skip the weekly analysis while latest is the pinned release A first job reads the latest release name from the MathWorks URL that setup-matlab uses for "latest" and the matlab_release pinned in analyse-code.yml. The analysis runs only when they differ, on the resolved release, so the run checks the release that was compared. A manual run can force it with the force input. The job fails if analyse-code.yml has no pin of the form R2026b. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/analyse-code-latest.yml | 53 ++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/.github/workflows/analyse-code-latest.yml b/.github/workflows/analyse-code-latest.yml index 95b12cd33..9facd7a33 100644 --- a/.github/workflows/analyse-code-latest.yml +++ b/.github/workflows/analyse-code-latest.yml @@ -5,18 +5,69 @@ name: Analyse code (latest MATLAB) # the README badge, change only when the code changes. A failure here means # a newer release reports issues that the fixed release does not: resolve # them, then raise matlab_release in analyse-code.yml. +# +# The analysis is skipped while the latest release is the one pinned in +# analyse-code.yml, because that workflow already covers it. on: # Weekly, Monday 04:00 UTC schedule: - cron: '0 4 * * 1' workflow_dispatch: + inputs: + force: + description: Run the analysis even if the latest release is the pinned release + type: boolean + default: false jobs: + compare-releases: + name: Compare latest and pinned MATLAB release + runs-on: ubuntu-latest + outputs: + latest_release: ${{ steps.compare.outputs.latest_release }} + run_analysis: ${{ steps.compare.outputs.run_analysis }} + steps: + - name: Check out analyse-code.yml + uses: actions/checkout@v6 + with: + sparse-checkout: .github/workflows/analyse-code.yml + sparse-checkout-cone-mode: false + + # setup-matlab resolves "latest" from the same MathWorks URL, which + # returns a lowercase release name such as r2026b + - name: Compare releases + id: compare + env: + FORCE: ${{ inputs.force || false }} + run: | + latest=$(curl -fsS --retry 3 https://ssd.mathworks.com/supportfiles/ci/matlab-release/v0/latest \ + | tr '[:upper:]' '[:lower:]') + pinned=$(grep -oE '^[[:space:]]*matlab_release:[[:space:]]*R[0-9]{4}[ab]' .github/workflows/analyse-code.yml \ + | grep -oE 'R[0-9]{4}[ab]' || true) + if [[ -z "$pinned" ]]; then + echo "::error::No matlab_release of the form R2026b found in analyse-code.yml" + exit 1 + fi + pinned=$(echo "$pinned" | tr '[:upper:]' '[:lower:]') + + if [[ "$latest" != "$pinned" || "$FORCE" == "true" ]]; then + runAnalysis=true + else + runAnalysis=false + fi + + echo "latest_release=$latest" >> "$GITHUB_OUTPUT" + echo "run_analysis=$runAnalysis" >> "$GITHUB_OUTPUT" + echo "Latest release: $latest, pinned release: $pinned, run analysis: $runAnalysis" \ + | tee -a "$GITHUB_STEP_SUMMARY" + analyse-code: name: Analyse code (latest MATLAB) + needs: compare-releases + if: needs.compare-releases.outputs.run_analysis == 'true' uses: ehennestad/matbox-actions/.github/workflows/check-code-workflow.yml@v1 with: source_directory: "." - matlab_release: latest + matlab_release: ${{ needs.compare-releases.outputs.latest_release }} update_badges: false From 583a6d1ce345ee9a40d97487487a4f8f95b87bec Mon Sep 17 00:00:00 2001 From: ehennestad Date: Wed, 11 Nov 2026 21:44:27 +0100 Subject: [PATCH 6/7] ci: name the analysis workflows Code analysis The workflows report a status, so they get a noun for both the file and the display name, as in GitHub's starter workflows: code-analysis.yml ("Code analysis") and code-analysis-latest.yml ("Code analysis (latest MATLAB)"). The README badge, the pin lookup in the weekly workflow and the comment in codecheckToolbox follow the new names. Co-Authored-By: Claude Opus 5.5 --- ...de-latest.yml => code-analysis-latest.yml} | 22 +++++++++---------- .../{analyse-code.yml => code-analysis.yml} | 6 ++--- README.md | 2 +- tools/tasks/codecheckToolbox.m | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) rename .github/workflows/{analyse-code-latest.yml => code-analysis-latest.yml} (80%) rename .github/workflows/{analyse-code.yml => code-analysis.yml} (94%) diff --git a/.github/workflows/analyse-code-latest.yml b/.github/workflows/code-analysis-latest.yml similarity index 80% rename from .github/workflows/analyse-code-latest.yml rename to .github/workflows/code-analysis-latest.yml index 9facd7a33..8141a60d1 100644 --- a/.github/workflows/analyse-code-latest.yml +++ b/.github/workflows/code-analysis-latest.yml @@ -1,13 +1,13 @@ -name: Analyse code (latest MATLAB) +name: Code analysis (latest MATLAB) -# Runs the same code analysis as analyse-code.yml on the latest MATLAB -# release. analyse-code.yml uses a fixed release so that its result, and +# Runs the same check as code-analysis.yml on the latest MATLAB +# release. code-analysis.yml uses a fixed release so that its result, and # the README badge, change only when the code changes. A failure here means # a newer release reports issues that the fixed release does not: resolve -# them, then raise matlab_release in analyse-code.yml. +# them, then raise matlab_release in code-analysis.yml. # # The analysis is skipped while the latest release is the one pinned in -# analyse-code.yml, because that workflow already covers it. +# code-analysis.yml, because that workflow already covers it. on: # Weekly, Monday 04:00 UTC @@ -28,10 +28,10 @@ jobs: latest_release: ${{ steps.compare.outputs.latest_release }} run_analysis: ${{ steps.compare.outputs.run_analysis }} steps: - - name: Check out analyse-code.yml + - name: Check out code-analysis.yml uses: actions/checkout@v6 with: - sparse-checkout: .github/workflows/analyse-code.yml + sparse-checkout: .github/workflows/code-analysis.yml sparse-checkout-cone-mode: false # setup-matlab resolves "latest" from the same MathWorks URL, which @@ -43,10 +43,10 @@ jobs: run: | latest=$(curl -fsS --retry 3 https://ssd.mathworks.com/supportfiles/ci/matlab-release/v0/latest \ | tr '[:upper:]' '[:lower:]') - pinned=$(grep -oE '^[[:space:]]*matlab_release:[[:space:]]*R[0-9]{4}[ab]' .github/workflows/analyse-code.yml \ + pinned=$(grep -oE '^[[:space:]]*matlab_release:[[:space:]]*R[0-9]{4}[ab]' .github/workflows/code-analysis.yml \ | grep -oE 'R[0-9]{4}[ab]' || true) if [[ -z "$pinned" ]]; then - echo "::error::No matlab_release of the form R2026b found in analyse-code.yml" + echo "::error::No matlab_release of the form R2026b found in code-analysis.yml" exit 1 fi pinned=$(echo "$pinned" | tr '[:upper:]' '[:lower:]') @@ -62,8 +62,8 @@ jobs: echo "Latest release: $latest, pinned release: $pinned, run analysis: $runAnalysis" \ | tee -a "$GITHUB_STEP_SUMMARY" - analyse-code: - name: Analyse code (latest MATLAB) + code-analysis: + name: Code analysis (latest MATLAB) needs: compare-releases if: needs.compare-releases.outputs.run_analysis == 'true' uses: ehennestad/matbox-actions/.github/workflows/check-code-workflow.yml@v1 diff --git a/.github/workflows/analyse-code.yml b/.github/workflows/code-analysis.yml similarity index 94% rename from .github/workflows/analyse-code.yml rename to .github/workflows/code-analysis.yml index ac30ec39b..20511ed30 100644 --- a/.github/workflows/analyse-code.yml +++ b/.github/workflows/code-analysis.yml @@ -1,4 +1,4 @@ -name: Analyse code +name: Code analysis # Runs MATLAB Code Analyzer on every .m file in the repository. The job # fails when an issue of severity warning or error remains (see @@ -17,8 +17,8 @@ concurrency: cancel-in-progress: true jobs: - analyse-code: - name: Analyse code + code-analysis: + name: Code analysis uses: ehennestad/matbox-actions/.github/workflows/check-code-workflow.yml@v1 with: # Check the whole repository, including the tools folder diff --git a/README.md b/README.md index 81420acc8..701711710 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![View openMINDS_MATLAB on File Exchange](https://github.com/openMetadataInitiative/openMINDS_MATLAB/blob/gh-badges/.github/badges/matlab-file-exchange.svg)](https://se.mathworks.com/matlabcentral/fileexchange/134212-openminds_matlab) [![Run tests](https://github.com/openMetadataInitiative/openMINDS_MATLAB/actions/workflows/run_tests.yml/badge.svg)](https://github.com/openMetadataInitiative/openMINDS_MATLAB/actions/workflows/run_tests.yml) [![codecov](https://codecov.io/gh/openMetadataInitiative/openMINDS_MATLAB/graph/badge.svg?token=FTD5FHZSFA)](https://codecov.io/gh/openMetadataInitiative/openMINDS_MATLAB) -[![Analyse code](https://github.com/openMetadataInitiative/openMINDS_MATLAB/actions/workflows/analyse-code.yml/badge.svg)](https://github.com/openMetadataInitiative/openMINDS_MATLAB/actions/workflows/analyse-code.yml) +[![Code analysis](https://github.com/openMetadataInitiative/openMINDS_MATLAB/actions/workflows/code-analysis.yml/badge.svg)](https://github.com/openMetadataInitiative/openMINDS_MATLAB/actions/workflows/code-analysis.yml)

Installation • diff --git a/tools/tasks/codecheckToolbox.m b/tools/tasks/codecheckToolbox.m index 1be9db144..e8418a5ed 100644 --- a/tools/tasks/codecheckToolbox.m +++ b/tools/tasks/codecheckToolbox.m @@ -25,7 +25,7 @@ end % ShowIssues prints the table of remaining issues, so a failed CI run - % shows which files to fix. The status of the Analyse code workflow is + % shows which files to fix. The status of the Code analysis workflow is % the README badge, so no badge file is created. issues = matbox.tasks.codecheckToolbox(projectRootDirectory, ... FoldersToCheck=foldersToCheck, ... From 083026d434ba364131e4e717dccded0ee22d3b39 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Wed, 11 Nov 2026 22:41:35 +0100 Subject: [PATCH 7/7] ci: re-run checks after the GitHub Actions outage Co-Authored-By: Claude Opus 5.5