fix: prevent int32 overflow in box_iou #2272
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: Pytest/Test Workflow | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: pytest-test-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| build-pkg: | |
| name: Build this Package | |
| uses: ./.github/workflows/build-package.yml | |
| with: | |
| # only run link check on PRs from the same repo | |
| link-check: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} | |
| run-tests: | |
| name: Pytest Run | |
| # needs: build # todo: consider using this build package for testing | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ["ubuntu-latest", "windows-latest", "macos-latest"] | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| cv2: ["none"] | |
| include: | |
| - { os: "ubuntu-latest", python-version: "3.13", cv2: "opencv-python" } | |
| - { os: "windows-latest", python-version: "3.13", cv2: "opencv-python" } | |
| - { os: "macos-latest", python-version: "3.13", cv2: "opencv-python" } | |
| - { os: "ubuntu-latest", python-version: "3.13", cv2: "opencv-python-headless" } | |
| - { os: "windows-latest", python-version: "3.13", cv2: "opencv-python-headless" } | |
| - { os: "macos-latest", python-version: "3.13", cv2: "opencv-python-headless" } | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: π₯ Checkout the repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: π Install uv and set Python version ${{ matrix.python-version }} | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| activate-environment: true | |
| - name: π Install Packages | |
| run: uv sync --frozen --group dev --extra metrics | |
| - name: π· Install selected OpenCV package | |
| if: matrix.cv2 != 'none' | |
| run: uv pip install ${{ matrix.cv2 }} | |
| - name: π§ Confirm selected cv2 backend | |
| env: | |
| EXPECTED_BACKEND: ${{ matrix.cv2 == 'none' && 'fallback' || 'opencv' }} | |
| run: | | |
| import os | |
| from supervision import _cv2 | |
| expected = os.environ["EXPECTED_BACKEND"] | |
| assert _cv2.BACKEND_NAME == expected, f"expected {expected!r}, got {_cv2.BACKEND_NAME!r}" | |
| shell: python | |
| - name: π¦ Run the Import test | |
| run: python -c "import supervision; from supervision import assets; from supervision import metrics; print(supervision.__version__)" | |
| - name: π Print installed packages | |
| run: uv pip list | |
| - name: π§ͺ Run the Test | |
| run: pytest src/ tests/ --cov=supervision --cov-report=xml | |
| - name: Generate Coverage Report | |
| run: | | |
| coverage xml | |
| coverage report | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v7 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: "coverage.xml" | |
| flags: cpu,${{ runner.os }},python${{ matrix.python-version }} | |
| env_vars: OS,PYTHON | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| - name: Minimize uv cache | |
| run: uv cache prune --ci | |
| clean-wheel: | |
| name: Clean Wheel on ${{ matrix.os }} / Python ${{ matrix.python-version }} | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ["ubuntu-latest", "windows-latest", "macos-latest"] | |
| python-version: ["3.10", "3.13"] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: π₯ Checkout the repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: π Install uv and set Python version ${{ matrix.python-version }} | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| activate-environment: true | |
| - name: ποΈ Build the wheel | |
| run: | | |
| uv sync --frozen --group build | |
| uv build --wheel | |
| - name: π§Ό Create an isolated wheel environment | |
| shell: bash | |
| run: | | |
| uv venv --clear --seed .clean-wheel | |
| if [ "$RUNNER_OS" = "Windows" ]; then | |
| echo "CLEAN_PYTHON=$PWD/.clean-wheel/Scripts/python.exe" >> "$GITHUB_ENV" | |
| else | |
| echo "CLEAN_PYTHON=$PWD/.clean-wheel/bin/python" >> "$GITHUB_ENV" | |
| fi | |
| - name: π¦ Install and verify the wheel without OpenCV | |
| shell: bash | |
| run: | | |
| uv pip install --python "$CLEAN_PYTHON" --strict dist/*.whl | |
| "$CLEAN_PYTHON" .github/scripts/verify_clean_wheel.py \ | |
| --wheel dist/*.whl \ | |
| --python "$CLEAN_PYTHON" \ | |
| --manifest tests/cv2/installed_wheel_fallback_manifest.txt | |
| testing-guardian: | |
| runs-on: ubuntu-latest | |
| needs: [run-tests, clean-wheel] | |
| if: always() | |
| steps: | |
| - name: π Display test result | |
| run: echo "tests=${{ needs.run-tests.result }}, clean-wheel=${{ needs.clean-wheel.result }}" | |
| - name: β Fail guardian on test failure | |
| if: needs.run-tests.result == 'failure' || needs.clean-wheel.result == 'failure' | |
| run: exit 1 | |
| # Ensure that cancelled or skipped test runs still cause this guardian job to fail, | |
| # using an explicit exit code instead of relying on timeout behavior. | |
| - name: β οΈ cancelled or skipped... | |
| if: contains(fromJSON('["cancelled", "skipped"]'), needs.run-tests.result) || contains(fromJSON('["cancelled", "skipped"]'), needs.clean-wheel.result) | |
| run: | | |
| echo "run-tests job result is '${{ needs.run-tests.result }}'; failing explicitly." | |
| exit 1 | |
| - name: β tests succeeded | |
| if: needs.run-tests.result == 'success' | |
| run: echo "All tests completed successfully." |