Skip to content

Update test workflow to run lighter testing on draft PRs #720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion +tests/+system/UnitTimesIOTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function addContainer(~, file)
, 'waveform_mean', 5 ...
);
% the following is solely for a2a comparison with files.
file.units.spike_times.description = 'the spike times for each unit';
file.units.spike_times.description = 'the spike times for each unit in seconds';
file.units.waveforms.description = ['Individual waveforms for each spike. ' ...
'If the dataset is three-dimensional, the third dimension shows the response ' ...
'from different electrodes that all observe this unit simultaneously. ' ...
Expand Down
2 changes: 1 addition & 1 deletion +tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ scipy
matplotlib
hdf5plugin
dataframe_image
git+https://github.com/NeurodataWithoutBorders/nwbinspector.git@dev
git+https://github.com/NeurodataWithoutBorders/pynwb.git@dev
git+https://github.com/NeurodataWithoutBorders/nwbinspector.git@dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- matlab-version: R2021a
python-version: '3.9'
skip-pynwb-compatibilty-test-for-tutorial: '1'
- matlab-version: R2021b
python-version: '3.9'
skip-pynwb-compatibilty-test-for-tutorial: '1'
- matlab-version: R2022a
python-version: '3.9'
skip-pynwb-compatibilty-test-for-tutorial: '0'
- matlab-version: R2022b
python-version: '3.9'
skip-pynwb-compatibilty-test-for-tutorial: '0'
- matlab-version: R2023a
python-version: '3.10'
skip-pynwb-compatibilty-test-for-tutorial: '0'
- matlab-version: R2023b
python-version: '3.10'
skip-pynwb-compatibilty-test-for-tutorial: '0'
- matlab-version: R2024a
python-version: '3.11'
skip-pynwb-compatibilty-test-for-tutorial: '0'
- matlab-version: R2024b
python-version: '3.11'
skip-pynwb-compatibilty-test-for-tutorial: '0'
73 changes: 43 additions & 30 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: Run tests
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
paths-ignore:
Expand All @@ -14,41 +15,52 @@ on:
- main

concurrency:
group: ${{ github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
set_matrix:
name: Set test matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
latest_matlab_version: ${{ steps.set-matrix.outputs.latest_matlab_version }}
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set matrix
id: set-matrix
run: |
# Load the matrix configuration and extract latest version
latest_matlab_version=$(yq '.[-1].matlab-version' .github/workflows/configurations/matlab_release_matrix_strategy.yml)

# Conditionally define the MATLAB test matrix based on the PR type.
# Draft pull requests are only tested against the latest MATLAB release,
# while non-draft PRs and push events are tested against all configured releases.
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.draft }}" == "true" ]]; then
echo "Draft PR detected - using latest MATLAB version only"
# Create matrix with only the latest entry
matrix=$(yq -o=json '.[-1:] | {"include": .}' .github/workflows/configurations/matlab_release_matrix_strategy.yml | tr -d '\n')
else
echo "Non-draft PR or push event - using full matrix"
# Create matrix with all entries
matrix=$(yq -o=json '{"include": .}' .github/workflows/configurations/matlab_release_matrix_strategy.yml | tr -d '\n')
fi

# Assign `matrix` and `latest_matlab_version` as outputs of this job
echo "matrix=$matrix" >> $GITHUB_OUTPUT
echo "latest_matlab_version=$latest_matlab_version" >> $GITHUB_OUTPUT

run_tests:
name: Run MATLAB tests (${{ matrix.matlab-version }})
needs: set_matrix
runs-on: ubuntu-latest
env:
USE_CACHE: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == true }}
strategy:
fail-fast: false
matrix:
include:
- matlab-version: R2021a
python-version: '3.9'
skip-pynwb-compatibilty-test-for-tutorial: '1'
- matlab-version: R2021b
python-version: '3.9'
skip-pynwb-compatibilty-test-for-tutorial: '1'
- matlab-version: R2022a
python-version: '3.9'
skip-pynwb-compatibilty-test-for-tutorial: '0'
- matlab-version: R2022b
python-version: '3.9'
skip-pynwb-compatibilty-test-for-tutorial: '0'
- matlab-version: R2023a
python-version: '3.10'
skip-pynwb-compatibilty-test-for-tutorial: '0'
- matlab-version: R2023b
python-version: '3.10'
skip-pynwb-compatibilty-test-for-tutorial: '0'
- matlab-version: R2024a
python-version: '3.11'
skip-pynwb-compatibilty-test-for-tutorial: '0'
- matlab-version: R2024b
python-version: '3.11'
skip-pynwb-compatibilty-test-for-tutorial: '0'
matrix: ${{ fromJSON(needs.set_matrix.outputs.matrix) }}
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand All @@ -70,6 +82,7 @@ jobs:
uses: matlab-actions/setup-matlab@v2
with:
release: ${{ matrix.matlab-version }}
cache: ${{ env.USE_CACHE }}

- name: Run tests
uses: matlab-actions/run-command@v2
Expand All @@ -90,7 +103,7 @@ jobs:
retention-days: 1

- name: Upload coverage results
if: always()
if: always() && matrix.matlab-version == needs.set_matrix.outputs.latest_matlab_version
uses: actions/upload-artifact@v4
with:
name: test-coverage-${{ matrix.matlab-version }}
Expand Down Expand Up @@ -119,15 +132,15 @@ jobs:
publish_coverage:
name: Publish Cobertura test coverage
runs-on: ubuntu-latest
needs: [run_tests]
needs: [run_tests, set_matrix]
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Retrieve code coverage files
uses: actions/download-artifact@v4
with:
name: test-coverage-R2024b
name: test-coverage-${{ needs.set_matrix.outputs.latest_matlab_version }}

- name: Publish on coverage results on Codecov
uses: codecov/codecov-action@v4
Expand Down
Loading