Skip to content

Commit

Permalink
re-org CI workflows: adds support for Py3.12 & linux wheels, separate…
Browse files Browse the repository at this point in the history
…s testing & pypi publishing
  • Loading branch information
whitews committed Oct 6, 2023
1 parent ce23348 commit 93f9df7
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 49 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

0 comments on commit 93f9df7

Please sign in to comment.