Skip to content

Commit 5cd6af6

Browse files
lawrence-mbfehennestadbendichter
authored
Convert Azure Pipeline to Github Actions (#543)
* add test python requirements * migrate azure pipeline to github actions * Fix test workflow syntax - properly embed bash calls - fix artifact reference name - try to fix MATLAB test discovery * attempt to fix python setup * switch run-test to run-command * try to upload to codecov * Fix CI testing Use version of MATLAB that supports hdf5 dynamically loaded filters. * check ci env setting * fix debug pipeline * more env fixing * fix expected error test id * remove debug prints from ci * add source files to download repo * try different test suite * try different test suite (again) * Try using MATLAB R2024a for tests in workflow * Give test workflow a shorter name * Add codecov settings file * Update versions of dependent actions to latest versions * Update test badge in README.md * Rename utilities folder to tools * Add codespell workflow --------- Co-authored-by: ehennestad <ehennestad@gmail.com> Co-authored-by: Ben Dichter <ben.dichter@gmail.com>
1 parent 3be8111 commit 5cd6af6

9 files changed

+162
-50
lines changed

+tests/requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pynwb
2+
hdf5plugin

.codespellrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[codespell]
2-
skip = *.html,*logo_matnwb.svg,*fastsearch.m,*.yaml,*UpdateThirdPartyFromUpstream.sh,*testResults.xml
2+
skip = *.html,*logo_matnwb.svg,*fastsearch.m,*.yaml,*testResults.xml
33
ignore-words-list = DNE,nd,whos

.github/.codecov.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
coverage:
2+
range: "90...100"
3+
status:
4+
project:
5+
default:
6+
target: 90 # Set the desired coverage target as 90%
7+
threshold: 1 # Allowable drop in coverage
8+
patch:
9+
default:
10+
# 75% of the changed code must be covered by tests
11+
threshold: 25
12+
only_pulls: true

.github/workflows/run_codespell.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Note: This workflow allows specifying a custom location for the Codespell
2+
# configuration file by defining CONFIG_FILE as an environment variable.
3+
# A defined subset of options is extracted from this file and passed to the
4+
# Codespell action. This also ensures that the output of the codespell action
5+
# prints out the values of these options.
6+
# Todo: Generalize the extraction of codespell input arguments/options.
7+
8+
name: Codespell
9+
10+
on:
11+
pull_request:
12+
branches:
13+
- master
14+
push:
15+
branches-ignore:
16+
- master
17+
18+
jobs:
19+
codespell:
20+
name: Check for spelling errors
21+
runs-on: ubuntu-latest
22+
env:
23+
CONFIG_FILE: .codespellrc
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Extract codespell configurations from configuration file
30+
id: config
31+
run: |
32+
# Extract 'skip' value from the config file, excluding 'skip = ' part
33+
skip=$(grep -E '^skip' "$CONFIG_FILE" | sed 's/^skip *= *//')
34+
35+
# Extract 'ignore-words-list' value from the config file, excluding 'ignore-words-list = ' part
36+
ignore_words=$(grep -E '^ignore-words-list' "$CONFIG_FILE" | sed 's/^ignore-words-list *= *//')
37+
38+
# Export values as environment variables
39+
echo "SKIP=$skip" >> $GITHUB_ENV
40+
echo "IGNORE_WORDS_LIST=$ignore_words" >> $GITHUB_ENV
41+
42+
- name: Codespell
43+
uses: codespell-project/actions-codespell@v2
44+
with:
45+
skip: "${{ env.SKIP }}"
46+
ignore_words_list: "${{ env.IGNORE_WORDS_LIST }}"

.github/workflows/run_tests.yml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Run and publish MATLAB tests with coverage
2+
name: Run tests
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- master
8+
paths-ignore:
9+
- "*.md"
10+
- "*.codespellrc"
11+
- ".github/**"
12+
push:
13+
branches:
14+
- master
15+
16+
jobs:
17+
run_tests:
18+
name: Run MATLAB tests
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: check out repository
22+
uses: actions/checkout@v4
23+
- name: install python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.10'
27+
- name: configure python env
28+
run: |
29+
python -m pip install -U pip
30+
pip install -r +tests/requirements.txt
31+
echo "HDF5_PLUGIN_PATH=$(python -c "import hdf5plugin; print(hdf5plugin.PLUGINS_PATH)")" >> "$GITHUB_ENV"
32+
- name: install MATLAB
33+
uses: matlab-actions/setup-matlab@v2
34+
with:
35+
release: R2024a # this is necessary to test dynamic filters
36+
- name: run tests
37+
uses: matlab-actions/run-command@v2
38+
with:
39+
command: results = assertSuccess(nwbtest); assert(~isempty(results), 'No tests ran');
40+
- name: upload JUnit results
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: test-results
44+
path: testResults.xml
45+
retention-days: 1
46+
- name: upload coverage results
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: test-coverage
50+
path: ./coverage.xml
51+
publish_junit:
52+
name: Publish JUnit Test Results
53+
runs-on: ubuntu-latest
54+
if: ${{ always() }}
55+
needs: [run_tests]
56+
steps:
57+
- name: retrieve result files
58+
uses: actions/download-artifact@v4
59+
with:
60+
name: test-results
61+
- name: publish results
62+
uses: mikepenz/action-junit-report@v4
63+
with:
64+
report_paths: 'testResults.xml'
65+
publish_coverage:
66+
name: Publish Cobertura Test Coverage
67+
runs-on: ubuntu-latest
68+
needs: [run_tests]
69+
steps:
70+
- name: check out repository
71+
uses: actions/checkout@v4
72+
- name: retrieve code coverage files
73+
uses: actions/download-artifact@v4
74+
with:
75+
name: test-coverage
76+
- name: publish on Codecov
77+
uses: codecov/codecov-action@v4
78+
with:
79+
token: ${{ secrets.CODECOV_TOKEN }}
80+
files: coverage.xml
81+
name: codecov-matnwb
82+
verbose: true

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
![MatNWB Logo](logo/logo_matnwb_small.png)
22

33
[![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=NeurodataWithoutBorders/matnwb&file=tutorials/basicUsage.mlx)
4-
[![codecov](https://codecov.io/gh/NeurodataWithoutBorders/matnwb/branch/master/graph/badge.svg?token=apA7F24NsO)](https://codecov.io/gh/NeurodataWithoutBorders/matnwb) ![Azure DevOps tests](https://img.shields.io/azure-devops/tests/NeurodataWithoutBorders/matnwb/4)
4+
[![codecov](https://codecov.io/gh/NeurodataWithoutBorders/matnwb/branch/master/graph/badge.svg?token=apA7F24NsO)](https://codecov.io/gh/NeurodataWithoutBorders/matnwb)
5+
[![Run tests](https://github.com/NeurodataWithoutBorders/matnwb/actions/workflows/run_tests.yml/badge.svg)](https://github.com/NeurodataWithoutBorders/matnwb/actions/workflows/run_tests.yml?query=event%3Apush+branch%3Amaster)
6+
[![Codespell](https://github.com/NeurodataWithoutBorders/matnwb/actions/workflows/run_codespell.yml/badge.svg?branch=master)](https://github.com/NeurodataWithoutBorders/matnwb/actions/workflows/run_codespell.yml?query=event%3Apush+branch%3Amaster)
57

68
MatNWB is a Matlab interface for reading and writing Neurodata Without Borders (NWB) 2.x files.
79

azure-pipelines.yml

-48
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function validateCodecovSettings()
2+
% validateCodecovSettings Validate a codecov settings file.
3+
%
4+
% Note: This is a utility function developer's can use to check the
5+
% codecov settings file in .github/.codecov.yaml
6+
7+
sysCommand = sprintf("curl -X POST --data-binary @%s https://codecov.io/validate", ...
8+
fullfile(misc.getMatnwbDir, '.github', '.codecov.yaml'));
9+
10+
[status, message] = system(sysCommand);
11+
12+
assert(status == 0, 'Curl command failed')
13+
14+
assert(contains(message, 'Valid!'), ...
15+
'Codecov settings file is invalid')
16+
end

0 commit comments

Comments
 (0)