14
14
branches :
15
15
- main
16
16
workflow_dispatch :
17
+ inputs :
18
+ test_all_matlab_releases :
19
+ description : ' Run test matrix with all matlab releases (true) or only latest MATLAB release (false)'
20
+ required : true
21
+ default : false
22
+ type : boolean
17
23
18
24
concurrency :
19
25
group : ${{ github.workflow }}-${{ github.ref }}
@@ -36,17 +42,29 @@ jobs:
36
42
# Load the matrix configuration and extract latest version
37
43
latest_matlab_version=$(yq '.[-1].matlab-version' .github/workflows/configurations/matlab_release_matrix_strategy.yml)
38
44
39
- # Conditionally define the MATLAB test matrix based on the PR type.
40
- # Draft pull requests are only tested against the latest MATLAB release,
41
- # while non-draft PRs and push events are tested against all configured releases.
42
- if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.draft }}" == "true" ]]; then
43
- echo "Draft PR detected - using latest MATLAB version only"
44
- # Create matrix with only the latest entry
45
- matrix=$(yq -o=json '.[-1:] | {"include": .}' .github/workflows/configurations/matlab_release_matrix_strategy.yml | tr -d '\n')
45
+ # Determine whether to use full matrix of MATLAB releases or just
46
+ # latest MATLAB release
47
+ if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.test_all_matlab_releases }}" == "true" ]]; then
48
+ use_full_matrix=true
49
+ echo "Workflow dispatch with full matrix for all MATLAB releases"
50
+ elif [[ "${{ github.event_name }}" != "workflow_dispatch" && "${{ github.event_name }}" != "pull_request" ]]; then
51
+ use_full_matrix=true
52
+ echo "Push event - using full matrix"
53
+ elif [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.draft }}" != "true" ]]; then
54
+ use_full_matrix=true
55
+ echo "Non-draft PR - using full matrix"
46
56
else
47
- echo "Non-draft PR or push event - using full matrix"
48
- # Create matrix with all entries
57
+ use_full_matrix=false
58
+ echo "Using latest MATLAB release only"
59
+ fi
60
+
61
+ # Create the appropriate matrix based on the decision
62
+ if [[ "$use_full_matrix" == "true" ]]; then
63
+ # Create matrix with all MATLAB releases
49
64
matrix=$(yq -o=json '{"include": .}' .github/workflows/configurations/matlab_release_matrix_strategy.yml | tr -d '\n')
65
+ else
66
+ # Create matrix with only the latest MATLAB release
67
+ matrix=$(yq -o=json '.[-1:] | {"include": .}' .github/workflows/configurations/matlab_release_matrix_strategy.yml | tr -d '\n')
50
68
fi
51
69
52
70
# Assign `matrix` and `latest_matlab_version` as outputs of this job
0 commit comments