-
Notifications
You must be signed in to change notification settings - Fork 593
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
Add MATLAB code analyzer #3018
Merged
Merged
Add MATLAB code analyzer #3018
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Setup MATLAB | ||
description: Setup MATLAB for use in GitHub Actions | ||
runs: | ||
using: "composite" | ||
steps: | ||
# | ||
# MATLAB | ||
# | ||
- name: Setup MATLAB | ||
id: setup-matlab | ||
uses: matlab-actions/setup-matlab@v2 | ||
with: | ||
release: "R2024a" | ||
|
||
- name: Set MATLAB_HOME and MATLAB_VERSION | ||
run: | | ||
# Needed for MATLAB R2024a | ||
sudo apt install -y libgtk2.0-0 | ||
echo "MATLAB_VERSION=R2024a" >> $GITHUB_ENV | ||
echo "MATLAB_HOME=${{ steps.setup-matlab.outputs.matlabroot }}" >> $GITHUB_ENV | ||
shell: bash | ||
if: runner.os == 'Linux' | ||
|
||
- name: Set MATLAB_HOME and MATLAB_VERSION | ||
run: | | ||
echo "MATLAB_VERSION=R2024a" >> $env:GITHUB_ENV | ||
echo "MATLAB_HOME=${{ steps.setup-matlab.outputs.matlabroot }}" >> $env:GITHUB_ENV | ||
shell: powershell | ||
if: runner.os == 'Windows' | ||
|
||
# https://github.com/matlab-actions/run-command/issues/53 | ||
- name: Get run-matlab-command | ||
run: | | ||
wget -O /usr/local/bin/run-matlab-command https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command | ||
chmod +x /usr/local/bin/run-matlab-command | ||
echo "MATLAB_COMMAND=/usr/local/bin/run-matlab-command" >> $GITHUB_ENV | ||
|
||
# https://www.mathworks.com/matlabcentral/answers/1907290-how-to-manually-select-the-libstdc-library-to-use-to-resolve-a-version-glibcxx_-not-found | ||
echo "LD_PRELOAD=/lib/x86_64-linux-gnu/libstdc++.so.6" >> $GITHUB_ENV | ||
|
||
shell: bash | ||
if: runner.os == 'Linux' | ||
|
||
# Windows is currently not working. We get an error: "'matlab' executable not found on the system path" | ||
# However, MATLAB is installed and the path is (seemingly) set correctly | ||
- name: Get run-matlab-command | ||
run: | | ||
Invoke-WebRequest https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/win64/run-matlab-command.exe -OutFile C:\Windows\System32\run-matlab-command.exe | ||
echo "MATLAB_COMMAND=C:\Windows\System32\run-matlab-command.exe" >> $env:GITHUB_ENV | ||
shell: powershell | ||
if: runner.os == 'Windows' && matrix.config == 'matlab' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Matlab Analyzer | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: ["main"] | ||
|
||
jobs: | ||
matlab-analyzer: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Dependencies | ||
uses: ./.github/actions/setup-dependencies | ||
with: | ||
use_matlab: true | ||
|
||
- name: Build MATLAB on Ubuntu | ||
uses: ./.github/actions/build | ||
timeout-minutes: 90 | ||
with: | ||
working_directory: "matlab" | ||
build_cpp_and_python: true | ||
|
||
- name: MATLAB Analyzer | ||
run: | | ||
$MATLAB_COMMAND code_analyzer | ||
working-directory: ./matlab/config | ||
shell: bash | ||
|
||
- name: Upload Analyzer Report | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: matlab-analyzer-report | ||
path: ./matlab/config/result.json | ||
if-no-files-found: ignore | ||
if: always() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ lib/x86_64-linux-gnu/ | |
toolbox/build | ||
toolbox/toolbox.prj | ||
toolbox/info.xml | ||
config/result.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"baseConfiguration" : "factory", | ||
"checks": | ||
{ | ||
"PROPLC": | ||
{ | ||
"enabled" : false | ||
}, | ||
"PROP": | ||
{ | ||
"enabled" : false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function code_analyzer() | ||
result = codeIssues(["../lib/+Ice", "../lib/+IceInternal", "../lib/generated"], CodeAnalyzerConfiguration="analyzer.json"); | ||
export(result, "result.json", FileFormat="json"); | ||
disp(result); | ||
if height(result.Issues) > 0 | ||
exit(1); | ||
else | ||
exit(0); | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the MATLAB setup to a separate action to be able to use it from both CI and MATLAB Analyzer workflows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't both workflows use setup-dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem was how setup-dependencies detect if MATLAB has to be installed:
There is no matrix config with the new job.