Skip to content

Tests

Tests #685

Workflow file for this run

name: Tests
on:
release:
types: [published]
pull_request:
workflow_dispatch:
schedule:
- cron: '15 3 * * *'
- cron: '40 16 * * 3'
jobs:
matlab-tests:
name: Run MATLAB Tests
strategy:
fail-fast: false
matrix:
version: ["R2020a", "R2020b", "R2021a", "R2021b", "R2022a", "R2022b", "R2023a", "R2023b", "R2024a"]
os: ["ubuntu-latest", "macos-13", "macos-latest", "windows-latest"] # macos-13 has Intel architecture, macos-latest has Apple Silicon
exclude:
- os: windows-latest
version: "R2020a" # MATLAB not available
- os: windows-latest
version: "R2020b" # MATLAB not available
- os: windows-latest
version: "R2021a" # Compiler not available
- os: windows-latest
version: "R2021b" # Compiler not available
- os: macos-latest
version: "R2020a" # Apple Silicon version not available
- os: macos-latest
version: "R2020b" # Apple Silicon version not available
- os: macos-latest
version: "R2021a" # Apple Silicon version not available
- os: macos-latest
version: "R2021b" # Apple Silicon version not available
- os: macos-latest
version: "R2022a" # Apple Silicon version not available
- os: macos-latest
version: "R2022b" # Apple Silicon version not available
- os: macos-latest
version: "R2023a" # Apple Silicon version not available
runs-on: ${{matrix.os}}
steps:
- name: Set up MATLAB (legacy)
if: ${{matrix.version == 'R2020a' || matrix.version == 'R2020b' || matrix.version == 'R2022a' || matrix.version == 'R2022b'}}
uses: matlab-actions/setup-matlab@v1
with:
release: ${{matrix.version}}
- name: Set up MATLAB
if: ${{matrix.version != 'R2020a' && matrix.version != 'R2020b' && matrix.version != 'R2022a' && matrix.version != 'R2022b'}}
uses: matlab-actions/setup-matlab@v2
with:
release: ${{matrix.version}}
- name: Check out repository
uses: actions/checkout@v4
- name: Setup cached test data folder
id: cache-data-tests
uses: actions/cache@v4
with:
path: tests/data
key: tests-data
enableCrossOsArchive: true
- name: Check out test data to latest
uses: actions/checkout@v4
with:
repository: spm/spm-tests-data
token: ${{ secrets.TESTS_DATA_REPO_TOKEN }}
path: tests/data
lfs: true
- name: Run regression tests with existing MEX files (legacy)
if: ${{github.event.schedule == '40 16 * * 3' && (matrix.version == 'R2020a' || matrix.version == 'R2020b' || matrix.version == 'R2022a' || matrix.version == 'R2022b')}}
uses: matlab-actions/run-command@v1
with:
command: addpath(pwd); results = spm_tests('class','regression','display',true); assert(all(~[results.Failed]));
- name: Run unit tests with existing MEX files (legacy)
if: ${{github.event.schedule != '40 16 * * 3' && (matrix.version == 'R2020a' || matrix.version == 'R2020b' || matrix.version == 'R2022a' || matrix.version == 'R2022b')}}
uses: matlab-actions/run-command@v1
with:
command: addpath(pwd); results = spm_tests('class','unit','display',true); assert(all(~[results.Failed]));
- name: Run regression tests with existing MEX files
if: ${{github.event.schedule == '40 16 * * 3' && matrix.version != 'R2020a' && matrix.version != 'R2020b' && matrix.version != 'R2022a' && matrix.version != 'R2022b'}}
uses: matlab-actions/run-command@v2
with:
command: addpath(pwd); results = spm_tests('class','regression','display',true); assert(all(~[results.Failed]));
- name: Run unit tests with existing MEX files
if: ${{github.event.schedule != '40 16 * * 3' && matrix.version != 'R2020a' && matrix.version != 'R2020b' && matrix.version != 'R2022a' && matrix.version != 'R2022b'}}
uses: matlab-actions/run-command@v2
with:
command: addpath(pwd); results = spm_tests('class','unit','display',true); assert(all(~[results.Failed]));
- name: Compile MEX files
run: |
make -C src distclean
make -C src
make -C src install
# make -C src external-distclean
# make -C src external
# make -C src external-install
- name: Get MEX extension on Linux/macOS
if: runner.os != 'Windows'
run: echo "MEXEXT=$(mexext)" >> $GITHUB_ENV
- name: Get MEX extension on Windows
if: runner.os == 'Windows'
run: echo "MEXEXT=$(mexext.bat)" >> $env:GITHUB_ENV
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: spm-${{env.MEXEXT}}-${{runner.os}}-${{matrix.version}}
path: ./**/*.${{env.MEXEXT}}
retention-days: 1