1414
1515
1616jobs :
17+ check_if_skip :
18+ runs-on : ubuntu-latest
19+ outputs :
20+ commit_message : ${{ steps.get_commit_message.outputs.commit_message }}
21+ steps :
22+ - name : Get repo
23+ uses : actions/checkout@v3
24+ with :
25+ ref : ${{ github.event.pull_request.head.sha }}
26+ - name : Print head git commit message
27+ id : get_commit_message
28+ run : |
29+ COMMIT_MSG=${{ github.event.head_commit.message }}
30+ if [[ -z $COMMIT_MSG ]]; then
31+ COMMIT_MSG=$(git show -s --format=%s)
32+ fi
33+ echo $COMMIT_MSG
34+ echo "::set-output name=commit_message::$COMMIT_MSG"
35+
1736 build :
18- if : " !contains(github.event.head_commit.message, '[skip ci]')"
37+ needs : check_if_skip
38+ if : " !contains(needs.check_if_skip.outputs.commit_message, '[skip ci]')"
1939 runs-on : ubuntu-latest
2040 strategy :
2141 matrix :
@@ -95,17 +115,90 @@ jobs:
95115 matrix :
96116 python-version : [3.7, 3.8, 3.9]
97117 install : [repo]
98- pip-flags : ['', '--pre']
99118 include :
100119 - python-version : 3.9
101120 install : sdist
102- pip-flags : ' '
103121 - python-version : 3.9
104122 install : wheel
105- pip-flags : ' '
106123 - python-version : 3.9
107124 install : editable
108- pip-flags : ' '
125+
126+ env :
127+ INSTALL_TYPE : ${{ matrix.install }}
128+
129+ steps :
130+ - uses : actions/checkout@v3
131+ with :
132+ fetch-depth : 0
133+ - name : Set up Python ${{ matrix.python-version }}
134+ uses : actions/setup-python@v3
135+ with :
136+ python-version : ${{ matrix.python-version }}
137+ - name : Load test data cache
138+ uses : actions/cache@v2
139+ id : stanford-crn
140+ with :
141+ path : ~/.cache/stanford-crn/
142+ key : data-v0-${{ github.ref_name }}-${{ github.sha }}
143+ - name : Load TemplateFlow cache
144+ uses : actions/cache@v2
145+ id : templateflow
146+ with :
147+ path : ~/.cache/templateflow
148+ key : templateflow-v0-${{ github.ref_name }}-${{ strategy.job-index }}-${{ github.sha }}
149+ restore-keys : |
150+ templateflow-v0-${{ github.ref_name }}-
151+ templateflow-v0-
152+ - name : Fetch packages
153+ uses : actions/download-artifact@v3
154+ with :
155+ name : dist
156+ path : dist/
157+ - name : Select archive
158+ run : |
159+ if [ "$INSTALL_TYPE" = "sdist" ]; then
160+ ARCHIVE=$( ls dist/*.tar.gz )
161+ elif [ "$INSTALL_TYPE" = "wheel" ]; then
162+ ARCHIVE=$( ls dist/*.whl )
163+ elif [ "$INSTALL_TYPE" = "repo" ]; then
164+ ARCHIVE="."
165+ elif [ "$INSTALL_TYPE" = "editable" ]; then
166+ ARCHIVE="-e ."
167+ fi
168+ echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
169+ - name : Install package
170+ run : python -m pip install $ARCHIVE
171+ - name : Check version
172+ run : |
173+ # Interpolate version
174+ if [[ "$GITHUB_REF" == refs/tags/* ]]; then
175+ TAG=${GITHUB_REF##*/}
176+ fi
177+ THISVERSION=$( python get_version.py )
178+ THISVERSION=${TAG:-$THISVERSION}
179+ INSTALLED_VERSION=$(python -c 'import niworkflows; print(niworkflows.__version__, end="")')
180+ echo "VERSION: \"${THISVERSION}\""
181+ echo "INSTALLED: \"${INSTALLED_VERSION}\""
182+ test "${INSTALLED_VERSION}" = "${THISVERSION}"
183+ - name : Install test dependencies
184+ run : python -m pip install "niworkflows[tests]"
185+ - name : Run tests
186+ uses : GabrielBB/xvfb-action@v1
187+ with :
188+ run : pytest -sv --no-xvfb --doctest-modules --cov niworkflows niworkflows
189+ - uses : codecov/codecov-action@v2
190+ name : Submit to CodeCov
191+
192+ test-pre :
193+ needs : [build, get_data, check_if_skip]
194+ if : ${{ !contains(needs.check_if_skip.outputs.commit_message, '[skip pre]') }}
195+ runs-on : ubuntu-latest
196+ strategy :
197+ matrix :
198+ python-version : [3.7, 3.8, 3.9]
199+ install : [repo]
200+ pip-flags : ['--pre']
201+ include :
109202 # VTK won't build official 3.10 wheels before 9.2.0
110203 # PyVista has posted dev versions, at least
111204 - python-version : ' 3.10'
@@ -117,6 +210,8 @@ jobs:
117210 PIP_FLAGS : ${{ matrix.pip-flags }}
118211
119212 steps :
213+ - name : Debug commit message
214+ run : echo "${{ needs.check_if_skip.outputs.commit_message }}"
120215 - uses : actions/checkout@v3
121216 with :
122217 fetch-depth : 0
@@ -180,7 +275,8 @@ jobs:
180275 name : Submit to CodeCov
181276
182277 flake8 :
183- if : " !contains(github.event.head_commit.message, '[skip ci]')"
278+ needs : check_if_skip
279+ if : " !contains(needs.check_if_skip.outputs.commit_message, '[skip ci]')"
184280 runs-on : ubuntu-latest
185281 steps :
186282 - uses : actions/checkout@v3
0 commit comments