Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into plus-sign-labels
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Jan 14, 2025
2 parents a096cba + c16ab8d commit 45643a5
Show file tree
Hide file tree
Showing 95 changed files with 1,061 additions and 931 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
25 changes: 17 additions & 8 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 All @@ -56,7 +61,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- os: macos-latest
python-version: 3
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
21 changes: 14 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +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: v4.6.0
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.2
rev: 0.31.0
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand All @@ -25,7 +27,7 @@ repos:
- id: check-readthedocs
files: readthedocs.yml
- repo: https://github.com/psf/black
rev: 24.8.0
rev: 24.10.0
hooks:
- id: black
files: ^tools/(?!schemacode)
Expand All @@ -48,7 +50,7 @@ repos:
rev: 7.1.1
hooks:
- id: flake8
args: [--config=tools/schemacode/setup.cfg]
args: [--config=tools/schemacode/.flake8]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
Expand All @@ -61,13 +63,18 @@ repos:
- id: yamllint
args: [-f=standard, -c=.yamllint.yml]
files: src/schema/.*/.*\.yaml
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.14.0
hooks:
- id: pretty-format-toml
args: [--autofix, --indent, '4', --no-sort]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: ["--config=.codespellrc", "--dictionary=-", "--dictionary=.codespell_dict"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
rev: v1.14.1
hooks:
- id: mypy
# Sync with project.optional-dependencies.typing
Expand All @@ -83,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.

Loading

0 comments on commit 45643a5

Please sign in to comment.