Skip to content

Commit 7812824

Browse files
Adding testing to the CI. (#105)
Fix #104 Fix #109 --------- Co-authored-by: Taylor Hanayik <[email protected]>
1 parent a84e773 commit 7812824

19 files changed

+273
-103
lines changed

.github/workflows/ci.yml

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,28 @@ jobs:
1616
- uses: actions/setup-python@v5
1717
with:
1818
python-version: "3.12"
19-
- run: |
19+
# Run Ruff
20+
- name: Run Ruff
21+
run: |
2022
pip install uv
2123
uv pip install --system ruff
2224
ruff check
25+
# Run Codespell
26+
- name: Run Codespell
27+
run: |
28+
pip install codespell
29+
codespell codespell src/**/*.py
2330
2431
Test:
2532
runs-on: ubuntu-latest
2633
strategy:
2734
matrix:
28-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
35+
python-version: ["3.9", "3.10", "3.11", "3.12"]
36+
os:
37+
- ubuntu-latest
38+
- macos-latest # arm64 (Apple Silicon)
39+
- macos-13 # latest Intel release
40+
- windows-latest
2941

3042
steps:
3143
- uses: actions/checkout@v4
@@ -37,9 +49,70 @@ jobs:
3749
with:
3850
python-version: ${{ matrix.python-version }}
3951
- run: |
40-
pipx install hatch
41-
hatch run test
42-
52+
pip install pytest-notebook
53+
pip install pre-commit
54+
pre-commit run --all
55+
pre-commit install
56+
# pipx install hatch
57+
# hatch run test --cover --nb-test-files
58+
- name: Install IPyNiiVue & Deps
59+
run: pip install -e .
60+
- name: Test import
61+
run: |
62+
python -c "import ipyniivue"
63+
- name: Test IPyNiiVue
64+
run: |
65+
pip install pytest-cov
66+
pip install --upgrade pip ipython ipykernel
67+
ipython kernel install --name "python3" --user
68+
mkdir -p ./reports
69+
pytest --cov --cov-report=json:./reports/coverage.json --cov-report=xml:./reports/coverage.xml
70+
- name: Upload ipyniivue test coverage report
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: coverage_ipyniivue-${{ matrix.os }}-py${{ matrix.python-version }}
74+
path: ./reports/coverage.json
75+
- name: Generate Markdown summary of code coverage
76+
uses: irongut/[email protected]
77+
with:
78+
filename: ./reports/coverage.xml
79+
format: markdown
80+
output: both
81+
thresholds: "10 10"
82+
- name: Add test results to job summary
83+
run: |
84+
cat ./code-coverage-results.md >> $GITHUB_STEP_SUMMARY
85+
- name: Test example notebooks
86+
run: |
87+
pip install nbmake
88+
rm -rf ./reports
89+
mkdir -p ./reports
90+
pytest --nbmake examples/*ipynb --cov --cov-report=json:./reports/coverage.json --cov-report=xml:./reports/coverage.xml
91+
- name: Upload ipyniivue example notbooks coverage report
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: coverage_ipyniivue_notebooks-${{ matrix.os }}-py${{ matrix.python-version }}
95+
path: ./reports/coverage.json
96+
- name: Generate Markdown summary of code coverage
97+
uses: irongut/[email protected]
98+
with:
99+
filename: ./reports/coverage.xml
100+
format: markdown
101+
output: both
102+
thresholds: "10 10"
103+
- name: Add test results to job summary
104+
run: |
105+
cat ./code-coverage-results.md >> $GITHUB_STEP_SUMMARY
106+
# coverage run -m pytest --nb-test-files
107+
# nbt-test-files check for changes in the output of the notebook.
108+
# This does not work for our purpose since we wipe the output
109+
# before committing changes to facilitate integration with git.
110+
# - name: Upload coverage to codecov (Only do this for the ubuntu-latest job)
111+
# if: matrix.os == 'ubuntu-latest'
112+
# uses: codecov/codecov-action@v5
113+
# with:
114+
# token: ${{secrets.CODECOV_TOKEN}}
115+
#
43116
LintJavaScript:
44117
name: JavaScript / Lint
45118
runs-on: macos-14

examples/additive_voxels.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@
9292
"mimetype": "text/x-python",
9393
"name": "python",
9494
"nbconvert_exporter": "python",
95-
"pygments_lexer": "ipython3",
96-
"version": "3.11.6"
95+
"pygments_lexer": "ipython3"
9796
},
9897
"widgets": {
9998
"application/vnd.jupyter.widget-state+json": {

examples/basic_multiplanar.ipynb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,6 @@
7878
"nv.is_colorbar = True\n",
7979
"nv.view_mode_hot_key = \"KeyN\""
8080
]
81-
},
82-
{
83-
"cell_type": "code",
84-
"execution_count": null,
85-
"metadata": {},
86-
"outputs": [],
87-
"source": []
8881
}
8982
],
9083
"metadata": {
@@ -102,8 +95,7 @@
10295
"mimetype": "text/x-python",
10396
"name": "python",
10497
"nbconvert_exporter": "python",
105-
"pygments_lexer": "ipython3",
106-
"version": "3.11.6"
98+
"pygments_lexer": "ipython3"
10799
}
108100
},
109101
"nbformat": 4,

examples/drawing.ipynb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,6 @@
109109
"for widget in widgetArray:\n",
110110
" display(widget[\"widget\"])"
111111
]
112-
},
113-
{
114-
"cell_type": "code",
115-
"execution_count": null,
116-
"id": "32e9b296-bae2-47c4-9912-e99e5cb6a85e",
117-
"metadata": {},
118-
"outputs": [],
119-
"source": []
120112
}
121113
],
122114
"metadata": {
@@ -134,8 +126,7 @@
134126
"mimetype": "text/x-python",
135127
"name": "python",
136128
"nbconvert_exporter": "python",
137-
"pygments_lexer": "ipython3",
138-
"version": "3.12.3"
129+
"pygments_lexer": "ipython3"
139130
}
140131
},
141132
"nbformat": 4,

examples/example_sideview.ipynb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "52de1125",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"# This is not part of IPyNiiVue dependencies so it has to be installed independently\n",
11+
"!pip install ipylab"
12+
]
13+
},
314
{
415
"cell_type": "code",
516
"execution_count": null,
@@ -81,14 +92,6 @@
8192
"nv.volumes[0].opacity = 0.5\n",
8293
"nv.volumes[1].colormap = \"green\""
8394
]
84-
},
85-
{
86-
"cell_type": "code",
87-
"execution_count": null,
88-
"id": "c7b34b44-2940-4f0e-99b5-2e16ad3d23f3",
89-
"metadata": {},
90-
"outputs": [],
91-
"source": []
9295
}
9396
],
9497
"metadata": {
@@ -106,8 +109,7 @@
106109
"mimetype": "text/x-python",
107110
"name": "python",
108111
"nbconvert_exporter": "python",
109-
"pygments_lexer": "ipython3",
110-
"version": "3.11.6"
112+
"pygments_lexer": "ipython3"
111113
},
112114
"widgets": {
113115
"application/vnd.jupyter.widget-state+json": {

examples/mesh_and_volume.ipynb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,6 @@
6363
"\n",
6464
"nv"
6565
]
66-
},
67-
{
68-
"cell_type": "code",
69-
"execution_count": null,
70-
"id": "851a559d-59e8-40bc-b1f0-9380f9844855",
71-
"metadata": {},
72-
"outputs": [],
73-
"source": []
7466
}
7567
],
7668
"metadata": {
@@ -88,8 +80,7 @@
8880
"mimetype": "text/x-python",
8981
"name": "python",
9082
"nbconvert_exporter": "python",
91-
"pygments_lexer": "ipython3",
92-
"version": "3.11.6"
83+
"pygments_lexer": "ipython3"
9384
}
9485
},
9586
"nbformat": 4,

examples/mesh_layers.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@
8989
"mimetype": "text/x-python",
9090
"name": "python",
9191
"nbconvert_exporter": "python",
92-
"pygments_lexer": "ipython3",
93-
"version": "3.12.3"
92+
"pygments_lexer": "ipython3"
9493
},
9594
"widgets": {
9695
"application/vnd.jupyter.widget-state+json": {

examples/prototypes/meshes_(GIfTI, FreeSurfer, MZ3, OBJ, STL, legacy VTK).ipynb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@
5353
"\n",
5454
"# nv1.setMeshShader(nv1.meshes[0].id, \"Outline\"); does not seem to exist yet."
5555
]
56-
},
57-
{
58-
"cell_type": "code",
59-
"execution_count": null,
60-
"metadata": {},
61-
"outputs": [],
62-
"source": []
6356
}
6457
],
6558
"metadata": {
@@ -77,8 +70,7 @@
7770
"mimetype": "text/x-python",
7871
"name": "python",
7972
"nbconvert_exporter": "python",
80-
"pygments_lexer": "ipython3",
81-
"version": "3.11.6"
73+
"pygments_lexer": "ipython3"
8274
}
8375
},
8476
"nbformat": 4,

examples/prototypes/torso_regions.ipynb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,6 @@
8383
"}\n",
8484
"nv.setDrawColormap(cmap);"
8585
]
86-
},
87-
{
88-
"cell_type": "code",
89-
"execution_count": null,
90-
"id": "94a1c95a-308b-4259-ac29-7512c48239b2",
91-
"metadata": {},
92-
"outputs": [],
93-
"source": []
9486
}
9587
],
9688
"metadata": {
@@ -108,8 +100,7 @@
108100
"mimetype": "text/x-python",
109101
"name": "python",
110102
"nbconvert_exporter": "python",
111-
"pygments_lexer": "ipython3",
112-
"version": "3.11.6"
103+
"pygments_lexer": "ipython3"
113104
}
114105
},
115106
"nbformat": 4,

examples/prototypes/trajectory.ipynb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@
6161
"\n",
6262
"nv"
6363
]
64-
},
65-
{
66-
"cell_type": "code",
67-
"execution_count": null,
68-
"metadata": {},
69-
"outputs": [],
70-
"source": []
7164
}
7265
],
7366
"metadata": {
@@ -85,8 +78,7 @@
8578
"mimetype": "text/x-python",
8679
"name": "python",
8780
"nbconvert_exporter": "python",
88-
"pygments_lexer": "ipython3",
89-
"version": "3.11.6"
81+
"pygments_lexer": "ipython3"
9082
}
9183
},
9284
"nbformat": 4,

0 commit comments

Comments
 (0)