Skip to content

Commit

Permalink
Merge pull request #294 from boutproject/modernise-packaging
Browse files Browse the repository at this point in the history
Modernise packaging and CI
  • Loading branch information
ZedThree authored Jul 27, 2023
2 parents e3752ba + ea879a0 commit 216c14b
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 256 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: black

on:
pull_request:
paths:
- '**.py'

defaults:
run:
shell: bash

jobs:
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install black
run: |
python -m pip install --upgrade pip
pip install black
- name: Version
run: |
python --version
black --version
- name: Run black
run: |
black xbout
black docs
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Apply black formatting"
54 changes: 17 additions & 37 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,56 +20,54 @@ jobs:
if: always()
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', 3.x]
pip-packages:
- "setuptools pip pytest pytest-cov coverage boutdata xarray numpy>=1.16.0"
python-version: ["3.8", "3.9", "3.10", "3.11", "3.x"]
fail-fast: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install libhdf5-dev libnetcdf-dev
python -m pip install --upgrade pip
pip install --upgrade ${{ matrix.pip-packages }}
pip install -e .
- name: Install package
run: |
pip install -e .[calc,tests]
- name: Test with pytest
run: |
pip install pytest
pytest -v --long --cov
pytest -vv --long --cov
pytest-min-versions:
# test with oldest supported version of packages
pytest-oldest-xarray:

runs-on: ubuntu-latest
if: always()
strategy:
matrix:
python-version: [3.8]
pip-packages:
- "setuptools pip pytest pytest-cov coverage boutdata==0.1.4 xarray==0.18.0 dask==2.10.0 numpy==1.18.0 natsort==5.5.0 matplotlib==3.1.1 animatplot==0.4.2 netcdf4==1.4.2 Pillow==6.1.0" # test with oldest supported version of packages. Note, using numpy==1.18.0 as a workaround because numpy==1.17.0 is not supported on Python-3.7, even though we should currently support numpy==1.17.0.
python-version: ["3.8"]
fail-fast: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install libhdf5-dev libnetcdf-dev
python -m pip install --upgrade pip
pip install --upgrade ${{ matrix.pip-packages }}
pip install -e .
pip install xarray~=0.18.0 pandas~=1.4.0
- name: Install package
run: |
pip install -e .[tests]
- name: Test with pytest
run: |
pip install pytest
pytest -v --long --cov
pytest -vv --long --cov
# Need to tidy up the things that flake8 finds before we activate this
Expand All @@ -89,21 +87,3 @@ jobs:
# run: |
# pip install flake8
# flake8


black:

runs-on: ubuntu-latest
if: always()

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Check formatting with black
run: |
pip install black
black --check .
55 changes: 17 additions & 38 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,57 +20,54 @@ jobs:
if: always()
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', 3.x]
pip-packages:
- "setuptools pip pytest pytest-cov coverage boutdata xarray numpy>=1.16.0"
python-version: ["3.8", "3.9", "3.10", "3.x"]
fail-fast: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install libhdf5-dev libnetcdf-dev
python -m pip install --upgrade pip
pip install --upgrade ${{ matrix.pip-packages }}
pip install -e .
- name: Install package
run: |
pip install -e .[calc,tests]
- name: Test with pytest
run: |
pip install pytest
pytest -v --long --cov
pytest -vv --long --cov
pytest-min-versions:
# test with oldest supported version of packages
pytest-oldest-xarray:

runs-on: ubuntu-latest
if: always()
strategy:
matrix:
python-version: [3.8]
pip-packages:
- "setuptools pip pytest pytest-cov coverage boutdata==0.1.4 xarray==0.18.0 dask==2.10.0 numpy==1.18.0 natsort==5.5.0 matplotlib==3.1.1 animatplot==0.4.2 netcdf4==1.4.2 Pillow==7.2.0" # test with oldest supported version of packages. Note, using numpy==1.18.0 as a workaround because numpy==1.17.0 is not supported on Python-3.7, even though we should currently support numpy==1.17.0.
python-version: ["3.8"]
fail-fast: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install libhdf5-dev libnetcdf-dev
python -m pip install --upgrade pip
pip install --upgrade ${{ matrix.pip-packages }}
pip install -e .
pip install xarray~=0.18.0 pandas~=1.4.0
- name: Install package
run: |
pip install -e .[tests]
- name: Test with pytest
run: |
pip install pytest
pytest -v --long --cov
pytest -vv --long --cov
# Need to tidy up the things that flake8 finds before we activate this
#flake8:
Expand All @@ -89,21 +86,3 @@ jobs:
# run: |
# pip install flake8
# flake8


black:

runs-on: ubuntu-latest
if: always()

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Check formatting with black
run: |
pip install black
black --check .
123 changes: 12 additions & 111 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,125 +5,26 @@ name: Upload Python Package

on:
release:
types: [created]
types: [published]

jobs:
pytest:

runs-on: ubuntu-latest
if: always()
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', 3.x]
pip-packages:
- "setuptools pip pytest boutdata xarray numpy>=1.16.0"
fail-fast: true

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install libhdf5-dev libnetcdf-dev
python -m pip install --upgrade pip
pip install --upgrade ${{ matrix.pip-packages }}
pip install -e .
- name: Test with pytest
run: |
pip install pytest
pytest -v --long
pytest-min-versions:

runs-on: ubuntu-latest
if: always()
strategy:
matrix:
python-version: [3.8]
pip-packages:
- "setuptools pip pytest boutdata==0.1.4 xarray==0.18.0 dask==2.10.0 numpy==1.18.0 natsort==5.5.0 matplotlib==3.1.1 animatplot==0.4.2 netcdf4==1.4.2 Pillow==7.2.0" # test with oldest supported version of packages. Note, using numpy==1.18.0 as a workaround because numpy==1.17.0 is not supported on Python-3.7, even though we should currently support numpy==1.17.0.
fail-fast: true

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install libhdf5-dev libnetcdf-dev
python -m pip install --upgrade pip
pip install --upgrade ${{ matrix.pip-packages }}
pip install -e .
- name: Test with pytest
run: |
pip install pytest
pytest -v --long
# Need to tidy up the things that flake8 finds before we activate this
#flake8:

# runs-on: ubuntu-latest
# if: always()

# steps:
# - uses: actions/checkout@v2
# - name: Set up Python
# uses: actions/setup-python@v1
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# - name: Lint with flake8
# run: |
# pip install flake8
# flake8


black:

runs-on: ubuntu-latest
if: always()

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Check formatting with black
run: |
pip install black
black --check .
deploy:

name: Upload release to PyPI
runs-on: ubuntu-latest
needs: [pytest, pytest-min-versions, black]

environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install libhdf5-dev libnetcdf-dev
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine
pip install -e .
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
git fetch --tags --unshallow
python setup.py sdist bdist_wheel
twine upload dist/*
python -m pip install --upgrade pip build
- name: Build package
runs: python -m build --sdist --wheel
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Loading

0 comments on commit 216c14b

Please sign in to comment.