Skip to content

Commit

Permalink
Re-org CI workflows (#155)
Browse files Browse the repository at this point in the history
* re-org CI workflows: adds support for Py3.12 & linux wheels, separates testing & pypi publishing

* bump version & add python 3.12 to pyproject.toml

* rename test-base to test_base

* remove old Travis build script & doc reference
  • Loading branch information
whitews authored Oct 7, 2023
1 parent ce23348 commit bd8f701
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 73 deletions.
114 changes: 65 additions & 49 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,86 @@
name: Python CI
name: Build wheels

on:
push:
pull_request:
schedule:
- cron: '0 0 * * 0' # weekly
workflow_dispatch:

jobs:
build:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Allow one of the matrix builds to fail without failing others
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']


# The job
name: Python ${{ matrix.python-version }} / ${{ matrix.os }}

# The steps in the job. Each step either RUNS code, or USES an action

steps:

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Run tests and linting
run: |
pip install pip --upgrade
pip install --no-cache-dir -e .[dev,test,lint]
python -m black KDEpy -l 120 --check
python -m flake8 --show-source --ignore=F811,W293,W391,W292,W291,W504,W503,E231 --max-line-length=120 --exclude="*examples.py,testing.py,*kde.py" KDEpy
pytest KDEpy --doctest-modules --capture=sys
- name: Build docs
if: matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest'
continue-on-error: true
run: |
sudo apt install pandoc -y
sphinx-build docs/source _build/html -W
python-version: 3.11

# ======================= BUILD WHEELS AND UPLOAD TO PYPI ==================================
- name: Install cibuildwheel
run: |
pip install --upgrade pip
pip install cibuildwheel==2.15.0
- name: Build wheels (non-windows) ${{ matrix.python-version }} on ${{ matrix.os }}
if: github.ref == 'refs/heads/master' && matrix.python-version == '3.10' && matrix.os != 'windows-latest'
- name: Build wheels
env:
CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-*'
PYPI_PASSWORD: ${{ secrets.pypi_password }}
CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-* cp312-*'
CIBW_ARCHS_MACOS: x86_64 arm64
run: |
pip install cibuildwheel twine --upgrade;
python -m build --sdist
pip install cibuildwheel --upgrade;
python -m cibuildwheel --output-dir dist;
python -m twine upload dist/* -u tommyod -p "$PYPI_PASSWORD" --skip-existing;
- name: Build wheels (windows) ${{ matrix.python-version }} on ${{ matrix.os }}
if: github.ref == 'refs/heads/master' && matrix.python-version == '3.10' && matrix.os == 'windows-latest'
- name: Store artifacts
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/*.whl

package_source:
name: Package source distribution
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install build
run: python -m pip install build

- name: Run sdist
run: python -m build --sdist

- name: Store artifacts
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: ./dist/*.tar.gz

publish_to_pypi:
needs:
- build_wheels
- package_source
runs-on: ubuntu-latest

steps:
- name: Download build files
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/

- name: Upload to PyPI
env:
CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-*'
PYPI_PASSWORD: ${{ secrets.pypi_password }}
run: |
pip install cibuildwheel twine --upgrade;
python -m cibuildwheel --output-dir dist;
python -m twine upload dist/* -u tommyod -p "${env:PYPI_PASSWORD}" --skip-existing;
pip install twine;
python -m twine upload dist/* -u tommyod -p "$PYPI_PASSWORD" --skip-existing;
28 changes: 28 additions & 0 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build docs

on:
workflow_dispatch:

jobs:
build_docs:
name: Build docs
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install packages
run: |
pip install pip --upgrade
pip install --no-cache-dir -e .[dev]
- name: Build docs
run: |
sudo apt install pandoc -y
sphinx-build docs/source _build/html -W
34 changes: 34 additions & 0 deletions .github/workflows/test_base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build & test

on:
workflow_call:

jobs:
build:
name: Python ${{ matrix.python-version }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Allow one of the matrix builds to fail without failing others
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install
run: |
pip install pip --upgrade
pip install -e .[dev,test,lint]
- name: Run tests and linting
run: |
python -m black KDEpy -l 120 --check
python -m flake8 --show-source --ignore=F811,W293,W391,W292,W291,W504,W503,E231 --max-line-length=120 --exclude="*examples.py,testing.py,*kde.py" KDEpy
pytest KDEpy --doctest-modules --capture=sys
13 changes: 13 additions & 0 deletions .github/workflows/test_develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Build & test (develop)

on:
push:
branches:
- develop
pull_request:
branches:
- develop

jobs:
test:
uses: tommyod/KDEpy/.github/workflows/test_base.yml@develop
13 changes: 13 additions & 0 deletions .github/workflows/test_master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Build & test (master)

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
uses: tommyod/KDEpy/.github/workflows/test_base.yml@master
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Deployment

The KDEpy project uses TravisCI and Appveyor to build wheels for Linux, Mac and Windows.
The KDEpy project uses GitHub Actions to build wheels for Linux, Mac and Windows.
Wheels are built using the [cibuildwheel](https://github.com/joerick/cibuildwheel) Python package.
After developing, the following will push a tagged commit -- from there CI will build wheels to distribute to PyPI automatically.

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "KDEpy"
version = "1.1.7"
version = "1.1.8"
dependencies = [
"numpy>=1.14.2,<2.0",
"scipy>=1.0.1,<2.0",
Expand All @@ -18,6 +18,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]

[project.urls]
Expand Down
22 changes: 0 additions & 22 deletions travis/build-wheels.sh

This file was deleted.

0 comments on commit bd8f701

Please sign in to comment.