|
| 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 | +# For deployment, it will be necessary to create a PyPI API token and store it as a secret |
| 5 | +# https://docs.github.com/en/actions/reference/encrypted-secrets |
| 6 | + |
| 7 | +name: Python package |
| 8 | + |
| 9 | +# Set once |
| 10 | +env: |
| 11 | + SUBPACKAGE: dcm2niix |
| 12 | + |
| 13 | +on: |
| 14 | + push: |
| 15 | + branches: [ main ] |
| 16 | + tags: [ '*' ] |
| 17 | + pull_request: |
| 18 | + branches: [ main ] |
| 19 | + |
| 20 | +jobs: |
| 21 | + |
| 22 | + test: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + strategy: |
| 25 | + matrix: |
| 26 | + python-version: [3.11, 3.12, 3.13] |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v2 |
| 30 | + - name: Set up Python ${{ matrix.python-version }} |
| 31 | + uses: actions/setup-python@v2 |
| 32 | + with: |
| 33 | + python-version: ${{ matrix.python-version }} |
| 34 | + - name: Install build dependencies |
| 35 | + run: | |
| 36 | + python -m pip install --upgrade pip |
| 37 | + - name: Install task package |
| 38 | + run: | |
| 39 | + pip install ".[test]" |
| 40 | + python -c "import pydra.tasks.$SUBPACKAGE as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" |
| 41 | + python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" |
| 42 | + - name: Install development Pydra |
| 43 | + run: pip install --no-deps git+https://github.com/nipype/pydra.git@new-syntax |
| 44 | + - name: Test with pytest |
| 45 | + run: | |
| 46 | + pytest -sv --doctest-modules pydra/tasks/$SUBPACKAGE \ |
| 47 | + --cov pydra.tasks.$SUBPACKAGE --cov-report xml |
| 48 | + - uses: codecov/codecov-action@v1 |
| 49 | + if: ${{ always() }} |
| 50 | + |
| 51 | + |
| 52 | + deploy: |
| 53 | + needs: [test] |
| 54 | + runs-on: ubuntu-latest |
| 55 | + strategy: |
| 56 | + matrix: |
| 57 | + python-version: [3.9] |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v2 |
| 60 | + with: |
| 61 | + submodules: recursive |
| 62 | + fetch-depth: 0 |
| 63 | + - name: Set up Python ${{ matrix.python-version }} |
| 64 | + uses: actions/setup-python@v2 |
| 65 | + with: |
| 66 | + python-version: ${{ matrix.python-version }} |
| 67 | + - name: Install build tools |
| 68 | + run: python -m pip install --upgrade pip setuptools wheel twine |
| 69 | + - name: Build source and wheel distributions |
| 70 | + run: python setup.py sdist bdist_wheel |
| 71 | + - name: Check distributions |
| 72 | + run: twine check dist/* |
| 73 | + - uses: actions/upload-artifact@v2 |
| 74 | + with: |
| 75 | + name: distributions |
| 76 | + path: dist/ |
| 77 | + # Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets. |
| 78 | + # Secrets are not accessible in the if: condition [0], so set an output variable [1] |
| 79 | + # [0] https://github.community/t/16928 |
| 80 | + # [1] https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter |
| 81 | + - name: Check for PyPI token on tag |
| 82 | + id: deployable |
| 83 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 84 | + env: |
| 85 | + PYPI_API_TOKEN: "${{ secrets.PYPI_API_TOKEN }}" |
| 86 | + run: if [ -n "$PYPI_API_TOKEN" ]; then echo ::set-output name=DEPLOY::true; fi |
| 87 | + - name: Upload to PyPI |
| 88 | + if: steps.deployable.outputs.DEPLOY |
| 89 | + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 # v1.4.2 |
| 90 | + with: |
| 91 | + user: __token__ |
| 92 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments