Add a tests for building Python extensions #9
This file contains 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: e2e-extension | |
on: | |
pull_request: | |
paths-ignore: | |
- '**.md' | |
push: | |
branches: | |
- main | |
- releases/* | |
paths-ignore: | |
- '**.md' | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
python-c-extension: | |
name: Test building C extension (Python ${{ matrix.python-version}}, ${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
python-version: ['3.9', 'pypy-3.9-v7.x'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
id: setup-python | |
uses: ./ | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
- name: Install dependencies | |
run: pip install setuptools | |
- name: Build C extension | |
run: pip install . | |
working-directory: __tests__/data/c_extension/ | |
- name: Run C extension | |
run: | | |
${{ steps.setup-python.outputs.python-path }} -c "import helloworld; helloworld.say_hello('world')" | |
python-pyo3-extension: | |
name: Test building pyo3 extension (Python ${{ matrix.python-version}}, ${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
python-version: ['3.9', 'pypy-3.9-v7.x'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
id: setup-python | |
uses: ./ | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
- name: Build pyo3 extension | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: build | |
working-directory: __tests__/data/pyo3_extension/ | |
- name: Install pyo3 extension | |
run: pip install __tests__/data/pyo3_extension/target/wheels/helloworld-*.whl | |
- name: Run pyo3 extension | |
run: | | |
${{ steps.setup-python.outputs.python-path }} -c "import helloworld; helloworld.say_hello('world')" |