@@ -10,193 +10,123 @@ on:
1010 pull_request :
1111 branches : [ master ]
1212
13+ concurrency :
14+ group : ${{ github.workflow }}-${{ github.ref }}
15+ cancel-in-progress : true
16+
17+ permissions :
18+ contents : read
19+
1320jobs :
1421 build :
15- if : " !startsWith(github.ref, 'refs/tags/') && !contains(github.event.head_commit.message, '[skip ci]')"
1622 runs-on : ubuntu-latest
23+ outputs :
24+ version : ${{ steps.get_version.outputs.version }}
25+ steps :
26+ - uses : actions/checkout@v3
27+ with :
28+ fetch-depth : 0
29+ - uses : actions/setup-python@v4
30+ with :
31+ python-version : 3
32+ - uses : actions/cache@v3
33+ with :
34+ path : ~/.cache/pip
35+ key : pip-cache-v1
36+ restore-keys : |
37+ pip-cache-
38+ - run : pip install --upgrade build twine
39+ - name : Build sdist and wheel
40+ run : python -m build
41+ - run : twine check dist/*
42+ - uses : actions/upload-artifact@v3
43+ with :
44+ name : dist
45+ path : dist/
46+ - name : Interpolate version in confined environment
47+ id : get_version
48+ run : |
49+ python -m venv /tmp/buildenv
50+ source /tmp/buildenv/bin/activate
51+ python -m pip install --upgrade setuptools setuptools_scm nipreps-versions
52+ if [[ "$GITHUB_REF" == refs/tags/* ]]; then
53+ TAG=${GITHUB_REF##*/}
54+ fi
55+ THISVERSION=$( python -m setuptools_scm )
56+ THISVERSION=${TAG:-$THISVERSION}
57+ echo "Expected VERSION: \"${THISVERSION}\""
58+ echo "version=${THISVERSION}" >> $GITHUB_OUTPUT
59+
60+ test-install :
61+ runs-on : ubuntu-latest
62+ needs : build
1763 strategy :
1864 matrix :
19- python-version : [3.7, 3.8, 3.9]
20- pip : ["pip==21.2", "pip~=22.0"]
21-
65+ python-version : ['3.7', '3.8', '3.9', '3.10', '3.11']
66+ mode : ['wheel']
67+ include :
68+ - {python-version: '3.9', mode: 'repo'}
69+ - {python-version: '3.9', mode: 'sdist'}
70+ - {python-version: '3.9', mode: 'editable'}
71+
72+ env :
73+ TEMPLATEFLOW_HOME : /tmp/home
74+ THISVERSION : ${{ needs.build.outputs.version }}
2275 steps :
23- - uses : actions/checkout@v2
24- - name : Fetch all tags (for setuptools_scm to work)
25- run : |
26- /usr/bin/git -c protocol.version=2 fetch --tags --prune --unshallow origin
76+ - uses : actions/checkout@v3
77+ if : matrix.mode == 'repo' || matrix.mode == 'editable'
78+ with :
79+ fetch-depth : 0
80+ - uses : actions/download-artifact@v3
81+ if : matrix.mode == 'sdist' || matrix.mode == 'wheel'
82+ with :
83+ name : dist
84+ path : /tmp/package/
2785 - name : Set up Python ${{ matrix.python-version }}
28- uses : actions/setup-python@v1
86+ uses : actions/setup-python@v4
2987 with :
3088 python-version : ${{ matrix.python-version }}
31- - uses : actions/cache@v1
89+ - uses : actions/cache@v3
3290 with :
33- path : $HOME /.cache/pip
91+ path : ~ /.cache/pip
3492 key : pip-cache-v1
3593 restore-keys : |
3694 pip-cache-
37-
38- - name : Build in confined environment and interpolate version
39- run : |
40- python -m venv /tmp/buildenv
41- source /tmp/buildenv/bin/activate
42- python -m pip install -U "setuptools >= 45" wheel "setuptools_scm >= 6.2" \
43- setuptools_scm_git_archive pip twine docutils
44- python setup.py sdist bdist_wheel
45- python -m twine check dist/templateflow*
46-
47- mv dist /tmp/package
48- rm -rf templateflow.egg-info/
49-
50- # Interpolate version
51- if [[ "$GITHUB_REF" == refs/tags/* ]]; then
52- TAG=${GITHUB_REF##*/}
53- fi
54- THISVERSION=$( python setup.py --version )
55- THISVERSION=${TAG:-$THISVERSION}
56- echo "Expected VERSION: \"${THISVERSION}\""
57- echo "THISVERSION=${THISVERSION}" >> $GITHUB_ENV
58-
59- - name : Install in confined environment [pip]
60- env :
61- TEMPLATEFLOW_HOME : /tmp/home/pip
95+ - name : Upgrade pip
96+ run : pip install --upgrade pip wheel
97+ - name : Set install command
6298 run : |
63- python -m venv /tmp/pip
64- source /tmp/pip/bin/activate
65- python -m pip install -U "setuptools >= 45" "setuptools_scm >= 6.2" "${{ matrix.pip }}"
66- python -m pip install .
67- INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")')
68- echo "VERSION: \"${THISVERSION}\""
69- echo "INSTALLED: \"${INSTALLED_VERSION}\""
70- test "${INSTALLED_VERSION}" = "${THISVERSION}"
71-
72- - name : Install in confined environment [sdist]
73- env :
74- TEMPLATEFLOW_HOME : /tmp/home/sdist
99+ case ${{ matrix.mode }} in
100+ repo)
101+ echo "TARGET=." >> $GITHUB_ENV
102+ ;;
103+ editable)
104+ echo "TARGET=-e ." >> $GITHUB_ENV
105+ ;;
106+ sdist)
107+ echo "TARGET=$( ls /tmp/package/templateflow*.tar.gz )" >> $GITHUB_ENV
108+ ;;
109+ wheel)
110+ echo "TARGET=$( ls /tmp/package/templateflow*.whl )" >> $GITHUB_ENV
111+ ;;
112+ esac
113+ - name : Install and check version
75114 run : |
76- python -m venv /tmp/install_sdist
77- source /tmp/install_sdist/bin/activate
78- python -m pip install -U "setuptools >= 45" "${{ matrix.pip }}"
79- python -m pip install /tmp/package/templateflow*.tar.gz
115+ pip install $TARGET
80116 INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")')
81117 echo "VERSION: \"${THISVERSION}\""
82118 echo "INSTALLED: \"${INSTALLED_VERSION}\""
83119 test "${INSTALLED_VERSION}" = "${THISVERSION}"
84120
85- - name : Re-install in confined environment [sdist]
86- env :
87- TEMPLATEFLOW_HOME : /tmp/home/sdist
88- run : |
89- source /tmp/install_sdist/bin/activate
90- python -m pip install /tmp/package/templateflow*.tar.gz --force-reinstall
91- find ${TEMPLATEFLOW_HOME} >> /tmp/.sdist-install.txt
92- - name : Re-install in confined environment [sdist - missing template]
93- env :
94- TEMPLATEFLOW_HOME : /tmp/home/sdist
95- run : |
96- rm -rf ${TEMPLATEFLOW_HOME}/tpl-MNI152NLin2009cAsym
97- source /tmp/install_sdist/bin/activate
98- python -m pip install /tmp/package/templateflow*.tar.gz --force-reinstall
99- python -c "import templateflow; templateflow.update(overwrite=False)"
100- find ${TEMPLATEFLOW_HOME} >> /tmp/.sdist-install-2.txt
101- diff /tmp/.sdist-install.txt /tmp/.sdist-install-2.txt
102- exit $?
103-
104- - name : Install in confined environment [wheel]
105- env :
106- TEMPLATEFLOW_HOME : /tmp/home/wheel
107- run : |
108- python -m venv /tmp/install_wheel
109- source /tmp/install_wheel/bin/activate
110- python -m pip install -U "setuptools >= 45" "${{ matrix.pip }}"
111- python -m pip install /tmp/package/templateflow*.whl
112- INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")')
113- echo "INSTALLED: \"${INSTALLED_VERSION}\""
114- test "${INSTALLED_VERSION}" = "${THISVERSION}"
115-
116- - name : Re-install in confined environment [wheel]
117- env :
118- TEMPLATEFLOW_HOME : /tmp/home/wheel
119- run : |
120- source /tmp/install_wheel/bin/activate
121- python -m pip install /tmp/package/templateflow*.whl --force-reinstall
122- find ${TEMPLATEFLOW_HOME} >> /tmp/.wheel-install.txt
123- - name : Re-install in confined environment [wheel - missing template]
124- env :
125- TEMPLATEFLOW_HOME : /tmp/home/wheel
126- run : |
127- rm -rf ${TEMPLATEFLOW_HOME}/tpl-MNI152NLin2009cAsym
128- source /tmp/install_wheel/bin/activate
129- python -m pip install /tmp/package/templateflow*.whl --force-reinstall
130- # Wheels do not run post-install hooks:
131- test ! -d ${TEMPLATEFLOW_HOME}/tpl-MNI152NLin2009cAsym
132- python -c "import templateflow; templateflow.update(overwrite=False)"
133- find ${TEMPLATEFLOW_HOME} >> /tmp/.wheel-install-2.txt
134- diff /tmp/.wheel-install.txt /tmp/.wheel-install-2.txt
135- exit $?
136-
137- - name : Install in confined environment [setup.py - install]
138- env :
139- TEMPLATEFLOW_HOME : /tmp/home/setup_install
140- run : |
141- python -m venv /tmp/setup_install
142- source /tmp/setup_install/bin/activate
143- python -m pip install -U "setuptools >= 45" wheel "setuptools_scm >= 6.2" \
144- setuptools_scm_git_archive "${{ matrix.pip }}"
145- python -m pip install "numpy==1.20" Cython "pandas==1.3" "scipy==1.7"
146- python setup.py install
147- INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")')
148- echo "INSTALLED: \"${INSTALLED_VERSION}\""
149- test "${INSTALLED_VERSION}" = "${THISVERSION}"
150-
151- - name : Re-install in confined environment [setup.py - install]
152- env :
153- TEMPLATEFLOW_HOME : /tmp/home/setup_install
154- run : |
155- source /tmp/setup_install/bin/activate
156- python setup.py install
157- find ${TEMPLATEFLOW_HOME} >> /tmp/.setup-install.txt
158- - name : Re-install in confined environment [setup.py - install - missing template]
159- env :
160- TEMPLATEFLOW_HOME : /tmp/home/setup_install
161- run : |
162- rm -rf ${TEMPLATEFLOW_HOME}/tpl-MNI152NLin2009cAsym
163- source /tmp/setup_install/bin/activate
164- python setup.py install
165- python -c "import templateflow; templateflow.update(overwrite=False)"
166- find ${TEMPLATEFLOW_HOME} >> /tmp/.setup-install-2.txt
167- diff /tmp/.setup-install.txt /tmp/.setup-install-2.txt
168- exit $?
169-
170- - name : Install in confined environment [setup.py - develop]
171- env :
172- TEMPLATEFLOW_HOME : /tmp/home/setup_develop
121+ - name : Re-install
173122 run : |
174- python -m venv /tmp/setup_develop
175- source /tmp/setup_develop/bin/activate
176- python -m pip install -U "setuptools >= 45" wheel "setuptools_scm >= 6.2" \
177- setuptools_scm_git_archive "${{ matrix.pip }}"
178- python -m pip install "numpy==1.20" Cython "pandas==1.3" "scipy==1.7"
179- python setup.py develop
180- INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")')
181- echo "INSTALLED: \"${INSTALLED_VERSION}\""
182- test "${INSTALLED_VERSION}" = "${THISVERSION}"
183-
184- - name : Re-install in confined environment [setup.py - develop]
185- env :
186- TEMPLATEFLOW_HOME : /tmp/home/setup_develop
187- run : |
188- source /tmp/setup_develop/bin/activate
189- python setup.py develop
190- find ${TEMPLATEFLOW_HOME} >> /tmp/.setup-develop.txt
191-
192- - name : Re-install in confined environment [setup.py - develop - missing template]
193- env :
194- TEMPLATEFLOW_HOME : /tmp/home/setup_develop
123+ pip install $TARGET --force-reinstall
124+ find ${TEMPLATEFLOW_HOME} >> /tmp/.install.txt
125+ - name : Re-install [missing template]
195126 run : |
196127 rm -rf ${TEMPLATEFLOW_HOME}/tpl-MNI152NLin2009cAsym
197- source /tmp/setup_develop/bin/activate
198- python setup.py develop
128+ pip install $TARGET --force-reinstall
199129 python -c "import templateflow; templateflow.update(overwrite=False)"
200- find ${TEMPLATEFLOW_HOME} >> /tmp/.setup-develop -2.txt
201- diff /tmp/.setup-develop .txt /tmp/.setup-develop -2.txt
130+ find ${TEMPLATEFLOW_HOME} >> /tmp/.install -2.txt
131+ diff /tmp/.install .txt /tmp/.install -2.txt
202132 exit $?
0 commit comments