robotpy-build meson rewrite #881
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: dist | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# This job limits concurrency on the default branch | |
# - we want it to run so it can populate ccache, but we typically | |
# don't care about when it completes, so limit its concurrency | |
# to stop eating up valuable + slow Windows/macOS runners | |
setup_concurrency: | |
runs-on: ubuntu-latest | |
outputs: | |
max-parallel: ${{ steps.max-parallel.outputs.p }} | |
steps: | |
- name: Setup concurrency | |
shell: bash | |
id: max-parallel | |
run: | | |
if [[ "${{ github.ref_name }}" == "main" ]]; then | |
echo "PARALLEL=1" | |
echo "p={\"v\": 1}" >> $GITHUB_OUTPUT | |
else | |
echo "PARALLEL=10000" | |
echo "p={\"v\": 10000}" >> $GITHUB_OUTPUT | |
fi | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pre-commit/[email protected] | |
check-doc: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
# - uses: actions/setup-python@v5 | |
# with: | |
# python-version: 3.8 | |
# - name: Sphinx | |
# run: | | |
# pip --disable-pip-version-check install -e . | |
# pip --disable-pip-version-check install -r docs/requirements.txt | |
# cd docs && make clean html SPHINXOPTS="-W --keep-going" | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.8 | |
- name: Install build | |
run: python -m pip --disable-pip-version-check install build | |
- name: Build sdist + wheel | |
run: python -m build | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
test: | |
runs-on: ${{ matrix.os }} | |
needs: [setup_concurrency, build] | |
strategy: | |
max-parallel: ${{ fromJSON(needs.setup_concurrency.outputs.max-parallel).v }} | |
matrix: | |
os: ["ubuntu-22.04", "macos-13", "windows-2022"] | |
python_version: | |
- '3.8' | |
- '3.9' | |
- '3.10' | |
- '3.11' | |
- '3.12' | |
- '3.13' | |
architecture: [x64] | |
# exclude: | |
# - os: macos-13 | |
# architecture: x86 | |
# - os: ubuntu-22.04 | |
# architecture: x86 | |
include: | |
- os: macos-14 | |
python_version: 3.9 | |
architecture: arm64 | |
- os: ubuntu-22.04-arm | |
python_version: 3.11 | |
architecture: arm64 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python_version }} | |
architecture: ${{ matrix.architecture }} | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: Setup ccache | |
uses: robotpy/ccache-action@fork | |
with: | |
key: ${{ matrix.os }}-${{ matrix.architecture }}-${{ matrix.python_version }} | |
variant: ccache | |
- name: Setup MSVC | |
uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1 | |
with: | |
architecture: x64 | |
if: runner.os == 'Windows' | |
- name: Configure ccache for MSVC | |
shell: bash | |
# https://github.com/mesonbuild/meson/issues/10423 | |
run: | | |
echo "CC=ccache.exe cl" >> $GITHUB_ENV | |
echo "CXX=ccache.exe cl" >> $GITHUB_ENV | |
if: runner.os == 'Windows' | |
- name: Install | |
shell: bash | |
working-directory: dist | |
run: python -m pip --disable-pip-version-check install *.whl | |
- name: Install test dependencies | |
working-directory: tests | |
run: python -m pip --disable-pip-version-check install -r requirements.txt | |
- name: Test wheel | |
working-directory: tests | |
run: python run_tests.py | |
cross-build: | |
runs-on: ubuntu-latest | |
needs: [setup_concurrency, build] | |
strategy: | |
max-parallel: ${{ fromJSON(needs.setup_concurrency.outputs.max-parallel).v }} | |
matrix: | |
container: | |
- wpilib/roborio-cross-ubuntu:2025-22.04-py313 | |
- wpilib/raspbian-cross-ubuntu:2025-bookworm-22.04-py313 | |
container: | |
image: "${{ matrix.container }}" | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- run: apt-get update | |
- name: Setup ccache | |
uses: robotpy/ccache-action@fork | |
with: | |
key: ${{ matrix.container }} | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: Setup cross environment | |
uses: robotpy/build-actions/setup-cross-meson@semiwrap | |
- name: Install | |
working-directory: dist | |
run: | | |
/build/venv/bin/build-pip --disable-pip-version-check install *.whl | |
- name: Install test dependencies | |
shell: bash | |
working-directory: tests | |
run: | | |
/build/venv/bin/build-pip --disable-pip-version-check install -r requirements.txt | |
- name: Build cross wheel | |
working-directory: tests/cpp | |
run: /build/venv/bin/cross-python run_install.py --config-settings=setup-args=--cross-file=cross.txt | |
publish: | |
runs-on: ubuntu-latest | |
needs: [check, check-doc, test] | |
permissions: | |
id-token: write | |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') | |
steps: | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |