|
| 1 | +# adapted from xarray's ci |
| 2 | +name: CI |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [ master ] |
| 7 | + pull_request: |
| 8 | + branches: [ master ] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +jobs: |
| 12 | + detect-skip-ci-trigger: |
| 13 | + name: "Detect CI Trigger: [skip-ci]" |
| 14 | + if: github.event_name == 'push' || github.event_name == 'pull_request' |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + triggered: ${{ steps.detect-trigger.outputs.trigger-found }} |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v2 |
| 20 | + with: |
| 21 | + fetch-depth: 2 |
| 22 | + - uses: keewis/ci-trigger@v1 |
| 23 | + id: detect-trigger |
| 24 | + with: |
| 25 | + keyword: "[skip-ci]" |
| 26 | + |
| 27 | + ci: |
| 28 | + name: py${{ matrix.python-version }} |
| 29 | + runs-on: ubuntu-latest |
| 30 | + needs: detect-skip-ci-trigger |
| 31 | + |
| 32 | + if: | |
| 33 | + always() |
| 34 | + && github.repository == 'xarray-contrib/pint-xarray' |
| 35 | + && ( |
| 36 | + github.event_name == 'workflow_dispatch' |
| 37 | + || needs.detect-skip-ci-trigger.outputs.triggered == 'false' |
| 38 | + ) |
| 39 | +
|
| 40 | + strategy: |
| 41 | + fail-fast: false |
| 42 | + matrix: |
| 43 | + python-version: [3.7, 3.8, 3.9] |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: cancel previous runs |
| 47 | + |
| 48 | + with: |
| 49 | + access_token: ${{ github.token }} |
| 50 | + |
| 51 | + - name: checkout the repository |
| 52 | + uses: actions/checkout@v2 |
| 53 | + with: |
| 54 | + # need to fetch all tags to get a correct version |
| 55 | + fetch-depth: 0 # fetch all branches and tags |
| 56 | + |
| 57 | + - name: cache pip |
| 58 | + uses: actions/cache@v2 |
| 59 | + with: |
| 60 | + path: ~/.cache/pip |
| 61 | + key: pip-py${{ matrix.python-version }} |
| 62 | + restore-keys: | |
| 63 | + pip- |
| 64 | +
|
| 65 | + - name: setup python |
| 66 | + uses: actions/setup-python@v2 |
| 67 | + with: |
| 68 | + python-version: ${{ matrix.python-version }} |
| 69 | + |
| 70 | + - name: upgrade pip |
| 71 | + run: python -m pip install --upgrade pip setuptools wheel |
| 72 | + |
| 73 | + - name: install dependencies |
| 74 | + run: | |
| 75 | + python -m pip install -r ci/requirements.txt |
| 76 | +
|
| 77 | + - name: install pint-xarray |
| 78 | + run: python -m pip install --no-deps . |
| 79 | + |
| 80 | + - name: show versions |
| 81 | + run: python -m pip list |
| 82 | + |
| 83 | + - name: import pint-xarray |
| 84 | + run: | |
| 85 | + python -c 'import pint_xarray' |
| 86 | +
|
| 87 | + - name: run tests |
| 88 | + if: success() |
| 89 | + id: status |
| 90 | + run: | |
| 91 | + python -m pytest --cov=pint_xarray --cov-report=xml |
| 92 | +
|
| 93 | + - name: Upload code coverage to Codecov |
| 94 | + uses: codecov/codecov-action@v1 |
| 95 | + with: |
| 96 | + file: ./coverage.xml |
| 97 | + flags: unittests |
| 98 | + env_vars: PYTHON_VERSION |
| 99 | + name: codecov-umbrella |
| 100 | + fail_ci_if_error: false |
0 commit comments