Skip to content

Commit 10e0b53

Browse files
authored
Merge pull request #36 from nipype/fileformats-patch
Patch up fileformats description and CI/CD
2 parents e364a8f + c7bc621 commit 10e0b53

File tree

2 files changed

+140
-3
lines changed

2 files changed

+140
-3
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
release:
9+
types: [published]
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
jobs:
16+
test:
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest]
20+
python-version: ["3.8", "3.12"]
21+
fail-fast: false
22+
runs-on: ${{ matrix.os }}
23+
defaults:
24+
run:
25+
shell: bash -l {0}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v2
29+
- name: Unset header
30+
# checkout@v2 adds a header that makes branch protection report errors
31+
# because the Github action bot is not a collaborator on the repo
32+
run: git config --local --unset http.https://github.com/.extraheader
33+
- name: Fetch tags
34+
run: git fetch --prune --unshallow
35+
- name: Disable etelemetry
36+
run: echo "NO_ET=TRUE" >> $GITHUB_ENV
37+
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
38+
uses: actions/setup-python@v2
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
- name: Update build tools
42+
run: python3 -m pip install --upgrade pip
43+
- name: Install Package
44+
run: python3 -m pip install -e related-packages/fileformats[test] -e related-packages/fileformats-extras[test]
45+
- name: Pytest
46+
run: pytest -vvs --cov fileformats.medimage_CHANGEME --cov-config .coveragerc --cov-report xml .
47+
- name: Upload coverage to Codecov
48+
uses: codecov/codecov-action@v2
49+
with:
50+
fail_ci_if_error: true
51+
token: ${{ secrets.CODECOV_TOKEN }}
52+
53+
build:
54+
needs: [test]
55+
runs-on: ubuntu-latest
56+
strategy:
57+
matrix:
58+
pkg:
59+
- ["main", "related-packages/fileformats"]
60+
- ["extras", "related-packages/fileformats-extras"]
61+
steps:
62+
- uses: actions/checkout@v3
63+
with:
64+
submodules: recursive
65+
fetch-depth: 0
66+
- name: Unset header
67+
# checkout@v2 adds a header that makes branch protection report errors
68+
# because the Github action bot is not a collaborator on the repo
69+
run: git config --local --unset http.https://github.com/.extraheader
70+
- name: Set up Python
71+
uses: actions/setup-python@v4
72+
with:
73+
python-version: '3.12'
74+
- name: Install build tools
75+
run: python3 -m pip install build twine
76+
- name: Build source and wheel distributions
77+
run: python3 -m build ${{ matrix.pkg[1] }}
78+
- name: Check distributions
79+
run: twine check ${{ matrix.pkg[1] }}/dist/*
80+
- uses: actions/upload-artifact@v3
81+
with:
82+
name: built-${{ matrix.pkg[0] }}
83+
path: ${{ matrix.pkg[1] }}/dist
84+
85+
deploy:
86+
needs: [build]
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Download build
90+
uses: actions/download-artifact@v3
91+
with:
92+
name: built-main
93+
path: dist
94+
- name: Check for PyPI token on tag
95+
id: deployable
96+
if: github.event_name == 'release'
97+
env:
98+
PYPI_API_TOKEN: "${{ secrets.FILEFORMATS_PYPI_API_TOKEN }}"
99+
run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
100+
- name: Upload to PyPI
101+
if: steps.deployable.outputs.DEPLOY
102+
uses: pypa/gh-action-pypi-publish@release/v1
103+
with:
104+
user: __token__
105+
password: ${{ secrets.FILEFORMATS_PYPI_API_TOKEN }}
106+
107+
deploy-extras:
108+
needs: [build, deploy]
109+
runs-on: ubuntu-latest
110+
steps:
111+
- name: Download build
112+
uses: actions/download-artifact@v3
113+
with:
114+
name: built-extras
115+
path: dist
116+
- name: Check for PyPI token on tag
117+
id: deployable
118+
if: github.event_name == 'release'
119+
env:
120+
EXTRAS_PYPI_API_TOKEN: "${{ secrets.FILEFORMATS_EXTRAS_PYPI_API_TOKEN }}"
121+
run: if [ -n "$EXTRAS_PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
122+
- name: Upload to PyPI
123+
if: steps.deployable.outputs.DEPLOY
124+
uses: pypa/gh-action-pypi-publish@release/v1
125+
with:
126+
user: __token__
127+
password: ${{ secrets.FILEFORMATS_EXTRAS_PYPI_API_TOKEN }}
128+
129+
# Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets.
130+
# Secrets are not accessible in the if: condition [0], so set an output variable [1]
131+
# [0] https://github.community/t/16928
132+
# [1] https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ All tasks will be inserted into the `pydra.tasks.<yourtaskpackagename>` namespac
1010
1. Give your repo a name.
1111
1. Once the repo is created and cloned, search for CHANGEME (`grep -rn CHANGEME . `) and
1212
replace with appropriate name.
13-
1. Rename the following folders to replace `CHANGEME` with the name of the package:
13+
1. Rename the namespace package root directory to replace `CHANGEME` with the name of the package:
1414
* `src/pydra/tasks/CHANGEME`
15-
* `fileformats/fileformats/medimage_CHANGEME`
16-
* `fileformats/fileformats/extras/medimage_CHANGEME`
15+
1. If you are planning to define [fileformats](https://arcanaframework.github.io/fileformats/) classes specific
16+
to the tools defined in the task package, then rename the base and "extras" packages using a
17+
matching name to the package (if the tool is from in another field other than medical imaging,
18+
also replace the `medimage` part). If you don't need to define and tool-specific fileformats you can delete
19+
these packages and the .github/workflows/fileformats-ci-cd.yaml
20+
* `related-packages/fileformats/fileformats/medimage_CHANGEME`
21+
* `related-packages/fileformats-extras/fileformats/extras/medimage_CHANGEME`
1722
1. Under the newly renamed package (i.e. formerly CHANGEME) there is a directory named "v1",
1823
`src/pydra/tasks/<package-name>/v1`, change this to valid Python package name starting with
1924
'v' to indicate the version of the tool the Pydra interfaces will be designed for,

0 commit comments

Comments
 (0)