-
Notifications
You must be signed in to change notification settings - Fork 46
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
[INFRA] MATLAB test automation #43
Open
Remi-Gau
wants to merge
30
commits into
cvnlab:main
Choose a base branch
from
Remi-Gau:matlab_test_automation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
af934b4
Add common tools for MATLAB and Python testing
Remi-Gau 20e6fd9
add smoke tests matlab
Remi-Gau 918091b
add matlab test automation
Remi-Gau aee01dc
add matlab test demo automation
Remi-Gau faba452
add expected data and an assert to system test
Remi-Gau b886a8b
rename test file
Remi-Gau 04508a5
add documentation
Remi-Gau b9df9f2
lint
Remi-Gau 0eff103
remove unneeded upload coverage artefact from CI workflow
Remi-Gau 3ab086b
run tests matlab demos with CRON job on 1rt and 15th of every month
Remi-Gau ef3920e
add assert on value of R2
Remi-Gau 8284581
add doc in CI yml and scripts
Remi-Gau 61cfe71
fix typo
Remi-Gau bd5d8fa
add matlab tests badge to README
Remi-Gau 956da88
add matlab demo badge to README
Remi-Gau 9def9a2
run demos with MOxUnit in CI so that demo2 is run even if demo1 fails
Remi-Gau c4530c3
force demos to fail to make sure this is picked by CI
Remi-Gau 10161f0
add a check log to try to show workflow as failed
Remi-Gau f569dd6
remove forced errors in demo and reset to run demos bimonthly
Remi-Gau 26389af
add doc on running tests and demos in CI
Remi-Gau 56807a6
miss_hit lint CI code
Remi-Gau 07da5c3
add miss hit and linting documentation
Remi-Gau 1908552
add pre-commit doc
Remi-Gau 70d205e
update contributors doc
Remi-Gau 731ac95
add doc on generating and chekcing test data
Remi-Gau a312579
update repo map
Remi-Gau b35bec6
switch to using png image in doc
Remi-Gau ca40488
try testing different os and matlab version
Remi-Gau 882cf8e
only run tests on ubuntu latest with matlab 2020a
Remi-Gau 4ae81fd
Update .github/workflows/run_tests_matlab.yaml
Remi-Gau 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
root_dir = getenv('GITHUB_WORKSPACE'); | ||
|
||
cd(fullfile(root_dir)); | ||
|
||
setup(); | ||
|
||
run matlab/examples/example1; | ||
run matlab/examples/example2; |
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,46 @@ | ||
name: run matlab demos | ||
|
||
# Uses the cron schedule for github actions | ||
# | ||
# will run at 00H00 run on the 1 and 15 of every month | ||
# | ||
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#scheduled-events | ||
# | ||
# ┌───────────── minute (0 - 59) | ||
# │ ┌───────────── hour (0 - 23) | ||
# │ │ ┌───────────── day of the month (1 - 31) | ||
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC): * means all | ||
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT): * means all | ||
# │ │ │ │ │ | ||
# │ │ │ │ │ | ||
# │ │ │ │ │ | ||
# | ||
# - cron "0 0 1,15 * *" | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 1,15 * *" | ||
|
||
jobs: | ||
demos: | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Install MATLAB | ||
uses: matlab-actions/setup-matlab@v1.0.1 | ||
with: | ||
# MATLAB release to set up R2020a | ||
release: R2020a | ||
|
||
- name: Shallow clone GLMsingle | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
fetch-depth: 0 | ||
|
||
- name: Run commands | ||
uses: matlab-actions/run-command@v1.0.1 | ||
with: | ||
command: | ||
cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); | ||
run run_demos; |
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,61 @@ | ||
name: tests and coverage with MATLAB | ||
|
||
# Installs | ||
# - MATLAB github action | ||
# - MOXunit | ||
# - MOcov | ||
# Get test data | ||
# cd into .github/workflows | ||
# run .github/workflows/tests_matlab.m | ||
# If tests pass, uploads coverage to codecov | ||
|
||
on: | ||
push: | ||
# TODO only run on master branch on push | ||
branches: ["*"] | ||
pull_request: | ||
branches: ["*"] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Install MATLAB | ||
uses: matlab-actions/setup-matlab@v1.0.1 | ||
with: | ||
release: R2020a | ||
|
||
- name: Shallow clone GLMsingle | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
fetch-depth: 0 # 0 means we only get the last commit, not the whole git history | ||
|
||
- name: Install Moxunit and MOcov | ||
run: | | ||
git clone https://github.com/MOxUnit/MOxUnit.git --depth 1 | ||
git clone https://github.com/MOcov/MOcov.git --depth 1 | ||
|
||
- name: Download data | ||
run: make tests/data/nsdcoreexampledataset.mat | ||
|
||
- name: Run commands | ||
uses: matlab-actions/run-command@v1.0.1 | ||
with: | ||
command: | ||
cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); | ||
run tests_matlab; | ||
|
||
- name: Run tests | ||
run: | | ||
cat test_report.log | grep 0 | ||
bash <(curl -s https://codecov.io/bash) | ||
|
||
- name: Code coverage | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
file: coverage.xml # optional | ||
flags: matlab # optional | ||
name: codecov-umbrella # optional | ||
fail_ci_if_error: true # optional (default = 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,11 @@ | ||
root_dir = getenv('GITHUB_WORKSPACE'); | ||
|
||
% MOxUnit and MOcov need to be in the matlab path | ||
addpath(fullfile(root_dir, 'MOcov', 'MOcov')); | ||
cd(fullfile(root_dir, 'MOxUnit', 'MOxUnit')); | ||
run moxunit_set_path(); | ||
|
||
% adds GLM single to the path and runs all the tests | ||
cd(fullfile(root_dir)); | ||
setup(); | ||
run run_tests(); |
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,7 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.1.0 | ||
hooks: | ||
- id: check-yaml |
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,126 @@ | ||
# CONTRIBUTING | ||
|
||
Information for anyone who would like to contribute to this repository. | ||
|
||
## Repository map | ||
|
||
```bash | ||
├── .git | ||
├── .github | ||
│ └── workflows # Github continuous integration set up | ||
├── examples | ||
│ ├── data | ||
│ ├── example1outputs | ||
│ ├── example2outputs | ||
├── glmsingle # Python implementation | ||
│ ├── cod | ||
│ ├── design | ||
│ ├── gmm | ||
│ ├── hrf | ||
│ ├── ols | ||
│ ├── ssq | ||
│ └── utils | ||
├── matlab # Matlab implementation | ||
│ ├── examples | ||
│ ├── fracridge | ||
│ └── utilities | ||
└── tests # Python and Matlab tests | ||
└── data | ||
|
||
``` | ||
|
||
## Generic | ||
|
||
### Makefile | ||
|
||
A `Makefile` is used to help set / and automate some things. | ||
|
||
In a terminal type `make help` to see what are the different "recipes" you can | ||
run with this `Makefile`. | ||
|
||
### pre-commit | ||
|
||
## Matlab | ||
|
||
### Style guide | ||
|
||
### Tests | ||
|
||
Running the tests require to have the following toolboes in your MATLAB path: | ||
|
||
- the [MOxUnit testing framework](https://github.com/MOxUnit/MOxUnit) to run the | ||
tests | ||
([see installation procedure](https://github.com/MOxUnit/MOxUnit#installation)) | ||
- [MOcov](https://github.com/MOcov/MOcov)) to get a code coverage estimate | ||
([see installation procedure](https://github.com/MOcov/MOcov#installation)) | ||
|
||
All the tests are in the `tests` folder in files starting with `test_*.m`. | ||
|
||
To Download the data required for running the tests (this data is common for | ||
MATLAB and python tests), type: | ||
|
||
```bash | ||
make tests/data/nsdcoreexampledataset.mat | ||
``` | ||
|
||
To run **all** the tests and get code coverage, you can | ||
|
||
1. type the following in a terminal | ||
|
||
``` | ||
make test-matlab | ||
``` | ||
|
||
2. run the `run_tests.m` in MATLAB | ||
|
||
You can also run all the tests contained in a specific `test_*.m` file directly, | ||
by running that file only. | ||
|
||
#### Adding new tests | ||
|
||
A typical MoxUnit test file starts with with `test_` and would look something | ||
like this. | ||
|
||
```matlab | ||
function test_suite=test_sum_of_squares | ||
|
||
try % assignment of 'localfunctions' is necessary in Matlab >= 2016 | ||
test_functions=localfunctions(); | ||
catch % no problem; early Matlab versions can use initTestSuite fine | ||
end | ||
initTestSuite(); | ||
|
||
end | ||
|
||
function test_sum_of_squares_basic | ||
|
||
% given | ||
a = 2; | ||
b = 3; | ||
|
||
% when | ||
result = sum_of_squares([a, b]) | ||
|
||
% then | ||
expected = 13; | ||
assertEqual(result, expected); | ||
|
||
end | ||
|
||
% New tests can added as new sub functions | ||
|
||
``` | ||
|
||
#### Demos | ||
|
||
### Continuous integration | ||
|
||
## Python | ||
|
||
### Style guide | ||
|
||
### Tests | ||
|
||
#### Demos | ||
|
||
### Continuous integration |
Oops, something went wrong.
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.
Demos will be run automatically every 15 days