|
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 |
|
19 | | -jobs: |
20 | | - job_metadata: |
21 | | - if: github.repository == 'nipreps/niworkflows' |
22 | | - runs-on: ubuntu-latest |
23 | | - outputs: |
24 | | - commit_message: ${{ steps.get_commit_message.outputs.commit_message }} |
25 | | - version: ${{ steps.show_version.outputs.version }} |
26 | | - steps: |
27 | | - - name: Checkout |
28 | | - uses: actions/checkout@v4 |
29 | | - with: |
30 | | - fetch-depth: 0 |
31 | | - - name: Print head git commit message |
32 | | - id: get_commit_message |
33 | | - run: | |
34 | | - if [[ -z "$COMMIT_MSG" ]]; then |
35 | | - COMMIT_MSG=$(git show -s --format=%s $REF) |
36 | | - fi |
37 | | - echo commit_message=$COMMIT_MSG | tee -a $GITHUB_OUTPUT |
38 | | - env: |
39 | | - COMMIT_MSG: ${{ github.event.head_commit.message }} |
40 | | - REF: ${{ github.event.pull_request.head.sha }} |
41 | | - - name: Detect version |
42 | | - id: show_version |
43 | | - run: | |
44 | | - if [[ "$GITHUB_REF" == refs/tags/* ]]; then |
45 | | - VERSION=${GITHUB_REF##*/} |
46 | | - else |
47 | | - pipx run hatch version # Once to avoid output of initial setup |
48 | | - VERSION=$( pipx run hatch version ) |
49 | | - fi |
50 | | - echo version=$VERSION | tee -a $GITHUB_OUTPUT |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +env: |
| 20 | + # Force tox and pytest to use color |
| 21 | + FORCE_COLOR: true |
51 | 22 |
|
| 23 | +jobs: |
52 | 24 | build: |
53 | 25 | if: github.repository == 'nipreps/niworkflows' |
54 | 26 | runs-on: ubuntu-latest |
@@ -118,140 +90,73 @@ jobs: |
118 | 90 | datalad get -J 2 -r ds000003 ds000030/sub-10228/func |
119 | 91 |
|
120 | 92 | test: |
121 | | - needs: [build, get_data, job_metadata] |
| 93 | + needs: [get_data] |
122 | 94 | runs-on: ubuntu-latest |
123 | 95 | strategy: |
124 | 96 | matrix: |
125 | 97 | python-version: ["3.9", "3.10", "3.11", "3.12"] |
126 | | - install: [repo] |
| 98 | + dependencies: [latest, pre] |
127 | 99 | 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 |
134 | | - |
135 | | - env: |
136 | | - INSTALL_TYPE: ${{ matrix.install }} |
137 | | - |
138 | | - 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'] |
| 100 | + - python-version: "3.9" |
| 101 | + dependencies: min |
| 102 | + exclude: |
| 103 | + # Do not test pre-releases for versions out of SPEC0 |
| 104 | + - python-version: "3.9" |
| 105 | + dependencies: pre |
| 106 | + - python-version: "3.10" |
| 107 | + dependencies: pre |
208 | 108 |
|
209 | 109 | env: |
210 | | - INSTALL_TYPE: ${{ matrix.install }} |
211 | | - PIP_FLAGS: ${{ matrix.pip-flags }} |
| 110 | + DEPENDS: ${{ matrix.dependencies }} |
212 | 111 |
|
213 | 112 | 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 |
| 113 | + - uses: actions/checkout@v4 |
| 114 | + with: |
| 115 | + submodules: recursive |
| 116 | + fetch-depth: 0 |
| 117 | + - name: Install the latest version of uv |
| 118 | + uses: astral-sh/setup-uv@v3 |
| 119 | + - name: Load test data cache |
| 120 | + uses: actions/cache@v4 |
| 121 | + id: stanford-crn |
| 122 | + with: |
| 123 | + path: ~/.cache/stanford-crn/ |
| 124 | + key: data-v0-${{ github.ref_name }}-${{ github.sha }} |
| 125 | + - name: Load TemplateFlow cache |
| 126 | + uses: actions/cache@v4 |
| 127 | + id: templateflow |
| 128 | + with: |
| 129 | + path: ~/.cache/templateflow |
| 130 | + key: templateflow-v0-${{ github.ref_name }}-${{ strategy.job-index }}-${{ github.sha }} |
| 131 | + restore-keys: | |
| 132 | + templateflow-v0-${{ github.ref_name }}- |
| 133 | + templateflow-v0- |
| 134 | + - uses: actions/cache@v4 |
| 135 | + with: |
| 136 | + path: ~/.cache/templateflow |
| 137 | + key: templateflow-v1 |
| 138 | + - name: Install dependencies |
| 139 | + run: | |
| 140 | + sudo apt update |
| 141 | + sudo apt install -y --no-install-recommends graphviz |
| 142 | + - name: Set up Python ${{ matrix.python-version }} |
| 143 | + uses: actions/setup-python@v5 |
| 144 | + with: |
| 145 | + python-version: ${{ matrix.python-version }} |
| 146 | + - name: Display Python version |
| 147 | + run: python -c "import sys; print(sys.version)" |
| 148 | + - name: Install tox |
| 149 | + run: | |
| 150 | + uv tool install tox --with=tox-uv --with=tox-gh-actions |
| 151 | + - name: Show tox config |
| 152 | + run: tox c |
| 153 | + - name: Run tox |
| 154 | + run: tox -v --exit-and-dump-after 1200 |
| 155 | + - uses: codecov/codecov-action@v4 |
| 156 | + with: |
| 157 | + file: coverage.xml |
| 158 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 159 | + if: ${{ always() }} |
255 | 160 |
|
256 | 161 | flake8: |
257 | 162 | if: github.event_name != 'schedule' |
|
0 commit comments