Skip to content

Commit

Permalink
Merge pull request #36 from nipype/fileformats-patch
Browse files Browse the repository at this point in the history
Patch up fileformats description and CI/CD
  • Loading branch information
tclose authored Mar 16, 2024
2 parents e364a8f + c7bc621 commit 10e0b53
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 3 deletions.
132 changes: 132 additions & 0 deletions .github/workflows/fileformats-ci-cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: CI/CD

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
release:
types: [published]

defaults:
run:
shell: bash

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.12"]
fail-fast: false
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unset header
# checkout@v2 adds a header that makes branch protection report errors
# because the Github action bot is not a collaborator on the repo
run: git config --local --unset http.https://github.com/.extraheader
- name: Fetch tags
run: git fetch --prune --unshallow
- name: Disable etelemetry
run: echo "NO_ET=TRUE" >> $GITHUB_ENV
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Update build tools
run: python3 -m pip install --upgrade pip
- name: Install Package
run: python3 -m pip install -e related-packages/fileformats[test] -e related-packages/fileformats-extras[test]
- name: Pytest
run: pytest -vvs --cov fileformats.medimage_CHANGEME --cov-config .coveragerc --cov-report xml .
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

build:
needs: [test]
runs-on: ubuntu-latest
strategy:
matrix:
pkg:
- ["main", "related-packages/fileformats"]
- ["extras", "related-packages/fileformats-extras"]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Unset header
# checkout@v2 adds a header that makes branch protection report errors
# because the Github action bot is not a collaborator on the repo
run: git config --local --unset http.https://github.com/.extraheader
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install build tools
run: python3 -m pip install build twine
- name: Build source and wheel distributions
run: python3 -m build ${{ matrix.pkg[1] }}
- name: Check distributions
run: twine check ${{ matrix.pkg[1] }}/dist/*
- uses: actions/upload-artifact@v3
with:
name: built-${{ matrix.pkg[0] }}
path: ${{ matrix.pkg[1] }}/dist

deploy:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download build
uses: actions/download-artifact@v3
with:
name: built-main
path: dist
- name: Check for PyPI token on tag
id: deployable
if: github.event_name == 'release'
env:
PYPI_API_TOKEN: "${{ secrets.FILEFORMATS_PYPI_API_TOKEN }}"
run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
- name: Upload to PyPI
if: steps.deployable.outputs.DEPLOY
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.FILEFORMATS_PYPI_API_TOKEN }}

deploy-extras:
needs: [build, deploy]
runs-on: ubuntu-latest
steps:
- name: Download build
uses: actions/download-artifact@v3
with:
name: built-extras
path: dist
- name: Check for PyPI token on tag
id: deployable
if: github.event_name == 'release'
env:
EXTRAS_PYPI_API_TOKEN: "${{ secrets.FILEFORMATS_EXTRAS_PYPI_API_TOKEN }}"
run: if [ -n "$EXTRAS_PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
- name: Upload to PyPI
if: steps.deployable.outputs.DEPLOY
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.FILEFORMATS_EXTRAS_PYPI_API_TOKEN }}

# Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets.
# Secrets are not accessible in the if: condition [0], so set an output variable [1]
# [0] https://git.luolix.topmunity/t/16928
# [1] https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ All tasks will be inserted into the `pydra.tasks.<yourtaskpackagename>` namespac
1. Give your repo a name.
1. Once the repo is created and cloned, search for CHANGEME (`grep -rn CHANGEME . `) and
replace with appropriate name.
1. Rename the following folders to replace `CHANGEME` with the name of the package:
1. Rename the namespace package root directory to replace `CHANGEME` with the name of the package:
* `src/pydra/tasks/CHANGEME`
* `fileformats/fileformats/medimage_CHANGEME`
* `fileformats/fileformats/extras/medimage_CHANGEME`
1. If you are planning to define [fileformats](https://arcanaframework.github.io/fileformats/) classes specific
to the tools defined in the task package, then rename the base and "extras" packages using a
matching name to the package (if the tool is from in another field other than medical imaging,
also replace the `medimage` part). If you don't need to define and tool-specific fileformats you can delete
these packages and the .github/workflows/fileformats-ci-cd.yaml
* `related-packages/fileformats/fileformats/medimage_CHANGEME`
* `related-packages/fileformats-extras/fileformats/extras/medimage_CHANGEME`
1. Under the newly renamed package (i.e. formerly CHANGEME) there is a directory named "v1",
`src/pydra/tasks/<package-name>/v1`, change this to valid Python package name starting with
'v' to indicate the version of the tool the Pydra interfaces will be designed for,
Expand Down

0 comments on commit 10e0b53

Please sign in to comment.