|
| 1 | +name: Tox |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master, main, 'maint/*' ] |
| 6 | + tags: [ '*' ] |
| 7 | + pull_request: |
| 8 | + branches: [ master, main, 'maint/*' ] |
| 9 | + schedule: |
| 10 | + - cron: '0 0 * * *' |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +env: |
| 20 | + # Force tox and pytest to use color |
| 21 | + FORCE_COLOR: true |
| 22 | + TEST_DATA_HOME: /home/runner/testdata/nitransforms-tests |
| 23 | + |
| 24 | +jobs: |
| 25 | + cache-test-data: |
| 26 | + if: "!contains(github.event.head_commit.message, '[skip ci]')" |
| 27 | + runs-on: ubuntu-latest |
| 28 | + outputs: |
| 29 | + SHA: ${{ steps.test-head.outputs.SHA }} |
| 30 | + steps: |
| 31 | + - name: Install the latest version of uv |
| 32 | + uses: astral-sh/setup-uv@v3 |
| 33 | + - name: Git settings (pacify DataLad) |
| 34 | + run: | |
| 35 | + git config --global user.name 'NiPreps Bot' |
| 36 | + git config --global user.email '[email protected]' |
| 37 | + - name: Install DataLad |
| 38 | + run: | |
| 39 | + $CONDA/bin/conda install -c conda-forge git-annex |
| 40 | + uv tool install --with=datalad-next --with=datalad-osf datalad |
| 41 | + - name: Check remote HEAD |
| 42 | + id: test-head |
| 43 | + run: | |
| 44 | + git ls-remote https://gin.g-node.org/oesteban/nitransforms-tests \ |
| 45 | + | awk '/HEAD/{ print "SHA=" $1 }' >> $GITHUB_OUTPUT |
| 46 | +
|
| 47 | + - uses: actions/cache@v4 |
| 48 | + with: |
| 49 | + path: ${{ env.TEST_DATA_HOME }} |
| 50 | + key: data-cache-v2-${{ steps.test-head.outputs.SHA }} |
| 51 | + restore-keys: | |
| 52 | + data-cache-v2-${{ steps.test-head.outputs.SHA }} |
| 53 | + data-cache-v2 |
| 54 | +
|
| 55 | + - name: Install test data |
| 56 | + run: | |
| 57 | + export PATH=$CONDA/bin:$PATH |
| 58 | + mkdir -p /home/runner/testdata |
| 59 | +
|
| 60 | + datalad install -s https://gin.g-node.org/oesteban/nitransforms-tests $TEST_DATA_HOME |
| 61 | + datalad update --merge -d $TEST_DATA_HOME |
| 62 | + datalad get -J 2 -d $TEST_DATA_HOME |
| 63 | +
|
| 64 | + test: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + needs: [cache-test-data] |
| 67 | + strategy: |
| 68 | + matrix: |
| 69 | + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] |
| 70 | + dependencies: [latest, pre] |
| 71 | + include: |
| 72 | + - python-version: "3.9" |
| 73 | + dependencies: min |
| 74 | + exclude: |
| 75 | + # Do not test pre-releases for versions out of SPEC0 |
| 76 | + - python-version: "3.9" |
| 77 | + dependencies: pre |
| 78 | + - python-version: "3.10" |
| 79 | + dependencies: pre |
| 80 | + |
| 81 | + env: |
| 82 | + DEPENDS: ${{ matrix.dependencies }} |
| 83 | + |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v4 |
| 86 | + with: |
| 87 | + submodules: recursive |
| 88 | + fetch-depth: 0 |
| 89 | + - name: Install the latest version of uv |
| 90 | + uses: astral-sh/setup-uv@v3 |
| 91 | + - uses: actions/cache/restore@v4 |
| 92 | + with: |
| 93 | + path: ${{ env.TEST_DATA_HOME }} |
| 94 | + key: data-cache-v2-${{ needs.cache-test-data.outputs.SHA }} |
| 95 | + - name: Set up Python ${{ matrix.python-version }} |
| 96 | + uses: actions/setup-python@v5 |
| 97 | + with: |
| 98 | + python-version: ${{ matrix.python-version }} |
| 99 | + - name: Display Python version |
| 100 | + run: python -c "import sys; print(sys.version)" |
| 101 | + - name: Install tox |
| 102 | + run: | |
| 103 | + uv tool install tox --with=tox-uv --with=tox-gh-actions |
| 104 | + - name: Show tox config |
| 105 | + run: tox c |
| 106 | + - name: Run tox |
| 107 | + run: tox -v --exit-and-dump-after 1200 |
| 108 | + - uses: codecov/codecov-action@v4 |
| 109 | + with: |
| 110 | + file: coverage.xml |
| 111 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 112 | + if: ${{ always() }} |
| 113 | + |
| 114 | + checks: |
| 115 | + runs-on: 'ubuntu-latest' |
| 116 | + continue-on-error: true |
| 117 | + strategy: |
| 118 | + matrix: |
| 119 | + check: ['style'] |
| 120 | + |
| 121 | + steps: |
| 122 | + - uses: actions/checkout@v4 |
| 123 | + - name: Install the latest version of uv |
| 124 | + uses: astral-sh/setup-uv@v3 |
| 125 | + - name: Show tox config |
| 126 | + run: uvx tox c |
| 127 | + - name: Show tox config (this call) |
| 128 | + run: uvx tox c -e ${{ matrix.check }} |
| 129 | + - name: Run check |
| 130 | + run: uvx tox -e ${{ matrix.check }} |
0 commit comments