Repository navigation
106 lines (95 loc) · 3.78 KB
/
Copy pathtests.yml
File metadata and controls
106 lines (95 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Tests
on: [pull_request]
# Needed for the test-results comment and check run on the PR.
permissions:
contents: read
checks: write
pull-requests: write
jobs:
function-tests:
name: Function tests
runs-on: ubuntu-latest
# Bound the run so a hanging test fails the job in minutes instead of
# blocking the runner for hours.
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v3
with:
release: R2024b
- name: Run function tests
uses: matlab-actions/run-command@v3
env:
# Batch licensing token for running MATLAB on a GitHub-hosted
# runner. Request one from MathWorks and store it as the
# MATLAB_BATCH_TOKEN repository secret.
MLM_LICENSE_TOKEN: ${{ secrets.MATLAB_BATCH_TOKEN }}
with:
# The function tests use a "t*" naming convention that MATLAB's
# folder-based discovery does not recognise, so the suite is built
# from the explicit file list. RavenTestCase is the abstract base
# class and must be excluded. Results are written as JUnit XML for
# the reporting step below; the run itself does not fail the step so
# that the report is always produced.
command: |
root = pwd;
addpath(genpath(root));
resultsDir = fullfile(root, 'test-results');
if ~isfolder(resultsDir); mkdir(resultsDir); end
import matlab.unittest.TestRunner
import matlab.unittest.plugins.XMLPlugin
cd(fullfile('tests', 'function_tests'));
files = string({dir('*.m').name});
files(files == "RavenTestCase.m") = [];
files(files == "tBinaries.m") = []; % run separately by the binary-tests job (Linux + macOS)
suite = testsuite(cellstr(files));
% Detailed output prints "Running <class>/<test>" before each test
% so that, if a test hangs on the runner, the last such line names
% the culprit.
runner = TestRunner.withTextOutput('OutputDetail', ...
matlab.unittest.Verbosity.Detailed);
runner.addPlugin(XMLPlugin.producingJUnitFormat( ...
fullfile(resultsDir, 'results.xml')));
run(runner, suite);
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
check_name: Function test results
comment_mode: always
files: test-results/results.xml
# Fail the workflow (and the PR check) when any test fails or errors.
action_fail: true
binary-tests:
name: Binary download (${{ matrix.os }})
# Validate the on-demand fetch of the external binaries from toolbox-assets on
# Linux and macOS. Running the downloaded binaries also confirms the macOS
# Gatekeeper quarantine is cleared so they can execute.
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v3
with:
release: R2024b
- name: Test on-demand binary download
uses: matlab-actions/run-command@v3
env:
MLM_LICENSE_TOKEN: ${{ secrets.MATLAB_BATCH_TOKEN }}
with:
command: |
addpath(genpath(pwd));
results = runtests('tBinaries');
disp(table(results));
nFailed = nnz([results.Failed]);
if nFailed > 0
error('%d binary download test(s) failed on %s', nFailed, computer('arch'));
end