Improve coverage #85
Workflow file for this run
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: "Python Bindings Unit Tests" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| concurrency: | |
| group: build-python-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| python-tests: | |
| name: "Test Python bindings" | |
| strategy: | |
| matrix: | |
| on: [ 'ubuntu-22.04', 'ubuntu-24.04', 'macos-15-intel', 'macos-26' ] | |
| python: [ '3.10', '3.11', '3.12', '3.13' ] | |
| runs-on: ${{ matrix.on }} | |
| env: | |
| INSTALL_PREFIX: "/usr/local" | |
| steps: | |
| - name: "Checkout repository" | |
| uses: actions/checkout@v4 | |
| - name: "Set up Python ${{ matrix.python }}" | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| # Install platform build dependencies | |
| - name: "Install system packages (Ubuntu)" | |
| if: startsWith(matrix.on, 'ubuntu-') | |
| run: sudo apt-get update && sudo apt-get install -y ninja-build g++ cmake | |
| - name: "Setup Homebrew (macOS)" | |
| if: startsWith(matrix.on, 'macos-') | |
| uses: Homebrew/actions/setup-homebrew@main | |
| - name: "Install system packages (macOS)" | |
| if: startsWith(matrix.on, 'macos-') | |
| run: brew install ninja gcc cmake | |
| # Install Python build dependencies | |
| - name: "Build and Install Python wheel" | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -r build-requirements.txt | |
| python -m build \ | |
| -Ccmake.define.ENABLE_COVERAGE=ON \ | |
| -Ccmake.build-type=Debug \ | |
| -Ccmake.define.CAPIO_CL_BUILD_TESTS=OFF | |
| pip install dist/*.whl | |
| # Run unit tests | |
| - name: "Run Python tests" | |
| run: | | |
| python -m pip install -r test-requirements.txt | |
| pytest -v tests/python/test_* | |
| - name: "Generate coverage report" | |
| if: ${{ startsWith(matrix.on, 'ubuntu-') }} | |
| run: | | |
| pip install --upgrade gcovr | |
| gcovr \ | |
| --exclude-throw-branches \ | |
| --xml coverage.xml \ | |
| . | |
| - name: "Upload coverage report" | |
| if: ${{ startsWith(matrix.on, 'ubuntu-') }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ format('{0}-{1}-tests', matrix.on, matrix.python) }} | |
| path: ./coverage.xml | |
| retention-days: 1 | |
| if-no-files-found: error | |
| upload-to-codecov: | |
| name: "Codecov report upload" | |
| needs: [ "python-tests" ] | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: "Download artifacts" | |
| uses: actions/download-artifact@v4 | |
| - name: "Upload coverage to Codecov" | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| fail_ci_if_error: true | |
| token: ${{ secrets.CODECOV_TOKEN }} |