|
| 1 | +name: CI/CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, develop ] |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + |
| 11 | +defaults: |
| 12 | + run: |
| 13 | + shell: bash |
| 14 | + |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + os: [macos-latest, ubuntu-latest] |
| 20 | + python-version: ["3.8", "3.11"] |
| 21 | + fail-fast: false |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + defaults: |
| 24 | + run: |
| 25 | + shell: bash -l {0} |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v2 |
| 30 | + |
| 31 | + - name: Unset header |
| 32 | + # checkout@v2 adds a header that makes branch protection report errors |
| 33 | + # because the Github action bot is not a collaborator on the repo |
| 34 | + run: git config --local --unset http.https://github.com/.extraheader |
| 35 | + |
| 36 | + - name: Fetch tags |
| 37 | + run: git fetch --prune --unshallow |
| 38 | + |
| 39 | + - name: Disable etelemetry |
| 40 | + run: echo "NO_ET=TRUE" >> $GITHUB_ENV |
| 41 | + |
| 42 | + - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} |
| 43 | + uses: actions/setup-python@v2 |
| 44 | + with: |
| 45 | + python-version: ${{ matrix.python-version }} |
| 46 | + |
| 47 | + - name: Update build tools |
| 48 | + run: python3 -m pip install --upgrade pip setuptools wheel |
| 49 | + |
| 50 | + - name: Install required file-formats packages |
| 51 | + run: | |
| 52 | + pushd required-fileformats |
| 53 | + python3 -m pip install -r requirements.txt |
| 54 | + popd |
| 55 | +
|
| 56 | + - name: Install Package |
| 57 | + run: python3 -m pip install -e .[test] |
| 58 | + |
| 59 | + - name: Pytest |
| 60 | + run: pytest -vvs --cov nipype2pydra --cov-config .coveragerc --cov-report xml |
| 61 | + |
| 62 | + - name: Upload coverage to Codecov |
| 63 | + uses: codecov/codecov-action@v2 |
| 64 | + with: |
| 65 | + fail_ci_if_error: true |
| 66 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 67 | + |
| 68 | + deploy: |
| 69 | + needs: [test] |
| 70 | + runs-on: ubuntu-latest |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v3 |
| 73 | + with: |
| 74 | + submodules: recursive |
| 75 | + fetch-depth: 0 |
| 76 | + |
| 77 | + - name: Unset header |
| 78 | + # checkout@v2 adds a header that makes branch protection report errors |
| 79 | + # because the Github action bot is not a collaborator on the repo |
| 80 | + run: git config --local --unset http.https://github.com/.extraheader |
| 81 | + |
| 82 | + - name: Set up Python |
| 83 | + uses: actions/setup-python@v4 |
| 84 | + with: |
| 85 | + python-version: '3.11' |
| 86 | + |
| 87 | + - name: Install build tools |
| 88 | + run: python3 -m pip install build twine |
| 89 | + |
| 90 | + - name: Build source and wheel distributions |
| 91 | + run: python3 -m build . |
| 92 | + |
| 93 | + - name: Check distributions |
| 94 | + run: twine check dist/* |
| 95 | + |
| 96 | + - name: Check for PyPI token on tag |
| 97 | + id: deployable |
| 98 | + if: github.event_name == 'release' |
| 99 | + env: |
| 100 | + PYPI_API_TOKEN: "${{ secrets.PYPI_API_TOKEN }}" |
| 101 | + run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi |
| 102 | + |
| 103 | + - name: Upload to PyPI |
| 104 | + if: steps.deployable.outputs.DEPLOY |
| 105 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 106 | + with: |
| 107 | + user: __token__ |
| 108 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments