Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[flake8]
max-line-length = 88
max-complexity = 10
exclude =
.git,
__pycache__,
.tox,
.eggs,
*.egg,
build,
dist
27 changes: 27 additions & 0 deletions .github/workflows/codeformat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Code Format

on:
push:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read

jobs:
pre-commit:
name: Pre-commit checks
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install and run pre-commit hooks
uses: pre-commit/action@v3.0.1
48 changes: 48 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Coverage

on:
push:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read

jobs:
coverage:
name: Code Coverage
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[test]

- name: Run tests with coverage
run: |
pytest trx/tests --cov=trx --cov-report=xml --cov-report=term-missing

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
flags: unittests
name: codecov-trx
fail_ci_if_error: false
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
87 changes: 81 additions & 6 deletions .github/workflows/docbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]
python-version: ["3.13"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history and tags for setuptools_scm
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install
Expand All @@ -35,13 +37,86 @@ jobs:
cd docs
make html
- name: Upload docs
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: docs
path: docs/_build/html

deploy-dev:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'tee-ar-ex/trx-python'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: docs
path: docs/_build/html
- name: Publish dev docs to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs/_build/html
target-folder: dev

deploy-release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'tee-ar-ex/trx-python'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: docs
path: docs/_build/html
- name: Publish docs to Github Pages
if: startsWith(github.event.ref, 'refs/tags')
- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Fetch existing switcher.json from gh-pages
run: |
curl -sSL https://tee-ar-ex.github.io/trx-python/switcher.json -o switcher.json || echo '[]' > switcher.json
- name: Update switcher.json with new version
run: python tools/update_switcher.py switcher.json --version ${{ steps.get_version.outputs.VERSION }}
- name: Create root files (redirect + switcher.json)
run: |
mkdir -p root_files
cp switcher.json root_files/
cat > root_files/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>trx-python - TRX File Format for Tractography</title>
<meta name="description" content="trx-python is a Python implementation of the TRX file format for tractography data, designed for efficient handling of brain fiber tract streamlines.">
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://tee-ar-ex.github.io/trx-python/stable/">
<meta http-equiv="refresh" content="0; URL=https://tee-ar-ex.github.io/trx-python/stable/">
<script>window.location.replace("https://tee-ar-ex.github.io/trx-python/stable/");</script>
</head>
<body>
<h1>trx-python Documentation</h1>
<p>Python implementation of the TRX file format for tractography data.</p>
<p>If you are not redirected automatically, visit the <a href="https://tee-ar-ex.github.io/trx-python/stable/">stable documentation</a>.</p>
</body>
</html>
EOF
- name: Publish root files (redirect + switcher.json)
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: root_files
target-folder: .
clean: false
- name: Publish release docs to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs/_build/html
target-folder: ${{ steps.get_version.outputs.VERSION }}
- name: Publish stable docs to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs/_build/html
target-folder: stable
106 changes: 81 additions & 25 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,95 @@
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI

on: push
on:
push:
branches:
- master
tags:
- '*'

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
build:
name: Build distribution 📦
runs-on: ubuntu-latest
if: github.repository == 'tee-ar-ex/trx-python'
steps:
- uses: actions/checkout@master
- name: Set up Python 3.9
uses: actions/setup-python@v1
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history and tags for setuptools_scm
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.11"
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
run: python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
run: python -m build --sdist --wheel --outdir dist/ .
- name: Upload distribution artifacts
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-testpypi:
name: Publish to TestPyPI
needs: build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/trx-python
permissions:
id-token: write
steps:
- name: Download distribution artifacts
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/

publish-to-pypi:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
environment:
name: pypi
url: https://pypi.org/p/trx-python
permissions:
id-token: write
steps:
- name: Download distribution artifacts
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: Create GitHub Release
needs: publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download distribution artifacts
uses: actions/download-artifact@v4
with:
user: __token__
password: ${{ secrets.pypi_password }}
name: python-package-distributions
path: dist/
- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ steps.get_version.outputs.VERSION }}" \
--title "Release ${{ steps.get_version.outputs.VERSION }}" \
--generate-notes \
dist/*
39 changes: 0 additions & 39 deletions .github/workflows/python-package.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Tests

on:
push:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read

jobs:
test:
name: Python ${{ matrix.python-version }} • ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for setuptools_scm version detection

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev,test]

- name: Test
run: spin test
Loading