Skip to content

Commit d186e84

Browse files
authored
Merge pull request #94 from effigies/test
TEST: Add some basic tests, run CI
2 parents b096cf4 + 9c3379a commit d186e84

13 files changed

Lines changed: 1204 additions & 27 deletions

File tree

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
JUPYTER_PLATFORM_DIRS=1

.github/workflows/package.yml

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,74 @@ jobs:
4040
with:
4141
path: bsmschema
4242
attest-build-provenance-github: ${{ github.event_name != 'pull_request' }}
43+
- name: Upload uv.lock
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: Lockfile
47+
path: |
48+
uv.lock
49+
pyproject.toml
50+
51+
test:
52+
runs-on: ${{ matrix.os }}
53+
needs: [build]
54+
strategy:
55+
matrix:
56+
os: ['ubuntu-latest']
57+
source: ['repo', 'sdist']
58+
fail-fast: false
59+
60+
env:
61+
DEPENDS: ${{ matrix.dependencies }}
62+
63+
steps:
64+
- uses: actions/checkout@v4
65+
if: matrix.source == 'repo'
66+
with:
67+
submodules: recursive
68+
fetch-depth: 0
69+
- name: Download packages built by build-and-inspect-python-package
70+
if: matrix.source == 'sdist'
71+
uses: actions/download-artifact@v4
72+
with:
73+
name: Packages
74+
path: dist
75+
- name: Download lockfile
76+
if: matrix.source == 'sdist'
77+
uses: actions/download-artifact@v4
78+
with:
79+
name: Lockfile
80+
- name: Extract sdist
81+
if: matrix.source == 'sdist'
82+
run: |
83+
ls -lR
84+
mkdir -p bsmschema
85+
tar --strip-components=1 -C bsmschema -xzf dist/*.tar.gz
86+
ls -lR
87+
- name: Set up uv
88+
uses: astral-sh/setup-uv@v6
89+
- name: Install tox and coverage
90+
run: |
91+
uv tool install tox --with=tox-uv
92+
uv tool install coverage[toml]
93+
- name: Run tox
94+
run: tox run-parallel -c bsmschema/tox.ini --exit-and-dump-after 60
95+
- name: Combine coverage
96+
run: |
97+
coverage combine
98+
coverage xml
99+
working-directory: bsmschema
100+
- name: Upload coverage reports to Codecov
101+
uses: codecov/codecov-action@v5
102+
with:
103+
token: ${{ secrets.CODECOV_TOKEN }}
104+
working-directory: bsmschema
43105

44106
publish:
45107
name: Publish package to PyPI
46108
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
47109
runs-on: ubuntu-latest
48-
needs: [build]
110+
needs: [build, test]
49111
permissions:
50112
attestations: write
51113
id-token: write

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.*.swp
22
.vscode
3+
4+
dist/

bsmschema/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ build/
1010

1111
.mypy_cache/
1212
.pytest_cache/
13+
14+
.tox/
15+
16+
.coverage
17+
htmlcov

bsmschema/bsmschema/models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
# Hack to avoid unnecessary verbosity when generating documentation
3535
# Has no impact on emitted JSON, only on whether Python will attempt to cast instead of error
36-
if not TYPE_CHECKING and 'sphinxcontrib.autodoc_pydantic' in sys.modules:
36+
if not TYPE_CHECKING and 'sphinxcontrib.autodoc_pydantic' in sys.modules: # pragma: no cover
3737
StrictStr = str # noqa: F811
3838
StrictInt = int # noqa: F811
3939
StrictFloat = float # noqa: F811
@@ -126,7 +126,6 @@ class Edge(_BSMBase):
126126
Destination: StrictStr
127127
"""Name of :py:class:`Node`. The outputs of :py:attr:`Source` are passed to this node.
128128
129-
If :py:attr:`Filter` is defined,
130129
The outputs of the Source node are the inputs of the Destination node, after filtering (if any)."""
131130
Filter: OptionalFilter = None
132131
"""Maps a grouping variable to a list of values to pass to Destination.

bsmschema/pyproject.toml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ dependencies = [
1616
]
1717
classifiers = [
1818
"Programming Language :: Python :: 3",
19-
"Programming Language :: Python :: 3.8",
2019
"Programming Language :: Python :: 3.9",
2120
"Programming Language :: Python :: 3.10",
2221
"Programming Language :: Python :: 3.11",
23-
"Development Status :: 3 - Alpha",
22+
"Programming Language :: Python :: 3.12",
23+
"Programming Language :: Python :: 3.13",
24+
"Development Status :: 4 - Beta",
2425
"License :: OSI Approved :: Apache Software License",
2526
]
2627
dynamic = ["version"]
@@ -29,6 +30,18 @@ dynamic = ["version"]
2930
Homepage = "https://bids-standard.github.io/stats-models/"
3031
"Source code" = "https://github.com/bids-standard/stats-models"
3132

33+
[dependency-groups]
34+
test = [
35+
"pytest >=8",
36+
"acres >=0.2",
37+
"coverage[toml] >=7",
38+
"pytest-cov >=6",
39+
]
40+
types = [
41+
"mypy",
42+
"pyright",
43+
]
44+
3245
[tool.hatch.build.targets.wheel]
3346
packages = ["bsmschema"]
3447

@@ -47,3 +60,7 @@ quote-style = "single"
4760

4861
[tool.mypy]
4962
strict = true
63+
64+
[tool.coverage.run]
65+
parallel = true
66+
branch = true

bsmschema/tests/__init__.py

Whitespace-only changes.

bsmschema/tests/data/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import acres
2+
3+
load = acres.Loader(__spec__.name)

bsmschema/tests/data/examples

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../specification/examples

bsmschema/tests/test_load.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from bsmschema.models import BIDSStatsModel
2+
3+
from . import data
4+
5+
6+
def test_load():
7+
example = data.load.readable('examples', 'model-example_smdl.json')
8+
model = BIDSStatsModel.model_validate_json(example.read_text())
9+
10+
assert model.Name == 'my_first_model'
11+
assert len(model.Nodes) == 3
12+
assert len(model.Edges) == 2

0 commit comments

Comments
 (0)