Skip to content

ci: run code analysis as a pass/fail workflow - #225

Merged
ehennestad merged 7 commits into
mainfrom
ci-code-analysis-workflow
Nov 11, 2026
Merged

ehennestad merged 7 commits into
mainfrom
ci-code-analysis-workflow

Conversation

@ehennestad

@ehennestad ehennestad commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The Run tests workflow fails on R2026a. The "Check for MATLAB code issues" step creates the code issues badge through matbox.utility.createBadgeSvg, which calls the pybadges Python package. pybadges imports imghdr, a module removed in Python 3.13, so the step fails with ModuleNotFoundError. GitHub then skips the openMINDS_Python checkout and install steps. "Run tests" still runs because it has if: always(), and the three InteropTest tests fail because OPENMINDS_PYTHON points to an interpreter that was never installed.

Change

  • New .github/workflows/code-analysis.yml calls ehennestad/matbox-actions/.github/workflows/check-code-workflow.yml@v1 on R2026b, on push and pull request to main. It keeps the SARIF upload to code scanning.
  • tools/tasks/codecheckToolbox.m accepts the FoldersToCheck argument that the check-code action passes. It sets RequireIssuesResolved and ShowIssues so that any warning or error fails the job, and sets CreateBadge=false.
  • New .github/workflows/code-analysis-latest.yml runs the same check weekly and on manual dispatch on the latest MATLAB release. code-analysis.yml stays on a fixed release so its badge changes only when the code changes. A first job compares the release that MathWorks reports as latest with the one pinned in code-analysis.yml, and the analysis runs only when they differ (or when a manual run sets force). A failure in the weekly run means a newer release reports new issues; once they are resolved, matlab_release in code-analysis.yml can be raised.
  • The README shows the Code analysis workflow status badge in place of .github/badges/code_issues.svg, which is deleted.
  • run_tests.yml drops the code check, SARIF upload and badge commit steps. The test job no longer depends on a code-check step.
  • code/resources/codeAnalyzerConfiguration.json lists the generated v1.0 and v2.0 URL.m classes under ignoredFiles. In these classes the property has the same name as the class, which Code Analyzer reports as two REDEF errors. ignoredFiles is read by MATLAB R2026b and later, so the workflow pins R2026b.
  • tools/tests/oneOffs/personArray.m suppresses the one AGROW hint.

matbox.tasks.codecheckToolbox currently throws for RequireIssuesResolved only when ShowIssues is also true. The wrapper sets both, so the check fails on remaining issues with current MatBox and after that coupling is fixed in MatBox.

🤖 Generated with Claude Code

ehennestad and others added 2 commits November 11, 2026 21:15
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

ehennestad and others added 4 commits November 11, 2026 21:19
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
@ehennestad
ehennestad enabled auto-merge (squash) November 11, 2026 20:54
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Test Results (R2022a)

861 tests   - 262   857 ✅  - 250   3m 4s ⏱️ - 1m 40s
 27 suites ±  0     4 💤  -  12 
  1 files   ±  0     0 ❌ ±  0 

Results for commit 083026d. ± Comparison against base commit 6e61e90.

This pull request removes 262 tests.
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AccessEligibilityType)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AccessForm)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AccessProcessType)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=Accessibility)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AccountInformation)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=ActionStatusType)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=Affiliation)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AgeCategory)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AmountOfChemical)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AnalysisTechnique)
…

@github-actions

Copy link
Copy Markdown
Contributor

Test Results (R2026a)

861 tests   - 262   859 ✅  - 247   6m 11s ⏱️ - 3m 6s
 27 suites ±  0     2 💤  -  12 
  1 files   ±  0     0 ❌  -   3 

Results for commit 083026d. ± Comparison against base commit 6e61e90.

This pull request removes 262 tests.
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AccessEligibilityType)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AccessForm)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AccessProcessType)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=Accessibility)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AccountInformation)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=ActionStatusType)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=Affiliation)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AgeCategory)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AmountOfChemical)
RoundTripTest ‑ testJsonLdRoundTrip(MetadataType=AnalysisTechnique)
…

@ehennestad
ehennestad merged commit db792c5 into main Nov 11, 2026
8 checks passed
@codecov

codecov Bot commented Nov 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.25%. Comparing base (c9b56f1) to head (083026d).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #225      +/-   ##
==========================================
- Coverage   80.61%   80.25%   -0.37%     
==========================================
  Files         424      424              
  Lines        4436     4436              
==========================================
- Hits         3576     3560      -16     
- Misses        860      876      +16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants