Skip to content

Commit

Permalink
CI: split 'build' into 'test' and 'deploy' workflows (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtoews authored Jan 19, 2024
1 parent 5a9bb07 commit 703f15a
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 170 deletions.
170 changes: 0 additions & 170 deletions .github/workflows/build.yml

This file was deleted.

82 changes: 82 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build and upload to PyPI

on:
workflow_dispatch:
pull_request:
push:
branches:
- master
paths:
- '.github/workflows/deploy.yml'
release:
types:
- published

jobs:
build_wheels:
name: Build wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v4

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'

- uses: ilammy/msvc-dev-cmd@v1
if: startsWith(matrix.os, 'windows')

- name: Run Windows Preinstall Build
if: startsWith(matrix.os, 'windows')
run: |
choco install vcpython27 -f -y
ci\install_libspatialindex.bat
- name: Build wheels
uses: pypa/cibuildwheel@v2.16.2

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
81 changes: 81 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Test

on:
push:
branches:
- master
paths:
- '.github/workflows/test.yml'
pull_request:
workflow_dispatch:
schedule:
- cron: '0 6 * * 1'

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.0

conda:
name: Conda ${{ matrix.python-version }} - ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
sidx-version: ['1.8.5','1.9.3']

steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
channels: conda-forge
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Setup
run: |
conda install -c conda-forge numpy libspatialindex=${{ matrix.sidx-version }} -y
- name: Install
run: |
pip install -e .
- name: Test with pytest
run: |
pip install pytest
python -m pytest --doctest-modules rtree tests
ubuntu:
name: Ubuntu Python ${{ matrix.python-version }}
defaults:
run:
shell: bash -l {0}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'
- name: Setup
run: |
sudo apt install libspatialindex-c6 python3-pip
python3 -m pip install --upgrade pip
python3 -m pip install setuptools numpy pytest
- name: Build
run: |
python3 -m pip install --user .
- name: Test with pytest
run: |
python3 -m pytest --doctest-modules rtree tests
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.3
hooks:
- id: check-github-workflows
args: ["--verbose"]
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
Expand Down

0 comments on commit 703f15a

Please sign in to comment.