Skip to content

Commit da1aa27

Browse files
authored
Update test workflow to run lighter testing on draft PRs (#720)
* Update test workflow Updated workflow to run tests only on latest release of MATLAB for draft PRs * Create test.m * Update run_tests.yml Fixed json formatting bug * Update test.m * Update run_tests.yml Cline suggested fix for error on github runner * Update run_tests.yml Cline suggested fix for error on github runner * Update test.m * Update run_tests.yml Added step for caching pip dependencies * Update UnitTimesIOTest.m Minor fix for failing test * Remove EOF sandwich * Add comments in `set-matrix` workflow job * Delete test.m * Revert caching of pip dependencies Does not have significant speedup gains Risk having outdated versions in cache as the cache does not detect if dependencies are updated
1 parent ffbfdb2 commit da1aa27

File tree

4 files changed

+69
-32
lines changed

4 files changed

+69
-32
lines changed

+tests/+system/UnitTimesIOTest.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function addContainer(~, file)
1313
, 'waveform_mean', 5 ...
1414
);
1515
% the following is solely for a2a comparison with files.
16-
file.units.spike_times.description = 'the spike times for each unit';
16+
file.units.spike_times.description = 'the spike times for each unit in seconds';
1717
file.units.waveforms.description = ['Individual waveforms for each spike. ' ...
1818
'If the dataset is three-dimensional, the third dimension shows the response ' ...
1919
'from different electrodes that all observe this unit simultaneously. ' ...

+tests/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ scipy
22
matplotlib
33
hdf5plugin
44
dataframe_image
5-
git+https://github.com/NeurodataWithoutBorders/nwbinspector.git@dev
65
git+https://github.com/NeurodataWithoutBorders/pynwb.git@dev
6+
git+https://github.com/NeurodataWithoutBorders/nwbinspector.git@dev
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
- matlab-version: R2021a
2+
python-version: '3.9'
3+
skip-pynwb-compatibilty-test-for-tutorial: '1'
4+
- matlab-version: R2021b
5+
python-version: '3.9'
6+
skip-pynwb-compatibilty-test-for-tutorial: '1'
7+
- matlab-version: R2022a
8+
python-version: '3.9'
9+
skip-pynwb-compatibilty-test-for-tutorial: '0'
10+
- matlab-version: R2022b
11+
python-version: '3.9'
12+
skip-pynwb-compatibilty-test-for-tutorial: '0'
13+
- matlab-version: R2023a
14+
python-version: '3.10'
15+
skip-pynwb-compatibilty-test-for-tutorial: '0'
16+
- matlab-version: R2023b
17+
python-version: '3.10'
18+
skip-pynwb-compatibilty-test-for-tutorial: '0'
19+
- matlab-version: R2024a
20+
python-version: '3.11'
21+
skip-pynwb-compatibilty-test-for-tutorial: '0'
22+
- matlab-version: R2024b
23+
python-version: '3.11'
24+
skip-pynwb-compatibilty-test-for-tutorial: '0'

.github/workflows/run_tests.yml

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name: Run tests
33
on:
44
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
56
branches:
67
- main
78
paths-ignore:
@@ -14,41 +15,52 @@ on:
1415
- main
1516

1617
concurrency:
17-
group: ${{ github.ref }}
18+
group: ${{ github.workflow }}-${{ github.ref }}
1819
cancel-in-progress: true
1920

2021
jobs:
22+
set_matrix:
23+
name: Set test matrix
24+
runs-on: ubuntu-latest
25+
outputs:
26+
matrix: ${{ steps.set-matrix.outputs.matrix }}
27+
latest_matlab_version: ${{ steps.set-matrix.outputs.latest_matlab_version }}
28+
steps:
29+
- name: Check out repository
30+
uses: actions/checkout@v4
31+
32+
- name: Set matrix
33+
id: set-matrix
34+
run: |
35+
# Load the matrix configuration and extract latest version
36+
latest_matlab_version=$(yq '.[-1].matlab-version' .github/workflows/configurations/matlab_release_matrix_strategy.yml)
37+
38+
# Conditionally define the MATLAB test matrix based on the PR type.
39+
# Draft pull requests are only tested against the latest MATLAB release,
40+
# while non-draft PRs and push events are tested against all configured releases.
41+
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.draft }}" == "true" ]]; then
42+
echo "Draft PR detected - using latest MATLAB version only"
43+
# Create matrix with only the latest entry
44+
matrix=$(yq -o=json '.[-1:] | {"include": .}' .github/workflows/configurations/matlab_release_matrix_strategy.yml | tr -d '\n')
45+
else
46+
echo "Non-draft PR or push event - using full matrix"
47+
# Create matrix with all entries
48+
matrix=$(yq -o=json '{"include": .}' .github/workflows/configurations/matlab_release_matrix_strategy.yml | tr -d '\n')
49+
fi
50+
51+
# Assign `matrix` and `latest_matlab_version` as outputs of this job
52+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
53+
echo "latest_matlab_version=$latest_matlab_version" >> $GITHUB_OUTPUT
54+
2155
run_tests:
2256
name: Run MATLAB tests (${{ matrix.matlab-version }})
57+
needs: set_matrix
2358
runs-on: ubuntu-latest
59+
env:
60+
USE_CACHE: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == true }}
2461
strategy:
2562
fail-fast: false
26-
matrix:
27-
include:
28-
- matlab-version: R2021a
29-
python-version: '3.9'
30-
skip-pynwb-compatibilty-test-for-tutorial: '1'
31-
- matlab-version: R2021b
32-
python-version: '3.9'
33-
skip-pynwb-compatibilty-test-for-tutorial: '1'
34-
- matlab-version: R2022a
35-
python-version: '3.9'
36-
skip-pynwb-compatibilty-test-for-tutorial: '0'
37-
- matlab-version: R2022b
38-
python-version: '3.9'
39-
skip-pynwb-compatibilty-test-for-tutorial: '0'
40-
- matlab-version: R2023a
41-
python-version: '3.10'
42-
skip-pynwb-compatibilty-test-for-tutorial: '0'
43-
- matlab-version: R2023b
44-
python-version: '3.10'
45-
skip-pynwb-compatibilty-test-for-tutorial: '0'
46-
- matlab-version: R2024a
47-
python-version: '3.11'
48-
skip-pynwb-compatibilty-test-for-tutorial: '0'
49-
- matlab-version: R2024b
50-
python-version: '3.11'
51-
skip-pynwb-compatibilty-test-for-tutorial: '0'
63+
matrix: ${{ fromJSON(needs.set_matrix.outputs.matrix) }}
5264
steps:
5365
- name: Check out repository
5466
uses: actions/checkout@v4
@@ -70,6 +82,7 @@ jobs:
7082
uses: matlab-actions/setup-matlab@v2
7183
with:
7284
release: ${{ matrix.matlab-version }}
85+
cache: ${{ env.USE_CACHE }}
7386

7487
- name: Run tests
7588
uses: matlab-actions/run-command@v2
@@ -90,7 +103,7 @@ jobs:
90103
retention-days: 1
91104

92105
- name: Upload coverage results
93-
if: always()
106+
if: always() && matrix.matlab-version == needs.set_matrix.outputs.latest_matlab_version
94107
uses: actions/upload-artifact@v4
95108
with:
96109
name: test-coverage-${{ matrix.matlab-version }}
@@ -119,15 +132,15 @@ jobs:
119132
publish_coverage:
120133
name: Publish Cobertura test coverage
121134
runs-on: ubuntu-latest
122-
needs: [run_tests]
135+
needs: [run_tests, set_matrix]
123136
steps:
124137
- name: Check out repository
125138
uses: actions/checkout@v4
126139

127140
- name: Retrieve code coverage files
128141
uses: actions/download-artifact@v4
129142
with:
130-
name: test-coverage-R2024b
143+
name: test-coverage-${{ needs.set_matrix.outputs.latest_matlab_version }}
131144

132145
- name: Publish on coverage results on Codecov
133146
uses: codecov/codecov-action@v4

0 commit comments

Comments
 (0)