Skip to content

Commit

Permalink
Merge branch 'master' into fix/acquisitionduration
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies authored Jan 10, 2025
2 parents 32a7f80 + c453524 commit d60fe83
Show file tree
Hide file tree
Showing 78 changed files with 698 additions and 419 deletions.
45 changes: 35 additions & 10 deletions .github/workflows/publish_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- "master"
- "maint/*"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -34,13 +35,27 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: 3
- run: env
- run: git status
- name: Determine master/maintenance branch
id: branch
run: |
if [[ "$GITHUB_REF_NAME" = "master" ]]; then
echo "branch=jsr-dist" | tee -a $GITHUB_OUTPUT
echo "mode=dev" | tee -a $GITHUB_OUTPUT
else
echo "branch=jsr-maint" | tee -a $GITHUB_OUTPUT
echo "mode=maint" | tee -a $GITHUB_OUTPUT
fi
- name: Install bidsschematools
run: |
pip install --upgrade tools/schemacode
git clean -fxd tools/schemacode
- name: Checkout jsr-dist
- name: Checkout ${{ steps.branch.outputs.branch }}
run: |
git checkout -t origin/jsr-dist
git checkout -t origin/$JSR_BRANCH
env:
JSR_BRANCH: ${{ steps.branch.outputs.branch }}
- name: Regenerate schema
run: bst export > schema.json
- name: Regenerate context types
Expand All @@ -54,36 +69,46 @@ jobs:
bst export-metaschema > /tmp/schema.json
npx --package=json-schema-to-typescript json2ts --unknownAny /tmp/schema.json > metaschema.ts
- name: Determine next version
id: version
run: |
BASE=$( jq -r .schema_version schema.json )
if [[ "$BASE" =~ ^[0-9]*.[0-9]*.[0-9]*$ ]]; then
if [[ "$BASE" =~ ^[0-9]*\.[0-9]*\.[0-9]*$ ]]; then
# Release, so unconditionally update version
VERSION=$BASE
jq ".version = \"$VERSION\"" jsr.json > tmp.json && mv tmp.json jsr.json
else
echo release=true | tee -a $GITHUB_OUTPUT
elif [[ "$BASE" =~ ^[0-9]*\.[0-9]*\.[0-9]*\.post[0-9]*$ ]]; then
# Post-release, so replace .post with + for JSR semver
VERSION=${BASE/.post/+}
jq ".version = \"$VERSION\"" jsr.json > tmp.json && mv tmp.json jsr.json
echo release=true | tee -a $GITHUB_OUTPUT
elif [[ "$GITHUB_REF_NAME" = "master" ]]; then
DENOVER=$( jq -r .version jsr.json )
# Get the reference of the latest commit to touch the schema directory
HASH=$( git log -n 1 --pretty=%h $REF -- src/schema )
HASH=$( git log -n 1 --pretty=%h $GITHUB_REF -- src/schema )
if [[ $DENOVER =~ ^"$BASE".[0-9] ]]; then
PREFIX=${DENOVER%+*}
let SERIAL=1+${PREFIX#$BASE.}
else
SERIAL=1
fi
VERSION="$BASE.$SERIAL+$HASH"
echo release=true | tee -a $GITHUB_OUTPUT
else
echo release=false | tee -a $GITHUB_OUTPUT
fi
echo VERSION=$VERSION | tee -a $GITHUB_ENV
env:
REF: ${{ github.ref }}
- name: Check for changes, set version and commit
echo version=$VERSION | tee -a $GITHUB_OUTPUT
- name: Bump version (${{ steps.version.outputs.version }}) if changed
if: steps.version.outputs.release == 'true'
run: |
if ! git diff -s --exit-code; then
jq ".version = \"$VERSION\"" jsr.json > tmp.json && mv tmp.json jsr.json
git add jsr.json schema.json context.ts metaschema.ts
git commit -m "Update schema JSR distribution"
git commit -m "Update schema JSR distribution ($VERSION)"
git push
fi
- name: Publish to JSR
if: success()
if: success() && steps.version.outputs.release == 'true'
run: |
npx jsr publish
23 changes: 16 additions & 7 deletions .github/workflows/schemacode_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ on:
push:
branches:
- "master"
- "maint/*"
tags:
- "schema-*"
pull_request:
branches:
- "master"
- "maint/*"
- "*"

concurrency:
Expand Down Expand Up @@ -36,7 +39,9 @@ jobs:
run: pip install --upgrade tools/schemacode[all]
if: ${{ startsWith(github.ref, 'refs/tags/schema-') }}
- name: "Build archive on tag"
run: pytest tools/schemacode/bidsschematools -k make_archive
run: |
python -m pytest -k make_archive
working-directory: tools/schemacode
env:
BIDSSCHEMATOOLS_RELEASE: 1
if: ${{ startsWith(github.ref, 'refs/tags/schema-') }}
Expand Down Expand Up @@ -87,14 +92,15 @@ jobs:
- name: "Run tests"
run: |
python -m pytest -vs --pyargs bidsschematools -m "not validate_schema" \
--cov-append --cov-report=xml --cov=bidsschematools --doctest-modules
python -m pytest -vs --doctest-modules -m "not validate_schema" \
--cov-append --cov-report=xml --cov-report=term --cov=src/bidsschematools
working-directory: tools/schemacode

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: unit_${{ matrix.os }}_${{ matrix.python-version }}
path: coverage.xml
path: tools/schemacode/coverage.xml
if: success()

publish:
Expand Down Expand Up @@ -143,13 +149,16 @@ jobs:
python -m pip install -e ./tools/schemacode[all]
- name: Run schema validation tests
run: python -m pytest --pyargs bidsschematools -m "validate_schema" --cov-append --cov-report=xml --cov=bidsschematools
run: |
python -m pytest -vs --doctest-modules -m "not validate_schema" \
--cov-append --cov-report=xml --cov-report=term --cov=src/bidsschematools
working-directory: tools/schemacode

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: schema_validation
path: coverage.xml
path: tools/schemacode/coverage.xml
if: success()

upload_to_codecov:
Expand All @@ -164,7 +173,7 @@ jobs:
uses: actions/download-artifact@v4

- name: Upload to CodeCov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required but might help API rate limits
fail_ci_if_error: true
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
# See https://pre-commit.com/hooks.html for more hooks
ci:
skip: [shellcheck]
exclude: 'tools/schemacode/bidsschematools/tests/data/broken_dataset_description.json'
exclude: 'tools/schemacode/src/bidsschematools/tests/data/broken_dataset_description.json'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args: [--unsafe]
- id: check-json
- id: check-toml
- id: check-ast
- id: check-added-large-files
- id: check-case-conflict
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.4
rev: 0.30.0
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand Down Expand Up @@ -73,7 +74,7 @@ repos:
- id: codespell
args: ["--config=.codespellrc", "--dictionary=-", "--dictionary=.codespell_dict"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.12.1
rev: v1.14.1
hooks:
- id: mypy
# Sync with project.optional-dependencies.typing
Expand All @@ -89,7 +90,7 @@ repos:
- types-jsonschema
- jsonschema
- httpx
args: ["tools/schemacode/bidsschematools"]
args: ["tools/schemacode/src"]
pass_filenames: false
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
Expand Down
49 changes: 0 additions & 49 deletions CODE_OF_CONDUCT.md

This file was deleted.

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ We hope that these guidelines are designed to make it as easy as possible to get
If you have any questions that aren't discussed below, please let us know
by [opening an issue](https://github.com/bids-standard/bids-specification/issues/new).

If you are not familiar with Git ansd GitHub,
If you are not familiar with Git and GitHub,
check our [generic contributing guidelines](https://bids-website.readthedocs.io/en/latest/collaboration/bids_github/CONTRIBUTING.html).

If you want to contribute to the BIDS website,
If you want to contribute to the BIDS specification,
make sure you also read the instructions below.

## Table of contents
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[![Validation](https://github.com/bids-standard/bids-specification/actions/workflows/validation.yml/badge.svg)](https://github.com/bids-standard/bids-specification/actions/workflows/validation.yml)
[![CircleCI](https://circleci.com/gh/bids-standard/bids-specification.svg?style=shield)](https://circleci.com/gh/bids-standard/bids-specification)
[![Bluesky Follow](https://img.shields.io/badge/bluesky-Follow_bidsstandard-blue?logo=bluesky)](https://bsky.app/profile/bidsstandard.bsky.social)
![YouTube Channel Subscribers](https://img.shields.io/youtube/channel/subscribers/UCxZUcYfd_nvIVWAbzRB1tlw)
[![Mastodon Follow](https://img.shields.io/mastodon/follow/109520103085644521?domain=https%3A%2F%2Ffosstodon.org%2F)](https://fosstodon.org/@bidsstandard)
[![@BIDSstandard](https://img.shields.io/twitter/follow/bidsstandard.svg?style=social)](https://x.com/BIDSstandard)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3686061.svg)](https://doi.org/10.5281/zenodo.3686061)
Expand Down
4 changes: 4 additions & 0 deletions Release_Protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ You can also make use of the `exclude-from-changelog` label.
Adding this label to PRs in the GitHub web interface will prevent the changelog generator from
considering this item for inclusion in the changelog.

#### 2.5 Update the schema

Add the new version to `src/schema/meta/versions.yaml`.

### 3. Commit changes and push to upstream

By pushing `rel/` branches to the main repository, the chances of continuous integration
Expand Down
11 changes: 10 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,21 @@ extra:
link: https://www.instagram.com/bidsstandard/
- icon: fontawesome/brands/youtube
link: https://www.youtube.com/channel/UCxZUcYfd_nvIVWAbzRB1tlw
analytics:
provider: google
property: G-SBWH6YNMPX

extra_javascript:
- js/jquery-3.6.0.min.js
markdown_extensions:
- toc:
anchorlink: true
- pymdownx.superfences
- pymdownx.superfences:
preserve_tabs: true
custom_fences:
- name: tsv
class: tsv
format: !!python/name:bidsschematools.render.tsv.fence
- admonition
- pymdownx.details
plugins:
Expand All @@ -113,6 +121,7 @@ plugins:
- css/watermark.css
- macros:
module_name: tools/mkdocs_macros_bids/main
on_error_fail: true
- redirects:
redirect_maps:
"01-introduction.md": "introduction.md"
Expand Down
2 changes: 1 addition & 1 deletion pdf_build_src/pandoc_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _flatten_values(lst):
fname_mkdocs_yml = _find(HERE, "mkdocs.yml")

with open(fname_mkdocs_yml, "r") as stream:
mkdocs_yml = yaml.safe_load(stream)
mkdocs_yml = yaml.load(stream, yaml.Loader)

sections = mkdocs_yml["nav"][0]["The BIDS Specification"]

Expand Down
32 changes: 24 additions & 8 deletions readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
version: 2

build:
os: ubuntu-22.04
apt_packages:
- jq
os: ubuntu-lts-latest
tools:
python: "3.11"
python: latest
jobs:
# The *_create_environment and post_install steps replace RTD's virtual environment
# steps with uv, a much faster alternative to virtualenv+pip.
pre_create_environment:
# Install jq and uv
- asdf plugin add jq https://github.com/lsanwick/asdf-jq.git
- asdf plugin add uv https://github.com/asdf-community/asdf-uv.git
- asdf install jq latest
- asdf install uv latest
- asdf global jq latest
- asdf global uv latest
# Turn `python -m virtualenv` into `python -c pass`
- truncate --size 0 $( dirname $( uv python find ) )/../lib/python3*/site-packages/virtualenv/__main__.py
post_create_environment:
- uv venv $READTHEDOCS_VIRTUALENV_PATH
# Turn `python -m pip` into `python -c pass`
- truncate --size 0 $( ls -d $READTHEDOCS_VIRTUALENV_PATH/lib/python3* )/site-packages/pip.py
# post_install replaces the top-level {python: {install: [{requirements: requirements.txt}]}}
post_install:
# Use a cache dir in the same mount to halve the install time
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install --cache-dir $READTHEDOCS_VIRTUALENV_PATH/../../uv_cache -r requirements.txt
# Normal pre-build step to inject schema.json into the source directory
# so schema.json is hosted alongside the specification documents
pre_build:
- bst -v export --output src/schema.json
- tools/no-bad-schema-paths.sh src/schema.json # README.md might need fixing

mkdocs:
configuration: mkdocs.yml
fail_on_warning: true

python:
install:
- requirements: requirements.txt
Loading

0 comments on commit d60fe83

Please sign in to comment.