Add code and notebooks for OHBM2024 abstract. #102
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- main | |
- maint/* | |
tags: | |
- "*" | |
pull_request: | |
branches: | |
- main | |
- maint/* | |
workflow_dispatch: | |
inputs: | |
debug_enabled: | |
type: boolean | |
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' | |
required: false | |
default: false | |
defaults: | |
run: | |
shell: bash | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
get-dataset: | |
runs-on: ubuntu-latest | |
name: Datalad install and get | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Get Submodule Hash | |
id: get-smhash | |
run: | | |
echo "smhash=$(git submodule status contarg/test/data)" >> $GITHUB_OUTPUT | |
- name: Cache Dataset | |
id: restore-dataset | |
uses: actions/cache/restore@v3 | |
with: | |
path: | | |
./contarg/test/data | |
.git/modules/contarg/test/data | |
key: ${{ runner.os }}-${{steps.get-smhash.outputs.smhash}} | |
- name: Install datalad | |
if: steps.restore-dataset.outputs.cache-hit != 'true' | |
uses: datalad/datalad-action/install@main | |
- name: Download Dataset | |
if: steps.restore-dataset.outputs.cache-hit != 'true' | |
run: | | |
datalad get -r contarg/test/data/derivatives/contarg/seedmap/ \ | |
contarg/test/data/derivatives/contarg/hierarchical/testing2subs/sub-*/func/*mask.nii.gz \ | |
contarg/test/data/ds002330/*.json \ | |
contarg/test/data/ds002330/*.tsv \ | |
contarg/test/data/derivatives/fmriprep/*.json \ | |
contarg/test/data/derivatives/fmriprep/sub-*/anat/sub-*_from-MNI152NLin6Asym_to-T1w_mode-image_xfm.h5 \ | |
contarg/test/data/derivatives/fmriprep/sub-*/anat/*preproc_T1w.* \ | |
contarg/test/data/derivatives/fmriprep/sub-*/func/*preproc_bold.* \ | |
contarg/test/data/derivatives/fmriprep/sub-*/func/*brain_mask.* \ | |
contarg/test/data/derivatives/fmriprep/sub-*/func/*boldref.* \ | |
contarg/test/data/derivatives/fmriprep/sub-*/func/*confounds_timeseries.* \ | |
contarg/test/data/derivatives/contarg/hierarchical/testing*_ref/ \ | |
contarg/test/data/derivatives/contarg/hierarchical/testing1sub/sub-*/func/*mask.nii.gz \ | |
contarg/test/data/derivatives/contarg/cluster/ | |
- name: Cache Dataset | |
if: steps.restore-dataset.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v3 | |
with: | |
path: | | |
./contarg/test/data | |
.git/modules/contarg/test/data | |
key: ${{ runner.os }}-${{steps.get-smhash.outputs.smhash}} | |
- name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled && (success() || failure())}} | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3 | |
- run: pip install --upgrade build twine | |
- name: Build sdist and wheel | |
run: python -m build | |
- run: twine check dist/* | |
- name: Upload sdist and wheel artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: dist/ | |
- name: Build git archive | |
run: mkdir archive && git archive -v -o archive/archive.tgz HEAD | |
- name: Upload git archive artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: archive | |
path: archive/ | |
test-package: | |
runs-on: ubuntu-latest | |
needs: [get-dataset, build] | |
strategy: | |
matrix: | |
package: ['wheel', 'sdist', 'archive'] | |
steps: | |
- name: Download sdist and wheel artifacts | |
if: matrix.package != 'archive' | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
path: dist/ | |
- name: Download git archive artifact | |
if: matrix.package == 'archive' | |
uses: actions/download-artifact@v3 | |
with: | |
name: archive | |
path: archive/ | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3 | |
- name: Display Python version | |
run: python -c "import sys; print(sys.version)" | |
- name: Update pip | |
run: pip install --upgrade pip | |
- name: Install wheel | |
if: matrix.package == 'wheel' | |
run: pip install dist/*.whl | |
- name: Install sdist | |
if: matrix.package == 'sdist' | |
run: pip install dist/*.tar.gz | |
- name: Install archive | |
if: matrix.package == 'archive' | |
run: pip install archive/archive.tgz | |
- name: Install test extras | |
run: pip install contarg[test] | |
- name: Restore Dataset | |
id: restore-dataset | |
uses: actions/cache/restore@v3 | |
with: | |
path: | | |
./contarg/test/data | |
.git/modules/contarg/test/data | |
key: ${{ runner.os }}-${{steps.get-smhash.outputs.smhash}} | |
- name: Move data | |
run: | | |
contarg_path=$(which contarg) | |
contarg_test_path=${contarg_path:0:-12}/lib/python*/site-packages/contarg/test | |
mv contarg/test/data $contarg_test_path/ | |
rm -rf $contarg_test_path/data/.git | |
mv .git/modules/contarg/test/data .git/modules/contarg/test/.git | |
mv .git/modules/contarg/test/.git $contarg_test_path/data/ | |
- name: Run tests | |
run: pytest --doctest-modules -v --pyargs contarg | |
- name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled && (success() || failure())}} | |
publish: | |
runs-on: ubuntu-latest | |
needs: [test-package] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
path: dist/ | |
- uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |