|
1 | | -name: "Python Bindings Unit Tests" |
| 1 | +name: "Python Bindings Build & Test" |
| 2 | + |
2 | 3 | on: |
3 | 4 | push: |
4 | | - branches: |
5 | | - - main |
| 5 | + branches: [ main ] |
6 | 6 | pull_request: |
7 | | - branches: |
8 | | - - main |
| 7 | + branches: [ main ] |
| 8 | + |
9 | 9 | concurrency: |
10 | 10 | group: build-python-${{ github.event.pull_request.number || github.ref }} |
11 | 11 | cancel-in-progress: true |
| 12 | + |
12 | 13 | jobs: |
13 | | - python-tests: |
14 | | - name: "Test Python bindings" |
| 14 | + build_wheels: |
| 15 | + name: Build wheels on ${{ matrix.os }} |
| 16 | + runs-on: ${{ matrix.os }} |
15 | 17 | strategy: |
16 | 18 | matrix: |
17 | | - on: [ 'ubuntu-24.04', 'macos-15-intel', 'macos-26' ] |
18 | | - python: [ '3.10', '3.11', '3.12', '3.13', '3.14' ] |
| 19 | + os: |
| 20 | + - 'ubuntu-24.04' |
| 21 | + - 'ubuntu-24.04-arm' |
| 22 | + - 'macos-26-intel' |
| 23 | + - 'macos-26' |
19 | 24 |
|
20 | | - runs-on: ${{ matrix.on }} |
21 | 25 | env: |
22 | | - INSTALL_PREFIX: "/usr/local" |
23 | | - |
24 | | - steps: |
25 | | - - name: "Checkout repository" |
26 | | - uses: actions/checkout@v6 |
27 | | - |
28 | | - - name: "Set up Python ${{ matrix.python }}" |
29 | | - uses: actions/setup-python@v6 |
30 | | - with: |
31 | | - python-version: ${{ matrix.python }} |
32 | | - |
33 | | - # Install platform build dependencies |
34 | | - - name: "Install system packages (Ubuntu)" |
35 | | - if: startsWith(matrix.on, 'ubuntu-') |
36 | | - run: sudo apt-get update && sudo apt-get install -y ninja-build g++ cmake libcurl4-gnutls-dev |
37 | | - |
38 | | - - name: "Setup Homebrew (macOS)" |
39 | | - if: startsWith(matrix.on, 'macos-') |
40 | | - uses: Homebrew/actions/setup-homebrew@main |
41 | | - |
42 | | - - name: "Install system packages (macOS)" |
43 | | - if: startsWith(matrix.on, 'macos-') |
44 | | - run: brew install ninja gcc cmake curl |
45 | | - |
46 | | - - name: "Create virtual environment" |
47 | | - run: | |
48 | | - pip install -r build-requirements.txt |
49 | | - pip install -r test-requirements.txt |
| 26 | + CIBW_BEFORE_ALL_LINUX: > |
| 27 | + pip install cmake ninja |
| 28 | + CIBW_BEFORE_ALL_MACOS: > |
| 29 | + brew install ninja gcc cmake curl |
50 | 30 |
|
51 | | - # Install Python build dependencies |
52 | | - - name: "Build and Install Python package" |
53 | | - run: | |
54 | | - mkdir -p /tmp/capio_cl_jsons |
55 | | - mkdir -p /tmp/capio_cl_tomls |
56 | | - cp -r tests/jsons/* /tmp/capio_cl_jsons |
57 | | - cp -r tests/tomls/* /tmp/capio_cl_tomls |
58 | | - pip install . |
| 31 | + CIBW_BEFORE_BUILD: > |
| 32 | + pip install -r build-requirements.txt && |
| 33 | + mkdir -p /tmp/capio_cl_jsons /tmp/capio_cl_tomls && |
| 34 | + cp -r tests/jsons/* /tmp/capio_cl_jsons/ && |
| 35 | + cp -r tests/tomls/* /tmp/capio_cl_tomls/ |
59 | 36 |
|
60 | | - # Run unit tests |
61 | | - - name: "Run Python tests (Ubuntu)" |
62 | | - if: startsWith(matrix.on, 'ubuntu-') |
63 | | - run: | |
64 | | - pytest -v tests/python/test_* |
| 37 | + CIBW_BEFORE_TEST: pip install -r test-requirements.txt |
65 | 38 |
|
66 | | - - name: "Run Python tests (MacOS)" |
67 | | - if: startsWith(matrix.on, 'macos-') |
68 | | - run: | |
69 | | - pytest -k "not test_home_node" -v tests/python/test_* |
| 39 | + CIBW_TEST_COMMAND_LINUX: "pytest -v {project}/tests/python/test_*" |
| 40 | + CIBW_TEST_COMMAND_MACOS: "pytest -k 'not test_home_node' -v {project}/tests/python/test_*" |
70 | 41 |
|
71 | | -
|
72 | | - - name: "Generate coverage report" |
73 | | - if: ${{ startsWith(matrix.on, 'ubuntu-') }} |
74 | | - run: | |
75 | | - pip install --upgrade gcovr |
76 | | - gcovr \ |
77 | | - --exclude-throw-branches \ |
78 | | - --gcov-ignore-parse-errors=negative_hits.warn \ |
79 | | - --exclude tests/ \ |
80 | | - --xml coverage.xml \ |
81 | | - . |
82 | | -
|
83 | | - - name: "Upload coverage report" |
84 | | - if: ${{ startsWith(matrix.on, 'ubuntu-') }} |
85 | | - uses: actions/upload-artifact@v7 |
86 | | - with: |
87 | | - name: ${{ format('{0}-{1}-tests', matrix.on, matrix.python) }} |
88 | | - path: ./coverage.xml |
89 | | - retention-days: 1 |
90 | | - if-no-files-found: error |
91 | | - |
92 | | - riscv-tests: |
93 | | - name: "Build & Test on RISC-V (QEMU)" |
94 | | - strategy: |
95 | | - matrix: |
96 | | - python: [ '3.10', '3.11', '3.12', '3.13', '3.14' ] |
97 | | - runs-on: ubuntu-latest |
98 | | - |
99 | | - env: |
100 | | - INSTALL_PREFIX: "/usr/local" |
101 | | - PYTHON_VERSION: "${{ matrix.python }}" |
| 42 | + CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-* cp314-*" |
102 | 43 |
|
103 | 44 | steps: |
104 | | - - name: "Checkout repository" |
| 45 | + - name: Checkout repository |
105 | 46 | uses: actions/checkout@v6 |
106 | 47 |
|
107 | | - - name: "Build and test inside RISC-V emulated environment (Debian based)" |
108 | | - uses: uraimo/run-on-arch-action@v3 |
109 | | - with: |
110 | | - arch: riscv64 |
111 | | - distro: ubuntu_latest |
112 | | - githubToken: ${{ github.token }} |
113 | | - |
114 | | - install: | |
115 | | - apt-get update |
116 | | - DEBIAN_FRONTEND=noninteractive apt-get install -y \ |
117 | | - python3 python3-pip python3-venv python3-wheel python3-setuptools \ |
118 | | - g++ cmake ninja-build git |
119 | | -
|
120 | | - run: | |
121 | | - set -eux |
122 | | - echo "Building for RISC-V on Ubuntu 22.04" |
123 | | - |
124 | | - python3 -m pip install -r build-requirements.txt --break-system-packages |
125 | | - |
126 | | - mkdir -p /tmp/capio_cl_jsons |
127 | | - mkdir -p /tmp/capio_cl_tomls |
128 | | - cp -r tests/jsons/* /tmp/capio_cl_jsons |
129 | | - cp -r tests/tomls/* /tmp/capio_cl_tomls |
130 | | - |
131 | | - python3 -m build \ |
132 | | - -Ccmake.define.ENABLE_COVERAGE=OFF \ |
133 | | - -Ccmake.build-type=Release \ |
134 | | - -Ccmake.define.CAPIO_CL_BUILD_TESTS=OFF |
135 | | - |
136 | | - pip install dist/*.whl --break-system-packages |
137 | | - python3 -m pip install -r test-requirements.txt --break-system-packages |
| 48 | + - name: Build wheels |
| 49 | + uses: pypa/cibuildwheel@v3.4.0 |
| 50 | + env: |
| 51 | + MACOSX_DEPLOYMENT_TARGET: "10.15" |
138 | 52 |
|
139 | | - pytest -v tests/python/test_* | tee pytest-riscv.log |
| 53 | + - name: Upload artifacts |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| 57 | + path: ./wheelhouse/*.whl |
0 commit comments