Skip to content

Commit 2d82070

Browse files
authored
Merge pull request #112 from poldracklab/maint/travis-to-gha
MAINT: Move from TravisCI to GHA
2 parents 71ec933 + 97d3ad7 commit 2d82070

File tree

9 files changed

+187
-19
lines changed

9 files changed

+187
-19
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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: [ '*' ]
9+
tags: [ '*' ]
10+
pull_request:
11+
branches: [ master, 'maint/*' ]
12+
13+
jobs:
14+
build:
15+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: [3.7, 3.8, 3.9]
20+
21+
steps:
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- uses: actions/checkout@v2
27+
with:
28+
fetch-depth: 0
29+
- name: Build in confined, updated environment and interpolate version
30+
run: |
31+
python -m venv /tmp/buildenv
32+
source /tmp/buildenv/bin/activate
33+
python -m pip install -U setuptools pip wheel twine docutils
34+
python setup.py sdist bdist_wheel
35+
python -m twine check dist/nitransforms*
36+
37+
# Interpolate version
38+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
39+
TAG=${GITHUB_REF##*/}
40+
fi
41+
THISVERSION=$( python setup.py --version )
42+
THISVERSION=${TAG:-$THISVERSION}
43+
echo "Expected VERSION: \"${THISVERSION}\""
44+
echo "THISVERSION=${THISVERSION}" >> ${GITHUB_ENV}
45+
46+
- name: Install in confined environment [sdist]
47+
run: |
48+
python -m venv /tmp/install_sdist
49+
source /tmp/install_sdist/bin/activate
50+
python -m pip install --upgrade pip wheel
51+
python -m pip install dist/nitransforms*.tar.gz
52+
INSTALLED_VERSION=$(python -c 'import nitransforms; print(nitransforms.__version__, end="")')
53+
echo "VERSION: \"${THISVERSION}\""
54+
echo "INSTALLED: \"${INSTALLED_VERSION}\""
55+
test "${INSTALLED_VERSION}" = "${THISVERSION}"
56+
57+
- name: Install in confined environment [wheel]
58+
run: |
59+
python -m venv /tmp/install_wheel
60+
source /tmp/install_wheel/bin/activate
61+
python -m pip install --upgrade pip wheel
62+
python -m pip install dist/nitransforms*.whl
63+
INSTALLED_VERSION=$(python -c 'import nitransforms; print(nitransforms.__version__, end="")')
64+
echo "INSTALLED: \"${INSTALLED_VERSION}\""
65+
test "${INSTALLED_VERSION}" = "${THISVERSION}"
66+
67+
- name: Install in confined environment [pip install .]
68+
run: |
69+
python -m venv /tmp/setup_install
70+
source /tmp/setup_install/bin/activate
71+
python -m pip install --upgrade pip wheel
72+
python -m pip install .
73+
INSTALLED_VERSION=$(python -c 'import nitransforms; print(nitransforms.__version__, end="")')
74+
echo "INSTALLED: \"${INSTALLED_VERSION}\""
75+
test "${INSTALLED_VERSION}" = "${THISVERSION}"
76+
77+
- name: Install in confined environment [pip install -e .]
78+
run: |
79+
python -m venv /tmp/setup_develop
80+
source /tmp/setup_develop/bin/activate
81+
python -m pip install pip
82+
python -m pip install --upgrade pip wheel
83+
python -m pip install -e .
84+
INSTALLED_VERSION=$(python -c 'import nitransforms; print(nitransforms.__version__, end="")')
85+
echo "INSTALLED: \"${INSTALLED_VERSION}\""
86+
test "${INSTALLED_VERSION}" = "${THISVERSION}"
87+
88+
flake8:
89+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v2
93+
- name: Set up Python 3.7
94+
uses: actions/setup-python@v1
95+
with:
96+
python-version: 3.7
97+
- run: pip install flake8
98+
- run: flake8 nitransforms/

.github/workflows/travis.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Deps & CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build-linux:
7+
if: "!contains(github.event.head_commit.message, '[skip ci]' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'poldracklab/nitransforms'))"
8+
runs-on: ubuntu-latest
9+
env:
10+
TEST_DATA_HOME: /home/runner/testdata/nitransforms-tests
11+
strategy:
12+
max-parallel: 5
13+
matrix:
14+
python-version: [3.7, 3.8, 3.9]
15+
16+
steps:
17+
- name: Git settings (pacify DataLad)
18+
run: |
19+
git config --global user.name 'NiPreps Bot'
20+
git config --global user.email '[email protected]'
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- uses: actions/cache@v2
26+
id: conda
27+
with:
28+
path: |
29+
/usr/share/miniconda/pkgs
30+
/home/runner/.cache/pip
31+
key: python-${{ matrix.python-version }}-v1
32+
restore-keys: |
33+
python-${{ matrix.python-version }}-
34+
- name: Install DataLad
35+
run: |
36+
$CONDA/bin/conda install -c conda-forge git-annex datalad pip codecov pytest
37+
$CONDA/bin/python -m pip install datalad-osf
38+
# $CONDA/bin/pip install git+https://github.com/Lykos153/AnnexRemote.git
39+
40+
- uses: actions/cache@v2
41+
with:
42+
path: ${{ env.TEST_DATA_HOME }}
43+
key: data-cache-v1
44+
restore-keys: |
45+
data-cache-
46+
47+
- name: Install test data
48+
run: |
49+
export PATH=$CONDA/bin:$PATH
50+
mkdir -p /home/runner/testdata
51+
cd /home/runner/testdata
52+
53+
$CONDA/bin/datalad install https://github.com/nipreps-data/nitransforms-tests.git
54+
$CONDA/bin/datalad update --merge -d nitransforms-tests/
55+
$CONDA/bin/datalad get -d nitransforms-tests/
56+
57+
- uses: actions/checkout@v2
58+
- name: Install minimal dependencies
59+
run: |
60+
$CONDA/bin/pip install .[tests]
61+
- name: Run pytest
62+
run: |
63+
$CONDA/bin/pytest -v --cov nitransforms --cov-config .coveragerc --cov-report xml:cov.xml --doctest-modules nitransforms/
64+
65+
- name: Submit code coverage
66+
run: |
67+
$CONDA/bin/python -m codecov --flags travis --file cov.xml -e $GITHUB_RUN_NUMBER

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
recursive-exclude .circleci/ *
2+
recursive-exclude .github/ *
23
recursive-exclude docker/ *
34
recursive-exclude docs/ *
45
recursive-exclude joss/ *
6+
recursive-exclude nitransforms/tests *
57
exclude .codecov.yml .coveragerc .gitignore .pep8speaks.yml .travis.yml Dockerfile

nitransforms/io/afni.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ def from_string(cls, string):
6767
tf = cls()
6868
sa = tf.structarr
6969
lines = [
70-
l
71-
for l in string.splitlines()
72-
if l.strip() and not (l.startswith("#") or "3dvolreg matrices" in l)
70+
line
71+
for line in string.splitlines()
72+
if line.strip() and not (line.startswith("#") or "3dvolreg matrices" in line)
7373
]
7474

7575
if not lines:
@@ -101,9 +101,9 @@ def to_string(self):
101101
strings = []
102102
for i, xfm in enumerate(self.xforms):
103103
lines = [
104-
l.strip()
105-
for l in xfm.to_string(banner=(i == 0)).splitlines()
106-
if l.strip()
104+
line.strip()
105+
for line in xfm.to_string(banner=(i == 0)).splitlines()
106+
if line.strip()
107107
]
108108
strings += lines
109109
return "\n".join(strings)
@@ -124,14 +124,14 @@ def from_string(cls, string):
124124
_self = cls()
125125

126126
lines = [
127-
l.strip()
128-
for l in string.splitlines()
129-
if l.strip() and not l.startswith("#")
127+
line.strip()
128+
for line in string.splitlines()
129+
if line.strip() and not line.startswith("#")
130130
]
131131
if not lines:
132132
raise TransformFileError("Input string is empty.")
133133

134-
_self.xforms = [cls._inner_type.from_string(l) for l in lines]
134+
_self.xforms = [cls._inner_type.from_string(line) for line in lines]
135135
return _self
136136

137137

nitransforms/io/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class LinearParameters(StringBasedStruct):
4545
4646
"""
4747

48-
template_dtype = np.dtype([("parameters", "f8", (4, 4)),])
48+
template_dtype = np.dtype([("parameters", "f8", (4, 4))])
4949
dtype = template_dtype
5050

5151
def __init__(self, parameters=None):

nitransforms/io/fsl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def from_string(cls, string):
4545
"""Read the struct from string."""
4646
tf = cls()
4747
sa = tf.structarr
48-
lines = [l.strip() for l in string.splitlines() if l.strip()]
48+
lines = [line.strip() for line in string.splitlines() if line.strip()]
4949
if not lines or len(lines) < 4:
5050
raise TransformFileError
5151

nitransforms/io/itk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def from_matlab_dict(cls, mdict, index=0):
133133
"AffineTransform_double_3_3",
134134
mdict.get("AffineTransform_float_3_3")
135135
)
136-
136+
137137
if affine is None:
138138
raise NotImplementedError("Unsupported transform type")
139139

@@ -159,15 +159,15 @@ def from_string(cls, string):
159159
"""Read the struct from string."""
160160
tf = cls()
161161
sa = tf.structarr
162-
lines = [l.strip() for l in string.splitlines() if l.strip()]
162+
lines = [line.strip() for line in string.splitlines() if line.strip()]
163163
if not lines or not lines[0].startswith("#"):
164164
raise TransformFileError
165165

166166
if lines[1][0] == "#":
167167
lines = lines[1:] # Drop banner with version
168168

169169
parameters = np.eye(4, dtype="f4")
170-
sa["index"] = int(lines[0][lines[0].index("T") :].split()[1])
170+
sa["index"] = int(lines[0][lines[0].index("T"):].split()[1])
171171
sa["offset"] = np.genfromtxt(
172172
[lines[3].split(":")[-1].encode()], dtype=cls.dtype["offset"]
173173
)
@@ -258,7 +258,7 @@ def from_ras(cls, ras, moving=None, reference=None):
258258
def from_string(cls, string):
259259
"""Read the struct from string."""
260260
_self = cls()
261-
lines = [l.strip() for l in string.splitlines() if l.strip()]
261+
lines = [line.strip() for line in string.splitlines() if line.strip()]
262262

263263
if (
264264
not lines

nitransforms/io/lta.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ def from_string(klass, string):
294294
lta = klass()
295295
sa = lta.structarr
296296
lines = [
297-
l.strip()
298-
for l in string.splitlines()
299-
if l.strip() and not l.strip().startswith("#")
297+
line.strip()
298+
for line in string.splitlines()
299+
if line.strip() and not line.strip().startswith("#")
300300
]
301301
if not lines or not lines[0].startswith("type"):
302302
raise TransformFileError("Invalid LTA format")

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ max-line-length = 99
5656
doctests = False
5757
ignore =
5858
E266
59+
E231
5960
W503
6061

6162
[tool:pytest]

0 commit comments

Comments
 (0)