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: uses: ./.github/workflows/build-package.yml run-tests: name: Import Test and 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.9", "3.10", "3.11", "3.12", "3.13"] runs-on: ${{ matrix.os }} steps: - name: ๐Ÿ“ฅ Checkout the repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: ๐Ÿ Install uv and set Python version ${{ matrix.python-version }} uses: astral-sh/setup-uv@803947b9bd8e9f986429fa0c5a41c367cd732b41 # v7.2.1 with: python-version: ${{ matrix.python-version }} activate-environment: true - name: ๐Ÿš€ Install Packages run: uv pip install -r pyproject.toml --group dev --group docs --extra metrics - name: ๐Ÿ“ฆ Run the Import test run: uv run python -c "import supervision; from supervision import assets; from supervision import metrics; print(supervision.__version__)" - name: ๐Ÿงช Run the Test run: uv run pytest --cov=supervision --cov-report=xml --ignore=examples - name: Generate Coverage Report run: | coverage xml coverage report - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 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 testing-guardian: runs-on: ubuntu-latest needs: run-tests if: always() steps: - name: ๐Ÿ“‹ Display test result run: echo "${{ needs.run-tests.result }}" - name: โŒ Fail guardian on test failure if: needs.run-tests.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) 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 in job 'run-tests'."