Skip to content

Commit 11a6ade

Browse files
authored
Merge pull request #89 from bids-standard/mnt/misc
MNT: Miscellaneous cleanups and process improvements
2 parents e52ced0 + 40cbfbb commit 11a6ade

File tree

14 files changed

+1696
-99
lines changed

14 files changed

+1696
-99
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Mon Feb 3 13:04:18 2025 -0500 - markiewicz@stanford.edu - sty: ruff format [ignore-rev]
2+
5970ba32048444aa3a64a56d8122deeb4282b411

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: monthly
7+
groups:
8+
actions-infrastructure:
9+
patterns:
10+
- actions/*
11+
- package-ecosystem: uv
12+
directory: /
13+
schedule:
14+
interval: weekly

.github/workflows/gh-pages.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,16 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10-
strategy:
11-
matrix:
12-
python: ["3.11"]
1310
steps:
14-
- uses: actions/checkout@v3
15-
- name: Set up Python ${{ matrix.python }}
16-
uses: actions/setup-python@v4
17-
with:
18-
python-version: ${{ matrix.python }}
19-
- name: Install dependencies
20-
run: |
21-
pip install --upgrade pip
22-
pip install -r requirements.txt
11+
- uses: actions/checkout@v4
12+
- name: Set up uv
13+
uses: astral-sh/setup-uv@v6
14+
- name: Sync environment
15+
run: uv sync
2316
- name: Generate schemas
24-
run: python -m bsmschema specification/schema/
17+
run: uv run -m bsmschema specification/schema/
2518
- name: Build
26-
run: jb build -W specification
19+
run: uv run jb build -W specification
2720
- uses: peaceiris/actions-gh-pages@v3
2821
if: ${{ github.ref == 'refs/heads/main' }}
2922
with:

.github/workflows/package.yml

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,54 @@ on:
88
- rel/*
99
tags:
1010
- '*'
11+
pull_request:
12+
branches:
13+
- main
14+
- maint/*
15+
workflow_dispatch:
1116

1217
defaults:
1318
run:
1419
shell: bash
1520

21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
permissions:
26+
contents: read
27+
1628
jobs:
17-
package:
18-
# Build packages and upload
19-
runs-on: ${{ matrix.os }}
20-
strategy:
21-
matrix:
22-
include:
23-
- os: ubuntu-latest
24-
python-version: "3"
29+
build:
30+
name: Build & verify package
31+
runs-on: ubuntu-latest
32+
permissions:
33+
attestations: write
34+
id-token: write
2535
steps:
26-
- uses: actions/checkout@v3
36+
- uses: actions/checkout@v4
2737
with:
28-
submodules: recursive
2938
fetch-depth: 0
30-
- name: Set up Python ${{ matrix.python-version }}
31-
uses: actions/setup-python@v4
39+
- uses: hynek/build-and-inspect-python-package@v2
3240
with:
33-
python-version: ${{ matrix.python-version }}
34-
- name: Display Python version
35-
run: python -c "import sys; print(sys.version)"
36-
- name: Build sdist and wheel
37-
run: pipx run build bsmschema
38-
- name: Upload to PyPI (on tags)
39-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
40-
uses: pypa/gh-action-pypi-publish@release/v1
41+
path: bsmschema
42+
attest-build-provenance-github: ${{ github.event_name != 'pull_request' }}
43+
44+
publish:
45+
name: Publish package to PyPI
46+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
47+
runs-on: ubuntu-latest
48+
needs: [build]
49+
permissions:
50+
attestations: write
51+
id-token: write
52+
53+
steps:
54+
- name: Download packages built by build-and-inspect-python-package
55+
uses: actions/download-artifact@v4
4156
with:
42-
user: __token__
43-
password: ${{ secrets.PYPI_API_TOKEN }}
44-
packages-dir: bsmschema/dist
57+
name: Packages
58+
path: dist
59+
60+
- name: Upload package to PyPI
61+
uses: pypa/gh-action-pypi-publish@release/v1

Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,19 @@ validate_cff: CITATION.cff ## Makes sure the CITATION.cff file is valid. (pip in
2121
cffconvert --validate
2222

2323
test: ## Build the book, checks for dead link and fail on warning
24-
jupyter-book build specification --warningiserror --builder linkcheck
24+
uv run jupyter-book build specification --warningiserror --builder linkcheck
2525

26-
html: ## Build html version of the book
27-
jupyter-book build specification
26+
html: specification/schema ## Build html version of the book
27+
uv run jupyter-book build specification
2828

2929
serve: html ## Serve the built website
3030
python -m http.server -d specification/_build/html/
3131

3232
pdfhtml: ## Build pdf version of the book from html (requires pyppeteer)
33-
jupyter-book build specification --builder pdfhtml
33+
uv run jupyter-book build specification --builder pdfhtml
3434

3535
pdflatex: ## Build pdf version of the book from latex
36-
jb build specification --builder pdflatex
36+
uv run jb build specification --builder pdflatex
3737

38+
specification/schema:
39+
uv run -m bsmschema specification/schema/

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,29 @@ BIDSStatsModel.parse_file('stats-models/specification/examples/model-example_smd
4141

4242
## Building the documentation locally
4343

44-
1) Install the requirements, including the local copy of `bsmschema`:
45-
46-
```
47-
pip install -r requirements.txt
48-
```
44+
We recommend using the [uv] tool to ensure reproducible builds.
4945

5046
1) Build the schema files to ensure the local validator will work:
5147

5248
```
53-
python -m bsmschema specification/schema
49+
uv run -m bsmschema specification/schema
5450
```
5551

5652

5753
1) Build the JupyterBook:
5854

5955
```
60-
jb build specification
56+
uv run jb build specification
6157
```
6258

6359
1) Serve the built website:
6460

6561
```
66-
python -m http.server -d specification/_build/html/
62+
uv run -m http.server -d specification/_build/html/
6763
```
6864

6965
Note that this will start a long-running web-server that will occupy your terminal.
70-
`Ctrl-C` quits.
66+
`Ctrl-C` quits.
67+
68+
69+
[uv]: https://docs.astral.sh/uv/

bsmschema/bsmschema/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
from . import models
2+
3+
__all__ = ['models']

bsmschema/bsmschema/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
if __name__ == '__main__':
66
if len(sys.argv) != 2:
7-
print("Usage: python -m bsmschema /path/to/schemadir")
7+
print('Usage: python -m bsmschema /path/to/schemadir')
88
sys.exit(1)
99

10-
schemadir = Path(sys.argv[1])
10+
schemadir = Path(sys.argv[1])
1111
schemadir.mkdir(parents=True, exist_ok=True)
1212
for mname in models.__all__:
1313
model = getattr(models, mname)
14-
Path.write_text(schemadir / f"{mname}.json", model.schema_json(indent=2))
14+
Path.write_text(schemadir / f'{mname}.json', model.schema_json(indent=2))

0 commit comments

Comments
 (0)