|
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 |
| 1 | +name: Tox |
5 | 2 |
|
6 | 3 | on: |
7 | 4 | push: |
|
13 | 10 | - cron: '0 0 * * *' |
14 | 11 |
|
15 | 12 | concurrency: |
16 | | - group: python-${{ github.ref }} |
| 13 | + group: ${{ github.workflow }}-${{ github.ref }} |
17 | 14 | cancel-in-progress: true |
18 | 15 |
|
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
19 | 19 | jobs: |
20 | 20 | job_metadata: |
21 | 21 | if: github.repository == 'nipreps/niworkflows' |
@@ -123,135 +123,62 @@ jobs: |
123 | 123 | strategy: |
124 | 124 | matrix: |
125 | 125 | python-version: ["3.9", "3.10", "3.11", "3.12"] |
126 | | - install: [repo] |
| 126 | + dependencies: [latest, pre] |
127 | 127 | include: |
128 | | - - python-version: "3.12" |
129 | | - install: sdist |
130 | | - - python-version: "3.12" |
131 | | - install: wheel |
132 | | - - python-version: "3.12" |
133 | | - install: editable |
| 128 | + - python-version: "3.9" |
| 129 | + dependencies: min |
134 | 130 |
|
135 | 131 | env: |
136 | | - INSTALL_TYPE: ${{ matrix.install }} |
| 132 | + DEPENDS: ${{ matrix.dependencies }} |
137 | 133 |
|
138 | 134 | steps: |
139 | | - - uses: actions/checkout@v4 |
140 | | - if: matrix.install == 'repo' || matrix.install == 'editable' |
141 | | - with: |
142 | | - fetch-depth: 0 |
143 | | - - name: Set up Python ${{ matrix.python-version }} |
144 | | - uses: actions/setup-python@v5 |
145 | | - with: |
146 | | - python-version: ${{ matrix.python-version }} |
147 | | - - name: Load test data cache |
148 | | - uses: actions/cache@v4 |
149 | | - id: stanford-crn |
150 | | - with: |
151 | | - path: ~/.cache/stanford-crn/ |
152 | | - key: data-v0-${{ github.ref_name }}-${{ github.sha }} |
153 | | - - name: Load TemplateFlow cache |
154 | | - uses: actions/cache@v4 |
155 | | - id: templateflow |
156 | | - with: |
157 | | - path: ~/.cache/templateflow |
158 | | - key: templateflow-v0-${{ github.ref_name }}-${{ strategy.job-index }}-${{ github.sha }} |
159 | | - restore-keys: | |
160 | | - templateflow-v0-${{ github.ref_name }}- |
161 | | - templateflow-v0- |
162 | | - - name: Fetch packages |
163 | | - if: matrix.install == 'sdist' || matrix.install == 'wheel' |
164 | | - uses: actions/download-artifact@v3 |
165 | | - with: |
166 | | - name: dist |
167 | | - path: dist/ |
168 | | - - name: Select archive |
169 | | - run: | |
170 | | - if [ "$INSTALL_TYPE" = "sdist" ]; then |
171 | | - ARCHIVE=$( ls dist/*.tar.gz ) |
172 | | - elif [ "$INSTALL_TYPE" = "wheel" ]; then |
173 | | - ARCHIVE=$( ls dist/*.whl ) |
174 | | - elif [ "$INSTALL_TYPE" = "repo" ]; then |
175 | | - ARCHIVE="." |
176 | | - elif [ "$INSTALL_TYPE" = "editable" ]; then |
177 | | - ARCHIVE="-e ." |
178 | | - fi |
179 | | - echo "ARCHIVE=$ARCHIVE" | tee -a $GITHUB_ENV |
180 | | - - name: Install package |
181 | | - run: python -m pip install $ARCHIVE |
182 | | - - name: Check version |
183 | | - run: | |
184 | | - INSTALLED_VERSION=$(python -c 'import niworkflows; print(niworkflows.__version__, end="")') |
185 | | - echo "INSTALLED: \"${INSTALLED_VERSION}\"" |
186 | | - test "${INSTALLED_VERSION}" = "${VERSION}" |
187 | | - env: |
188 | | - VERSION: ${{ needs.job_metadata.outputs.version }} |
189 | | - - name: Install test dependencies |
190 | | - run: python -m pip install "niworkflows[tests]" |
191 | | - - name: Run tests |
192 | | - run: pytest -sv --doctest-modules --cov niworkflows --pyargs niworkflows |
193 | | - - uses: codecov/codecov-action@v4 |
194 | | - name: Submit to CodeCov |
195 | | - with: |
196 | | - token: ${{ secrets.CODECOV_TOKEN }} |
197 | | - |
198 | | - test-pre: |
199 | | - needs: [get_data, job_metadata] |
200 | | - if: ${{ !contains(needs.job_metadata.outputs.commit_message, '[skip pre]') }} |
201 | | - runs-on: ubuntu-latest |
202 | | - strategy: |
203 | | - matrix: |
204 | | - # Only run --pre tests on Python versions within SPEC0 support |
205 | | - python-version: ["3.11", "3.12"] |
206 | | - install: [repo] |
207 | | - pip-flags: ['--pre'] |
208 | | - |
209 | | - env: |
210 | | - INSTALL_TYPE: ${{ matrix.install }} |
211 | | - PIP_FLAGS: ${{ matrix.pip-flags }} |
212 | | - |
213 | | - steps: |
214 | | - - name: Debug commit message |
215 | | - run: echo "${{ needs.job_metadata.outputs.commit_message }}" |
216 | | - - uses: actions/checkout@v4 |
217 | | - with: |
218 | | - fetch-depth: 0 |
219 | | - - name: Set up Python ${{ matrix.python-version }} |
220 | | - uses: actions/setup-python@v5 |
221 | | - with: |
222 | | - python-version: ${{ matrix.python-version }} |
223 | | - - name: Load test data cache |
224 | | - uses: actions/cache@v4 |
225 | | - id: stanford-crn |
226 | | - with: |
227 | | - path: ~/.cache/stanford-crn/ |
228 | | - key: data-v0-${{ github.ref_name }}-${{ github.sha }} |
229 | | - - name: Load TemplateFlow cache |
230 | | - uses: actions/cache@v4 |
231 | | - id: templateflow |
232 | | - with: |
233 | | - path: ~/.cache/templateflow |
234 | | - key: templateflow-v0-${{ github.ref_name }}-${{ strategy.job-index }}-${{ github.sha }} |
235 | | - restore-keys: | |
236 | | - templateflow-v0-${{ github.ref_name }}- |
237 | | - templateflow-v0- |
238 | | - - name: Install package |
239 | | - run: python -m pip install $PIP_FLAGS . |
240 | | - - name: Check version |
241 | | - run: | |
242 | | - INSTALLED_VERSION=$(python -c 'import niworkflows; print(niworkflows.__version__, end="")') |
243 | | - echo "INSTALLED: \"${INSTALLED_VERSION}\"" |
244 | | - test "${INSTALLED_VERSION}" = "${VERSION}" |
245 | | - env: |
246 | | - VERSION: ${{ needs.job_metadata.outputs.version }} |
247 | | - - name: Install test dependencies |
248 | | - run: python -m pip install $PIP_FLAGS "niworkflows[tests]" |
249 | | - - name: Run tests |
250 | | - run: pytest -sv --doctest-modules --cov niworkflows --pyargs niworkflows |
251 | | - - uses: codecov/codecov-action@v4 |
252 | | - with: |
253 | | - token: ${{ secrets.CODECOV_TOKEN }} |
254 | | - name: Submit to CodeCov |
| 135 | + - uses: actions/checkout@v4 |
| 136 | + with: |
| 137 | + submodules: recursive |
| 138 | + fetch-depth: 0 |
| 139 | + - name: Install the latest version of uv |
| 140 | + uses: astral-sh/setup-uv@v3 |
| 141 | + - name: Load test data cache |
| 142 | + uses: actions/cache@v4 |
| 143 | + id: stanford-crn |
| 144 | + with: |
| 145 | + path: ~/.cache/stanford-crn/ |
| 146 | + key: data-v0-${{ github.ref_name }}-${{ github.sha }} |
| 147 | + - name: Load TemplateFlow cache |
| 148 | + uses: actions/cache@v4 |
| 149 | + id: templateflow |
| 150 | + with: |
| 151 | + path: ~/.cache/templateflow |
| 152 | + key: templateflow-v0-${{ github.ref_name }}-${{ strategy.job-index }}-${{ github.sha }} |
| 153 | + restore-keys: | |
| 154 | + templateflow-v0-${{ github.ref_name }}- |
| 155 | + templateflow-v0- |
| 156 | + - uses: actions/cache@v4 |
| 157 | + with: |
| 158 | + path: ~/.cache/templateflow |
| 159 | + key: templateflow-v1 |
| 160 | + - name: Install dependencies |
| 161 | + run: | |
| 162 | + sudo apt update |
| 163 | + sudo apt install -y --no-install-recommends graphviz |
| 164 | + - name: Set up Python ${{ matrix.python-version }} |
| 165 | + uses: actions/setup-python@v5 |
| 166 | + with: |
| 167 | + python-version: ${{ matrix.python-version }} |
| 168 | + - name: Display Python version |
| 169 | + run: python -c "import sys; print(sys.version)" |
| 170 | + - name: Install tox |
| 171 | + run: | |
| 172 | + uv tool install tox --with=tox-uv --with=tox-gh-actions |
| 173 | + - name: Show tox config |
| 174 | + run: tox c |
| 175 | + - name: Run tox |
| 176 | + run: tox -v --exit-and-dump-after 1200 |
| 177 | + - uses: codecov/codecov-action@v4 |
| 178 | + with: |
| 179 | + file: coverage.xml |
| 180 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 181 | + if: ${{ always() }} |
255 | 182 |
|
256 | 183 | flake8: |
257 | 184 | if: github.event_name != 'schedule' |
|
0 commit comments