Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 42 additions & 6 deletions .github/workflows/unittests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ on:
- 'tools/**'
- '.github/workflows/unittests.yaml'

workflow_call:
inputs:
ml_ref:
description: 'luxonis-ml version (branch/tag/SHA)'
required: true
type: string
tools_ref:
description: 'tools version (branch/tag/SHA)'
required: true
type: string

jobs:
run_tests:
strategy:
Expand All @@ -20,7 +31,17 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Checkout at tools_ref
if: ${{ inputs.tools_ref != '' }}
uses: actions/checkout@v4
with:
repository: Luxonis/tools
ref: ${{ inputs.tools_ref }}
path: tools
submodules: recursive # Ensures submodules are cloned

- name: Checkout
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
Expand All @@ -33,31 +54,46 @@ jobs:
cache: pip

- name: Install dependencies
working-directory: ${{ inputs.tools_ref != '' && 'tools' || '' }}
run: |
pip install -e .[dev]
pip install coverage-badge>=1.1.0 pytest-cov>=4.1.0

- name: Install specified luxonis-ml
shell: bash
if: inputs.ml_ref != ''
working-directory: tools
env:
ML_REF: ${{ inputs.ml_ref }}
run: |
pip uninstall luxonis-ml -y
pip install \
"luxonis-ml[data,nn_archive,utils] @ git+https://github.com/luxonis/luxonis-ml.git@${ML_REF}" \
--upgrade --force-reinstall

- name: Run tests with coverage [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
working-directory: ${{ inputs.tools_ref != '' && 'tools' || '' }}
run: pytest tests --cov=tools --cov-report xml --junit-xml pytest.xml

- name: Run tests [Windows, macOS]
if: matrix.os != 'ubuntu-latest' || matrix.version != '3.10'
working-directory: ${{ inputs.tools_ref != '' && 'tools' || '' }}
run: pytest tests --junit-xml pytest.xml

- name: Generate coverage badge [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10' && github.event_name == 'pull_request'
run: coverage-badge -o media/coverage_badge.svg -f

- name: Generate coverage report [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10' && github.event_name == 'pull_request'
uses: orgoro/coverage@v3.1
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}

- name: Commit coverage badge [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10' && github.event_name == 'pull_request'
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
Expand All @@ -66,13 +102,13 @@ jobs:
git commit -m "[Automated] Updated coverage badge"
}
- name: Push changes [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10' && github.event_name == 'pull_request'
uses: ad-m/github-push-action@master
with:
branch: ${{ github.head_ref }}

- name: Upload Test Results
if: always()
if: always() && github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: Test Results [${{ matrix.os }}] (Python ${{ matrix.version }})
Expand All @@ -87,7 +123,7 @@ jobs:
permissions:
checks: write
pull-requests: write
if: always()
if: always() && github.event_name == 'pull_request'

steps:
- name: Checkout
Expand Down
Loading