Skip to content

Commit 96ba258

Browse files
nipreps-botoesteban
authored andcommitted
maint: first codebase add
0 parents  commit 96ba258

File tree

102 files changed

+12557
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+12557
-0
lines changed

.dockerignore

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# python cache
2+
__pycache__/**/*
3+
__pycache__
4+
*.pyc
5+
6+
# python distribution
7+
build/**/*
8+
build
9+
dist/**/*
10+
dist
11+
src/eddymotion.egg-info/**/*
12+
src/eddymotion.egg-info
13+
.eggs/**/*
14+
.eggs
15+
16+
# housekeeping tools
17+
.maint/**/*
18+
.maint
19+
20+
# pip installs
21+
src/**/*
22+
src/
23+
24+
# git
25+
.git_archival.txt
26+
.gitattributes
27+
.gitignore
28+
.git/**/*
29+
.git
30+
.mailmap
31+
32+
# other
33+
work/**/*
34+
work
35+
out/**/*
36+
out/
37+
.idea/**/*
38+
.idea
39+
40+
# CI, etc.
41+
tox.ini
42+
.circleci
43+
.circleci/**/*
44+
.github
45+
.github/**/*
46+
.pytest_cache
47+
.pytest_cache/**/*
48+
.codecov.yml
49+
.coveragerc
50+
.pep8speaks.yml
51+
.pre-commit-config.yaml
52+
.readthedocs.yml
53+
.travis.yml
54+
.zenodo.json
55+
56+
.afq

.git_archival.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref-names: $Format:%D$

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git_archival.txt export-subst

.github/workflows/contrib.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Contribution checks
2+
on: [push, pull_request]
3+
4+
defaults:
5+
run:
6+
shell: bash
7+
8+
jobs:
9+
stable:
10+
name: Run ruff
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
submodules: recursive
17+
fetch-depth: 0
18+
- name: Set up Python 3
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: 3
22+
- name: Lint EddyMotion
23+
run: pipx run ruff check --diff
24+
- name: Format EddyMotion
25+
run: pipx run ruff format --diff

