Skip to content

build Python wheels with cibuildwheel and add to build workflow #470

build Python wheels with cibuildwheel and add to build workflow

build Python wheels with cibuildwheel and add to build workflow #470

Workflow file for this run

name: build and test
on:
pull_request:
push:
release:
types:
- released
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions: read-all
jobs:
cmake:
strategy:
matrix:
runs-on:
- ubuntu-22.04
- ubuntu-latest
# `large` is x86-64 and `xlarge` is AArch64.
# https://docs.github.com/en/actions/reference/runners/larger-runners#available-macos-larger-runners-and-labels
- macos-14-large
- macos-14-xlarge
- macos-latest-large
# macos-latest-xlarge may timeout.
# https://github.com/google/s2geometry/issues/409
- macos-latest-xlarge
fail-fast: false
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 30
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set NUM_CORES
run: |
NUM_CORES=$(getconf _NPROCESSORS_ONLN)
echo "NUM_CORES=$NUM_CORES" >> $GITHUB_ENV
echo "Detected $NUM_CORES cores"
- name: Setup ccache
uses: hendrikmuhs/ccache-action@33522472633dbd32578e909b315f5ee43ba878ce # v1.2.22
with:
key: ${{ github.job }}-${{ matrix.runs-on }}
- run: mkdir build
- run: >
cmake
-DWITH_PYTHON=OFF
-DFETCH_ABSEIL=ON
-DCMAKE_CXX_STANDARD=17
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
..
working-directory: build/
- run: cmake --build . --parallel ${{ env.NUM_CORES }}
working-directory: build/
- if: always()
run: ctest --parallel ${{ env.NUM_CORES }} --output-on-failure
working-directory: build/
bazel:
runs-on: ubuntu-latest
# We would like to test on the oldest and newest supported.
# https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md
# https://bazel.build/release#support-matrix
# It's not clear how to do that since bazelisk has some magic to pick a
# bazel version.
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Bazel ${{ matrix.bazel }}
uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # v0.19.0
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true
- name: Build and Test
run: |
bazel test \
--keep_going \
--test_verbose_timeout_warnings --test_output=errors \
//...
working-directory: src
python:
strategy:
matrix:
runs-on:
- ubuntu-latest
# `large` is x86-64 and `xlarge` is AArch64.
# https://docs.github.com/en/actions/reference/runners/larger-runners#available-macos-larger-runners-and-labels
- macos-14-large
- macos-14-xlarge
- macos-latest
fail-fast: false
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-tags: true
persist-credentials: false
- uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
with:
package-dir: ./
output-dir: dist/
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: dist-${{ runner.os }}-${{ runner.arch }}
path: ./dist/
python-publish:
if: (github.event_name == 'release') && (github.event.action == 'released')
needs: [python]
runs-on: ubuntu-latest
permissions:
id-token: write
attestations: write
# Requires environment protection rules in GitHub Settings:
# Settings > Environments > pypi > Add required reviewers
environment:
name: pypi
url: https://pypi.org/p/s2geometry
steps:
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
pattern: dist*
path: dist/
merge-multiple: true
- uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0
with:
subject-path: "dist/*"
# To upload to PyPI without a token, add this workflow file as a Trusted Publisher in the project settings on the PyPI website
- uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0