Skip to content

Commit 703f15a

Browse files
authored
CI: split 'build' into 'test' and 'deploy' workflows (#299)
1 parent 5a9bb07 commit 703f15a

File tree

4 files changed

+168
-170
lines changed

4 files changed

+168
-170
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 170 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build and upload to PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
paths:
10+
- '.github/workflows/deploy.yml'
11+
release:
12+
types:
13+
- published
14+
15+
jobs:
16+
build_wheels:
17+
name: Build wheel on ${{ matrix.os }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
os: [windows-latest, ubuntu-latest, macos-latest]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Set up QEMU
27+
if: runner.os == 'Linux'
28+
uses: docker/setup-qemu-action@v3
29+
with:
30+
platforms: arm64
31+
32+
- uses: actions/setup-python@v5
33+
name: Install Python
34+
with:
35+
python-version: '3.11'
36+
37+
- uses: ilammy/msvc-dev-cmd@v1
38+
if: startsWith(matrix.os, 'windows')
39+
40+
- name: Run Windows Preinstall Build
41+
if: startsWith(matrix.os, 'windows')
42+
run: |
43+
choco install vcpython27 -f -y
44+
ci\install_libspatialindex.bat
45+
46+
- name: Build wheels
47+
uses: pypa/[email protected]
48+
49+
- uses: actions/upload-artifact@v4
50+
with:
51+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
52+
path: ./wheelhouse/*.whl
53+
54+
build_sdist:
55+
name: Build source distribution
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Build sdist
61+
run: pipx run build --sdist
62+
63+
- uses: actions/upload-artifact@v4
64+
with:
65+
name: cibw-sdist
66+
path: dist/*.tar.gz
67+
68+
upload_pypi:
69+
needs: [build_wheels, build_sdist]
70+
runs-on: ubuntu-latest
71+
environment: pypi
72+
permissions:
73+
id-token: write
74+
if: github.event_name == 'release' && github.event.action == 'published'
75+
steps:
76+
- uses: actions/download-artifact@v4
77+
with:
78+
pattern: cibw-*
79+
path: dist
80+
merge-multiple: true
81+
82+
- uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- '.github/workflows/test.yml'
9+
pull_request:
10+
workflow_dispatch:
11+
schedule:
12+
- cron: '0 6 * * 1'
13+
14+
jobs:
15+
pre-commit:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-python@v5
20+
- uses: pre-commit/[email protected]
21+
22+
conda:
23+
name: Conda ${{ matrix.python-version }} - ${{ matrix.os }}
24+
defaults:
25+
run:
26+
shell: bash -l {0}
27+
runs-on: ${{ matrix.os }}
28+
strategy:
29+
fail-fast: true
30+
matrix:
31+
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
32+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
33+
sidx-version: ['1.8.5','1.9.3']
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: conda-incubator/setup-miniconda@v3
38+
with:
39+
channels: conda-forge
40+
auto-update-conda: true
41+
python-version: ${{ matrix.python-version }}
42+
- name: Setup
43+
run: |
44+
conda install -c conda-forge numpy libspatialindex=${{ matrix.sidx-version }} -y
45+
- name: Install
46+
run: |
47+
pip install -e .
48+
- name: Test with pytest
49+
run: |
50+
pip install pytest
51+
python -m pytest --doctest-modules rtree tests
52+
53+
ubuntu:
54+
name: Ubuntu Python ${{ matrix.python-version }}
55+
defaults:
56+
run:
57+
shell: bash -l {0}
58+
runs-on: ubuntu-latest
59+
strategy:
60+
fail-fast: true
61+
matrix:
62+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
63+
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: actions/setup-python@v5
67+
name: Install Python
68+
with:
69+
python-version: '3.11'
70+
- name: Setup
71+
run: |
72+
sudo apt install libspatialindex-c6 python3-pip
73+
python3 -m pip install --upgrade pip
74+
python3 -m pip install setuptools numpy pytest
75+
76+
- name: Build
77+
run: |
78+
python3 -m pip install --user .
79+
- name: Test with pytest
80+
run: |
81+
python3 -m pytest --doctest-modules rtree tests

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ repos:
55
- id: check-yaml
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
8+
- repo: https://github.com/python-jsonschema/check-jsonschema
9+
rev: 0.27.3
10+
hooks:
11+
- id: check-github-workflows
12+
args: ["--verbose"]
813
- repo: https://github.com/psf/black
914
rev: 23.9.1
1015
hooks:

0 commit comments

Comments
 (0)