.github/workflows/docs-build-pr.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
name: Build docs
3+
4+
on:
5+
pull_request:
6+
branches: [ main, 'maint/*' ]
7+
8+
jobs:
9+
build:
10+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Determine current branch/tag name
19+
run: |
20+
if [[ "$GITHUB_REF" == refs/pull/* ]]; then
21+
CURBRANCH=${GITHUB_REF%/*}
22+
CURBRANCH=${CURBRANCH##*/}
23+
elif [[ "$GITHUB_REF" == refs/heads/* ]]; then
24+
CURBRANCH=${GITHUB_REF##*/}
25+
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
26+
echo "This build should not be picking up a tag, cancelling."
27+
exit 1
28+
fi
29+
30+
# Remove forward slashes
31+
CURBRANCH=$( echo $CURBRANCH | sed 's+/+_+g' )
32+
echo "Building branch/tag ${CURBRANCH:-<unkwown>}, from git ref <$GITHUB_REF>"
33+
echo "CURBRANCH=${CURBRANCH}" >> ${GITHUB_ENV}
34+
35+
- name: Install GraphViz
36+
run: |
37+
sudo apt-get update -y
38+
sudo apt-get install -y --no-install-recommends graphviz
39+
40+
- name: Install dependencies
41+
run: |
42+
pip install -U build hatch pip
43+
pip install .[doc]
44+
python -m hatch version | tail -n1
45+
46+
- name: Build docs
47+
run: |
48+
python -m hatch build --hooks-only
49+
make -C docs/ SPHINXOPTS="-W -v" BUILDDIR="$HOME/docs" OUTDIR="${CURBRANCH:-html}" html
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
2+
name: Build & update docs
3+
4+
on:
5+
push:
6+
branches: [ 'doc/*', 'docs/*', main, "maint/*" ]
7+
tags: [ '*' ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
ssh-key: "${{ secrets.NIPREPS_DEPLOY }}"
17+
fetch-depth: 0
18+
19+
- name: Determine current branch/tag name & set-up git author
20+
run: |
21+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
22+
CURBRANCH=${GITHUB_REF##*/}
23+
elif [[ "$GITHUB_REF" == refs/pull/* ]]; then
24+
CURBRANCH=${GITHUB_REF%/*}
25+
CURBRANCH=${CURBRANCH##*/}
26+
elif [[ "$GITHUB_REF" == refs/heads/* ]]; then
27+
CURBRANCH=${GITHUB_REF##*/}
28+
fi
29+
30+
# Remove forward slashes
31+
CURBRANCH=$( echo $CURBRANCH | sed 's+/+_+g' )
32+
echo "Building branch/tag ${CURBRANCH:-<unkwown>}, from git ref <$GITHUB_REF>"
33+
echo "CURBRANCH=${CURBRANCH}" >> ${GITHUB_ENV}
34+
35+
# Pacify git if we were to commit something
36+
git config user.email "[email protected]"
37+
git config user.name "NiPreps Bot"
38+
- name: Install GraphViz
39+
run: |
40+
sudo apt-get update -y
41+
sudo apt-get install -y --no-install-recommends graphviz
42+
43+
- name: Install dependencies
44+
run: |
45+
pip install -U build hatch pip
46+
pip install .[doc]
47+
python -m hatch version | tail -n1
48+
49+
- name: Build docs
50+
run: |
51+
python -m hatch build --hooks-only
52+
make -C docs/ SPHINXOPTS="-W -v" BUILDDIR="$HOME/docs" OUTDIR="${CURBRANCH:-html}" html
53+
54+
- name: Push created tag to gh-pages
55+
if: startsWith(github.ref, 'refs/tags/')
56+
run: |
57+
MAJOR_MINOR=${CURBRANCH%.*}
58+
if [[ "${MAJOR_MINOR}" == "" ]]; then
59+
echo "Could not identify release series"
60+
exit 1
61+
fi
62+
git checkout -b gh-pages origin/gh-pages
63+
git rm -r ${MAJOR_MINOR}/ || true
64+
# It is fundamental that the directory does not exist at all.
65+
rm -rf ${MAJOR_MINOR}
66+
cp -r $HOME/docs/$CURBRANCH $PWD/${MAJOR_MINOR}
67+
git add ${MAJOR_MINOR}
68+
python -c "from pathlib import Path; import json; f=Path('versions.json'); d=json.loads(f.read_text()); d['tags'].append(\"${MAJOR_MINOR}\"); d['tags'] = list(sorted(set(d['tags']))); f.write_text(json.dumps(d, indent=4)); print('Updated versions.json')"
69+
git add versions.json
70+
git commit -m "rel(${CURBRANCH}): Update docs of ${MAJOR_MINOR} series" || true
71+
git push
72+
73+
- name: Push "main" docs to gh-pages after a push to main (typically, a PR merge).
74+
if: github.ref == 'refs/heads/main'
75+
run: |
76+
if [[ "${CURBRANCH}" != "main" ]]; then
77+
echo "$CURBRANCH is not the default development branch"
78+
exit 1
79+
fi
80+
git checkout -b gh-pages origin/gh-pages
81+
git rm -r main/ || true
82+
# It is fundamental that the directory does not exist at all.
83+
rm -rf main
84+
cp -r $HOME/docs/$CURBRANCH $PWD/main
85+
git add main
86+
git commit -am "docs(main): Update docs of development line" || true
87+
git push

.github/workflows/pypi-package.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
name: Build and upload package
3+
4+
on:
5+
push:
6+
branches: [main]
7+
tags: ["*"]
8+
release:
9+
types:
10+
- published
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
build-package:
18+
name: Build & verify package
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- uses: hynek/build-and-inspect-python-package@v2
25+
26+
auto-release-test-pypi:
27+
runs-on: ubuntu-latest
28+
needs: [build-package]
29+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
30+
permissions:
31+
id-token: write
32+
steps:
33+
- name: Download packages built by build-and-inspect-python-package
34+
uses: actions/download-artifact@v4
35+
with:
36+
name: Packages
37+
path: dist
38+
- uses: pypa/gh-action-pypi-publish@release/v1
39+
with:
40+
repository-url: https://test.pypi.org/legacy/
41+
skip-existing: true
42+
43+
auto-release-pypi:
44+
runs-on: ubuntu-latest
45+
environment: "Release"
46+
needs: [build-package]
47+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
48+
permissions:
49+
id-token: write
50+
steps:
51+
- name: Download packages built by build-and-inspect-python-package
52+
uses: actions/download-artifact@v4
53+
with:
54+
name: Packages
55+
path: dist
56+
- uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/pythonpackage.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python package
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
tags: [ '*' ]
10+
pull_request:
11+
branches: [ main ]
12+
13+
jobs:
14+
build:
15+
if: "!startsWith(github.ref, 'refs/tags/') && !contains(github.event.head_commit.message, '[skip ci]')"
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: ["3.10", "3.11", "3.12"]
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
submodules: recursive
25+
fetch-depth: 0
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
- uses: actions/cache@v4
31+
with:
32+
path: $HOME/.cache/pip
33+
key: pip-cache-v1
34+
restore-keys: |
35+
pip-cache-
36+
37+
- name: Build in confined environment and interpolate version
38+
run: |
39+
python -m venv /tmp/buildenv
40+
source /tmp/buildenv/bin/activate
41+
pip install -U build hatch pip twine
42+
43+
python -m build -s -w
44+
python -m twine check dist/eddymotion-*
45+
46+
mv dist /tmp/package
47+
48+
# Interpolate version
49+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
50+
TAG=${GITHUB_REF##*/}
51+
fi
52+
THISVERSION=$( python -m hatch version | tail -n1 | xargs )
53+
THISVERSION=${TAG:-$THISVERSION}
54+
echo "Expected VERSION: \"${THISVERSION}\""
55+
echo "THISVERSION=${THISVERSION}" >> $GITHUB_ENV
56+
57+
- name: Install in confined environment [pip]
58+
run: |
59+
python -m venv /tmp/pip
60+
source /tmp/pip/bin/activate
61+
pip install -U pip
62+
python -m pip install .
63+
INSTALLED_VERSION=$(python -c 'import eddymotion as em; print(em.__version__, end="")')
64+
echo "VERSION: \"${THISVERSION}\""
65+
echo "INSTALLED: \"${INSTALLED_VERSION}\""
66+
test "${INSTALLED_VERSION}" = "${THISVERSION}"
67+
68+
- name: Install in confined environment [sdist]
69+
run: |
70+
python -m venv /tmp/install_sdist
71+
source /tmp/install_sdist/bin/activate
72+
pip install -U pip
73+
python -m pip install /tmp/package/eddymotion*.tar.gz
74+
INSTALLED_VERSION=$(python -c 'import eddymotion as em; print(em.__version__, end="")')
75+
echo "VERSION: \"${THISVERSION}\""
76+
echo "INSTALLED: \"${INSTALLED_VERSION}\""
77+
test "${INSTALLED_VERSION}" = "${THISVERSION}"
78+
79+
- name: Install in confined environment [wheel]
80+
run: |
81+
python -m venv /tmp/install_wheel
82+
source /tmp/install_wheel/bin/activate
83+
pip install -U pip
84+
python -m pip install /tmp/package/eddymotion*.whl
85+
INSTALLED_VERSION=$(python -c 'import eddymotion as em; print(em.__version__, end="")')
86+
echo "INSTALLED: \"${INSTALLED_VERSION}\""
87+
test "${INSTALLED_VERSION}" = "${THISVERSION}"

0 commit comments

Comments
 (0)