Skip to content

Commit a0deb00

Browse files
authored
Support option for testing with all releases or latest release when running test workflow manually (#726)
* Update run_tests.yml * Update run_tests.yml Reorder code
1 parent 97c874e commit a0deb00

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

.github/workflows/run_tests.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ on:
1414
branches:
1515
- main
1616
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
1723

1824
concurrency:
1925
group: ${{ github.workflow }}-${{ github.ref }}
@@ -36,17 +42,29 @@ jobs:
3642
# Load the matrix configuration and extract latest version
3743
latest_matlab_version=$(yq '.[-1].matlab-version' .github/workflows/configurations/matlab_release_matrix_strategy.yml)
3844
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"
4656
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
4964
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')
5068
fi
5169
5270
# Assign `matrix` and `latest_matlab_version` as outputs of this job

0 commit comments

Comments
 (0)