Skip to content
Maksim Elizarev edited this page Apr 16, 2025 · 10 revisions

Basic usage

README

Specify supported MATLAB versions

You can specify a set of MATLAB releases in matlab.yml workflow. I suggest specifying only minimum and maximum versions to reduce computations.

Note that matlab.buildtool.tasks.CodeIssuesTask was introduced in 2023b, and buildtool itself in 2022b

See also: https://mathworks.com/help/matlab/ref/codecompatibilityanalysis.analyzecodecompatibility.html

on:
  workflow_call:
  workflow_dispatch:

jobs:
  buildtool:
    strategy:
      matrix:
        release: [R2023b, R2024b] # List MATLAB releases here
    name: MATLAB checks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: matlab-actions/setup-matlab@v2
        with:
          release: ${{ matrix.release }}
          cache: true
      - uses: matlab-actions/run-build@v2

Adjust Code Checks

This template works in a strict mode by default: all warnings are treated as errors by the buildtool and thus the matlab.yml workflow

% In buildfile.m
plan(task) = CodeIssuesTask(WarningThreshold=0);

I recommend keeping it this way and configuring Code Analyzer instead.

In case of failing checks use Code Analyzer locally by running codeAnalyzer in Command Window.

Configure Code Analyzer

If you instead change the Code Analyzer settings of your MATLAB distribution, it will not affect other runners of your code, including GitHub Actions. This will slow down the merging of new code, as code check results might differ locally and in the cloud.

Activity and severity of checks can be changed and preserved for your project using a configuration file. Official Documentation can be found here.

Suppress individual warnings

A warning can be suppressed individually if it is considered false-positive or non-critical. The steps are:

  1. Right-click on the line with the warning
  2. Choose Suppress Message...
  3. Choose On This Line

After that, the warning will not be included in the count but will still be visible in the Code Analyzer in the "Suppressed Only" list.

Use matlab-repo-init in existing repository

This release step attaches matlab-repo-init-vX.X.X.zip archive to every new release. The contents of this archive can be extracted to your public repository, and the resulting changes can then be adjusted and committed.

Please make sure you keep the copyright NOTICE.txt (or its contents merged to an equivalent file).

I'd also appreciate if you mention me @djmaxus in your issue or PR so I can add your project to the list of known template uses.

Similar projects