From bd8f701fcdd0a1d8d04bfecd6a73256827e566e2 Mon Sep 17 00:00:00 2001 From: Scott White Date: Sat, 7 Oct 2023 12:26:52 -0400 Subject: [PATCH] Re-org CI workflows (#155) * 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 --- .github/workflows/build.yml | 114 ++++++++++++++++------------- .github/workflows/build_docs.yml | 28 +++++++ .github/workflows/test_base.yml | 34 +++++++++ .github/workflows/test_develop.yml | 13 ++++ .github/workflows/test_master.yml | 13 ++++ DEVELOPMENT.md | 2 +- pyproject.toml | 3 +- travis/build-wheels.sh | 22 ------ 8 files changed, 156 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/build_docs.yml create mode 100644 .github/workflows/test_base.yml create mode 100644 .github/workflows/test_develop.yml create mode 100644 .github/workflows/test_master.yml delete mode 100644 travis/build-wheels.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 38cc386..1939062 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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; diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml new file mode 100644 index 0000000..e8f7b14 --- /dev/null +++ b/.github/workflows/build_docs.yml @@ -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 diff --git a/.github/workflows/test_base.yml b/.github/workflows/test_base.yml new file mode 100644 index 0000000..06134dc --- /dev/null +++ b/.github/workflows/test_base.yml @@ -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 diff --git a/.github/workflows/test_develop.yml b/.github/workflows/test_develop.yml new file mode 100644 index 0000000..45d1212 --- /dev/null +++ b/.github/workflows/test_develop.yml @@ -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 diff --git a/.github/workflows/test_master.yml b/.github/workflows/test_master.yml new file mode 100644 index 0000000..71485a8 --- /dev/null +++ b/.github/workflows/test_master.yml @@ -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 diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 0aa5f4d..c24ee25 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -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. diff --git a/pyproject.toml b/pyproject.toml index bd745cc..07b598c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -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] diff --git a/travis/build-wheels.sh b/travis/build-wheels.sh deleted file mode 100644 index e88f0b2..0000000 --- a/travis/build-wheels.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -set -e -x - -# Install a system package required by our library -yum install -y atlas-devel - -# Compile wheels -for PYBIN in /opt/python/*/bin; do - "${PYBIN}/pip" install -r /io/requirements.txt - "${PYBIN}/pip" wheel /io/ -w wheelhouse/ -done - -# Bundle external shared libraries into the wheels -for whl in wheelhouse/*.whl; do - auditwheel repair "$whl" -w /io/wheelhouse/ -done - -# Install packages and test -for PYBIN in /opt/python/*/bin/; do - "${PYBIN}/pip" install python-manylinux-demo --no-index -f /io/wheelhouse - (cd "$HOME"; "${PYBIN}/pytest .") -done