Runnability tests for DAIv3 oak-examples #257
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: Runnability tests for DAIv3 oak-examples | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| distinct_id: | |
| description: 'run identifier' | |
| required: false | |
| dai_versions: | |
| description: "DepthAI & depthai-nodes versions in the form: depthai=<ver>,nodes=<ver> (e.g. depthai=2.26.0,nodes=1.9.0). Each key is optional." | |
| required: false | |
| python_version: | |
| description: 'Python version to use. By default 3.8, 3.10 and 3.12 are used but you can use only one by passing only `3.8`, `3.10` or `3.12`.' | |
| default: "all" | |
| required: false | |
| log_level: | |
| description: 'Log level to use for pytest.' | |
| type: choice | |
| options: | |
| - ERROR | |
| - INFO | |
| - DEBUG | |
| default: INFO | |
| required: false | |
| reservation_name: | |
| description: 'Reservation name - usually usually unique identifier of root CI run' | |
| required: false | |
| type: string | |
| platform: | |
| description: 'Platform to use for testing. By default both RVC2 and RVC4 are used but you can use only one by passing only `rvc2` or `rvc4`(use lowercase).' | |
| default: "all" | |
| required: false | |
| root_dir: | |
| decription: 'One or more space-separated paths to example directories you want to test. Defaults to "." (all).' | |
| default: "." | |
| required: false | |
| strict_mode: | |
| description: "If set to 'yes', tests will fail on DepthAI warnings." | |
| type: choice | |
| options: | |
| - "yes" | |
| - "no" | |
| default: "no" | |
| required: false | |
| additional_options: | |
| required: false | |
| type: string | |
| subtests: | |
| description: "Specify if should run only peripheral, only standalone or both" | |
| type: choice | |
| options: | |
| - "all" | |
| - "peripheral" | |
| - "standalone" | |
| default: "all" | |
| required: false | |
| jobs: | |
| id: | |
| name: Workflow ID Provider | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: echo distinct ID ${{ github.event.inputs.distinct_id }} | |
| run: echo ${{ github.event.inputs.distinct_id }} | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix_platform: ${{ steps.set-matrix.outputs.platform }} | |
| matrix_python: ${{ steps.set-matrix.outputs.python }} | |
| dai_version: ${{ steps.set-matrix.outputs.dai_version }} | |
| dai_nodes_version: ${{ steps.set-matrix.outputs.dai_nodes_version }} | |
| steps: | |
| - id: set-matrix | |
| env: | |
| INPUT_PLATFORM: ${{ github.event.inputs.platform }} | |
| INPUT_PYTHON: ${{ github.event.inputs.python_version }} | |
| INPUT_DAI_VERSIONS: ${{ github.event.inputs.dai_versions }} | |
| run: | | |
| # Matrix platform | |
| if [ "$INPUT_PLATFORM" = "all" ] || [ -z "$INPUT_PLATFORM" ]; then | |
| echo 'platform=["rvc2","rvc4"]' >> "$GITHUB_OUTPUT" | |
| else | |
| echo "platform=[\"$INPUT_PLATFORM\"]" >> "$GITHUB_OUTPUT" | |
| fi | |
| # Matrix python | |
| if [ "$INPUT_PYTHON" = "all" ] || [ -z "$INPUT_PYTHON" ]; then | |
| echo 'python=["3.8", "3.10", "3.12"]' >> "$GITHUB_OUTPUT" | |
| else | |
| echo "python=[\"$INPUT_PYTHON\"]" >> "$GITHUB_OUTPUT" | |
| fi | |
| # Parse combined versions input like: depthai=2.26.0,nodes=1.9.0 | |
| DAI_VERSION="" | |
| DAI_NODES_VERSION="" | |
| if [ -n "$INPUT_DAI_VERSIONS" ]; then | |
| S="$(echo "$INPUT_DAI_VERSIONS" | tr -d '[:space:]')" # strip spaces | |
| if echo "$S" | grep -qi 'depthai='; then | |
| DAI_VERSION="$(printf '%s' "$S" | sed -n 's/.*depthai=\([^,]*\).*/\1/p')" | |
| fi | |
| if echo "$S" | grep -qi 'nodes='; then | |
| DAI_NODES_VERSION="$(printf '%s' "$S" | sed -n 's/.*nodes=\([^,]*\).*/\1/p')" | |
| fi | |
| fi | |
| echo "dai_version=$DAI_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "dai_nodes_version=$DAI_NODES_VERSION" >> "$GITHUB_OUTPUT" | |
| test_peripheral: | |
| needs: [setup] | |
| runs-on: ["self-hosted", "testbed-runner"] | |
| if: ${{ inputs.subtests== 'all' || inputs.subtests== 'peripheral'}} | |
| strategy: | |
| matrix: | |
| python-version: ${{ fromJSON(needs.setup.outputs.matrix_python) }} | |
| platform: ${{ fromJSON(needs.setup.outputs.matrix_platform) }} | |
| fail-fast: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.12 | |
| cache: pip | |
| - name: Install HIL | |
| run: | | |
| pip install hil_framework --upgrade --index-url https://__token__:${{ secrets.GITLAB_TOKEN }}@gitlab.luxonis.com/api/v4/projects/213/packages/pypi/simple | |
| - name: Set model variable | |
| run: | | |
| if [ "${{ matrix.platform }}" = "rvc2" ]; then | |
| echo "MODEL=oak_d_s2" >> $GITHUB_ENV | |
| elif [ "${{ matrix.platform }}" = "rvc4" ]; then | |
| echo "MODEL=oak4_pro or oak4_d" >> $GITHUB_ENV | |
| fi | |
| - name: Run Test | |
| run: | | |
| export RESERVATION_NAME="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}#${{ matrix.python-version}}-${{ matrix.platform }}" | |
| export INFLUXDB_TOKEN=${{ secrets.INFLUXDB_TOKEN }} | |
| ENV_VARS="\ | |
| --env PLATFORM=${{ matrix.platform }} \ | |
| --env DAI_VERSION=${{ needs.setup.outputs.dai_version }} \ | |
| --env DAI_NODES_VERSION=${{ needs.setup.outputs.dai_nodes_version }} \ | |
| --env PYTHON_VERSION_ENV=${{ matrix.python-version }} \ | |
| --env LOG_LEVEL=${{ github.event.inputs.log_level }} \ | |
| --env ROOT_DIR='${{ github.event.inputs.root_dir }}' \ | |
| --env STRICT_MODE='${{ github.event.inputs.strict_mode }}' " | |
| if [[ -n "${{ github.event.inputs.reservation_name }}" ]]; then | |
| RESERVATION_OPTION="--reservation-name ${{ github.event.inputs.reservation_name }}" | |
| if [[ "${{ github.event.inputs.reservation_name }}" == https://github.com/luxonis/* ]]; then | |
| HOLD_RESERVATION="--hold-reservation" | |
| fi | |
| else | |
| RESERVATION_OPTION="--reservation-name $RESERVATION_NAME" | |
| fi | |
| if [[ -n "${{ github.event.inputs.additional_options }}" ]]; then | |
| ADDITIONAL_OPTIONS="${{ github.event.inputs.additional_options }}" | |
| fi | |
| exec hil_runner --models "$MODEL" $RESERVATION_OPTION $HOLD_RESERVATION --wait $ADDITIONAL_OPTIONS --sync-workspace \ | |
| --dockerfile ./tests/Dockerfile_peripheral \ | |
| --docker-build-args "--build-arg PYTHON_VERSION=${{ matrix.python-version }}" \ | |
| --docker-run-args "$ENV_VARS" | |
| test_standalone: | |
| if: ${{ inputs.subtests== 'all' || inputs.subtests== 'standalone'}} | |
| needs: [setup] | |
| runs-on: ["self-hosted", "testbed-runner"] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.12 | |
| cache: pip | |
| - name: Install HIL | |
| run: | | |
| pip install hil_framework --upgrade --index-url https://__token__:${{ secrets.GITLAB_TOKEN }}@gitlab.luxonis.com/api/v4/projects/213/packages/pypi/simple | |
| - name: Run Test | |
| run: | | |
| export RESERVATION_NAME="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}#standalone" | |
| export INFLUXDB_TOKEN=${{ secrets.INFLUXDB_TOKEN }} | |
| ENV_VARS="\ | |
| --env PLATFORM="rvc4" \ | |
| --env DAI_VERSION=${{ needs.setup.outputs.dai_version }} \ | |
| --env DAI_NODES_VERSION=${{ needs.setup.outputs.dai_nodes_version }} \ | |
| --env PYTHON_VERSION_ENV="3.10" \ | |
| --env LOG_LEVEL=${{ github.event.inputs.log_level }} \ | |
| --env ROOT_DIR='${{ github.event.inputs.root_dir }}' \ | |
| --env STRICT_MODE='${{ github.event.inputs.strict_mode }}' \ | |
| --env DEVICE_PASSWORD=${{ secrets.DEVICE_PASSWORD }}\ | |
| --env LOCAL_STATIC_REGISTRY=${{ secrets.LOCAL_STATIC_REGISTRY }}" | |
| if [[ -n "${{ github.event.inputs.reservation_name }}" ]]; then | |
| RESERVATION_OPTION="--reservation-name ${{ github.event.inputs.reservation_name }}" | |
| if [[ "${{ github.event.inputs.reservation_name }}" == https://github.com/luxonis/* ]]; then | |
| HOLD_RESERVATION="--hold-reservation" | |
| fi | |
| else | |
| RESERVATION_OPTION="--reservation-name $RESERVATION_NAME" | |
| fi | |
| if [[ -n "${{ github.event.inputs.additional_options }}" ]]; then | |
| ADDITIONAL_OPTIONS="${{ github.event.inputs.additional_options }}" | |
| fi | |
| exec hil_runner --models "oak4_pro or oak4_d" $RESERVATION_OPTION $HOLD_RESERVATION --wait $ADDITIONAL_OPTIONS --oakctl --sync-workspace \ | |
| --dockerfile ./tests/Dockerfile_standalone \ | |
| --docker-build-args "--build-arg PYTHON_VERSION=3.12" \ | |
| --docker-run-args "$ENV_VARS" | |