|
| 1 | +# This workflows will upload a Python Package using Twine when a release is created |
| 2 | +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries |
| 3 | + |
| 4 | +name: Upload Python Package |
| 5 | + |
| 6 | +on: |
| 7 | + release: |
| 8 | + types: [created] |
| 9 | + |
| 10 | +jobs: |
| 11 | + pytest: |
| 12 | + |
| 13 | + runs-on: ubuntu-latest |
| 14 | + if: always() |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + python-version: [3.6, 3.7, 3.8] |
| 18 | + pip-packages: |
| 19 | + - "setuptools pip pytest pytest-cov coverage codecov boutdata xarray!=0.14.0 numpy>=1.16.0" |
| 20 | + - "setuptools pip pytest pytest-cov coverage codecov boutdata xarray==0.16.0 dask==2.10.0 numpy==1.16.0 natsort==5.5.0 matplotlib==3.1.1 animatplot==0.4.1 netcdf4==1.4.2 Pillow==6.1.0 fsspec" # test with oldest supported version of packages. Note, using numpy==1.16.0 as a workaround for some weird fails on Travis, in principle we should work with numpy>=1.13.3. We should not need to install fsspec explicitly, but at the moment are getting import errors in the tests due to fsspec not being present - should remove in future, probably when dask version is increased. |
| 21 | + fail-fast: true |
| 22 | + |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v2 |
| 25 | + - name: Set up Python ${{ matrix.python-version }} |
| 26 | + uses: actions/setup-python@v1 |
| 27 | + with: |
| 28 | + python-version: ${{ matrix.python-version }} |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + sudo apt-get install libhdf5-dev libnetcdf-dev |
| 32 | + python -m pip install --upgrade pip |
| 33 | + pip install --upgrade ${{ matrix.pip-packages }} |
| 34 | + pip install -e . |
| 35 | + - name: Test with pytest |
| 36 | + run: | |
| 37 | + pip install pytest |
| 38 | + pytest -v --long --cov |
| 39 | + - name: Upload coverage to Codecov |
| 40 | + uses: codecov/codecov-action@v1 |
| 41 | + with: |
| 42 | + fail_ci_if_error: true |
| 43 | + |
| 44 | + |
| 45 | + # Need to tidy up the things that flake8 finds before we activate this |
| 46 | + #flake8: |
| 47 | + |
| 48 | + # runs-on: ubuntu-latest |
| 49 | + # if: always() |
| 50 | + |
| 51 | + # steps: |
| 52 | + # - uses: actions/checkout@v2 |
| 53 | + # - name: Set up Python |
| 54 | + # uses: actions/setup-python@v1 |
| 55 | + # - name: Install dependencies |
| 56 | + # run: | |
| 57 | + # python -m pip install --upgrade pip |
| 58 | + # - name: Lint with flake8 |
| 59 | + # run: | |
| 60 | + # pip install flake8 |
| 61 | + # flake8 |
| 62 | + |
| 63 | + |
| 64 | + black: |
| 65 | + |
| 66 | + runs-on: ubuntu-latest |
| 67 | + if: always() |
| 68 | + |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v2 |
| 71 | + - name: Set up Python |
| 72 | + uses: actions/setup-python@v1 |
| 73 | + - name: Install dependencies |
| 74 | + run: | |
| 75 | + python -m pip install --upgrade pip |
| 76 | + - name: Check formatting with black |
| 77 | + run: | |
| 78 | + pip install black |
| 79 | + black --check . |
| 80 | +
|
| 81 | + deploy: |
| 82 | + |
| 83 | + runs-on: ubuntu-latest |
| 84 | + needs: [pytest, black] |
| 85 | + |
| 86 | + steps: |
| 87 | + - uses: actions/checkout@v2 |
| 88 | + - name: Set up Python |
| 89 | + uses: actions/setup-python@v1 |
| 90 | + with: |
| 91 | + python-version: '3.x' |
| 92 | + - name: Install dependencies |
| 93 | + run: | |
| 94 | + sudo apt-get install libhdf5-dev libnetcdf-dev |
| 95 | + python -m pip install --upgrade pip |
| 96 | + pip install --upgrade setuptools wheel twine |
| 97 | + pip install -e . |
| 98 | + - name: Build and publish |
| 99 | + env: |
| 100 | + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
| 101 | + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 102 | + run: | |
| 103 | + git fetch --tags --unshallow |
| 104 | + python setup.py sdist bdist_wheel |
| 105 | + twine upload dist/* |
0 commit comments