|
| 1 | +name: Python package |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ '*' ] |
| 6 | + tags: [ '*' ] |
| 7 | + pull_request: |
| 8 | + branches: [ master, 'maint/*' ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + if: "!contains(github.event.head_commit.message, '[skip ci]')" |
| 13 | + runs-on: ubuntu-latest |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + python-version: [3.7, 3.8] |
| 17 | + pip: ["pip~=18.1", "pip>=20.3"] |
| 18 | + setuptools: ["setuptools==40.8.0", "setuptools"] |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Set up Python ${{ matrix.python-version }} |
| 22 | + uses: actions/setup-python@v1 |
| 23 | + with: |
| 24 | + python-version: ${{ matrix.python-version }} |
| 25 | + - uses: actions/checkout@v2 |
| 26 | + with: |
| 27 | + ssh-key: "${{ secrets.NIPREPS_DEPLOY }}" |
| 28 | + - name: Fetch all tags (for versioneer to work) |
| 29 | + if: "!startsWith(github.ref, 'refs/tags/')" |
| 30 | + run: | |
| 31 | + /usr/bin/git -c protocol.version=2 fetch --tags --prune --unshallow origin |
| 32 | + - name: Build in confined, updated environment and interpolate version |
| 33 | + run: | |
| 34 | + python -m venv /tmp/buildenv |
| 35 | + source /tmp/buildenv/bin/activate |
| 36 | + python -m pip install -U setuptools pip wheel twine docutils |
| 37 | + python setup.py sdist bdist_wheel |
| 38 | + python -m twine check dist/dmriprep* |
| 39 | + # Interpolate version |
| 40 | + if [[ "$GITHUB_REF" == refs/tags/* ]]; then |
| 41 | + TAG=${GITHUB_REF##*/} |
| 42 | + fi |
| 43 | + THISVERSION=$( python get_version.py ) |
| 44 | + THISVERSION=${TAG:-$THISVERSION} |
| 45 | + echo "Expected VERSION: \"${THISVERSION}\"" |
| 46 | + echo "THISVERSION=${THISVERSION}" >> ${GITHUB_ENV} |
| 47 | + - name: Install in confined environment [sdist] |
| 48 | + run: | |
| 49 | + python -m venv /tmp/install_sdist |
| 50 | + source /tmp/install_sdist/bin/activate |
| 51 | + python -m pip install "${{ matrix.pip }}" "${{ matrix.setuptools }}" |
| 52 | + python -m pip install dist/dmriprep*.tar.gz |
| 53 | + INSTALLED_VERSION=$(python -c 'import dmriprep; print(dmriprep.__version__, end="")') |
| 54 | + echo "VERSION: \"${THISVERSION}\"" |
| 55 | + echo "INSTALLED: \"${INSTALLED_VERSION}\"" |
| 56 | + test "${INSTALLED_VERSION}" = "${THISVERSION}" |
| 57 | + - name: Install in confined environment [wheel] |
| 58 | + run: | |
| 59 | + python -m venv /tmp/install_wheel |
| 60 | + source /tmp/install_wheel/bin/activate |
| 61 | + python -m pip install "${{ matrix.pip }}" "${{ matrix.setuptools }}" |
| 62 | + python -m pip install dist/dmriprep*.whl |
| 63 | + INSTALLED_VERSION=$(python -c 'import dmriprep; print(dmriprep.__version__, end="")') |
| 64 | + echo "INSTALLED: \"${INSTALLED_VERSION}\"" |
| 65 | + test "${INSTALLED_VERSION}" = "${THISVERSION}" |
| 66 | + - name: Install in confined environment [setup.py - install] |
| 67 | + run: | |
| 68 | + python -m venv /tmp/setup_install |
| 69 | + source /tmp/setup_install/bin/activate |
| 70 | + python -m pip install "${{ matrix.pip }}" "${{ matrix.setuptools }}" |
| 71 | + python -m pip install numpy scipy "Cython >= 0.28.5" # sklearn needs this |
| 72 | + python -m pip install scikit-learn # otherwise it attempts to build it |
| 73 | + python setup.py install |
| 74 | + INSTALLED_VERSION=$(python -c 'import dmriprep; print(dmriprep.__version__, end="")') |
| 75 | + echo "INSTALLED: \"${INSTALLED_VERSION}\"" |
| 76 | + test "${INSTALLED_VERSION}" = "${THISVERSION}" |
| 77 | + - name: Install in confined environment [setup.py - develop] |
| 78 | + run: | |
| 79 | + python -m venv /tmp/setup_develop |
| 80 | + source /tmp/setup_develop/bin/activate |
| 81 | + python -m pip install "${{ matrix.pip }}" "${{ matrix.setuptools }}" |
| 82 | + # sklearn needs these dependencies |
| 83 | + if [ "${{ matrix.python-version }}" == "3.6" ]; then |
| 84 | + python -m pip install "numpy < 1.20" scipy "Cython >= 0.28.5" # numpy 1.20 drops Py3.6 |
| 85 | + else |
| 86 | + python -m pip install numpy scipy "Cython >= 0.28.5" |
| 87 | + fi |
| 88 | + python -m pip install scikit-learn # otherwise it attempts to build it |
| 89 | + python setup.py develop |
| 90 | + INSTALLED_VERSION=$(python -c 'import dmriprep; print(dmriprep.__version__, end="")') |
| 91 | + echo "INSTALLED: \"${INSTALLED_VERSION}\"" |
| 92 | + test "${INSTALLED_VERSION}" = "${THISVERSION}" |
| 93 | + flake8: |
| 94 | + if: "!contains(github.event.head_commit.message, '[skip ci]')" |
| 95 | + runs-on: ubuntu-latest |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v2 |
| 98 | + - name: Set up Python 3.7 |
| 99 | + uses: actions/setup-python@v1 |
| 100 | + with: |
| 101 | + python-version: 3.7 |
| 102 | + - run: pip install flake8 |
| 103 | + - run: flake8 dmriprep |
0 commit comments