Skip to content

Commit dd0f17a

Browse files
Windows hil (#1465)
windows hil tests
1 parent 76d7345 commit dd0f17a

File tree

4 files changed

+200
-34
lines changed

4 files changed

+200
-34
lines changed

.github/workflows/test.workflow.yml

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -82,39 +82,13 @@ jobs:
8282
CONTAINER_REGISTRY: ${{ secrets.CONTAINER_REGISTRY }}
8383
HIL_PAT_TOKEN: ${{ secrets.HIL_PAT_TOKEN }}
8484

85-
windows_rvc2_rvc4_test:
85+
run_windows_tests:
8686
needs: [precheck]
8787
if: needs.precheck.outputs.should_run == 'true'
88-
runs-on: ['self-hosted', 'windows', 'hil-test']
89-
env:
90-
LOCALAPPDATA: "C:/actions-runner/vcpkg_cache"
91-
steps:
92-
- uses: actions/checkout@v3
93-
with:
94-
submodules: 'recursive'
95-
96-
- name: Configure, Build and Test
97-
run: |
98-
$isPR = "${{ github.head_ref }}" -ne ""
99-
$extraFlags = ""
100-
101-
if (-not $isPR) {
102-
$extraFlags = @(
103-
'-DDEPTHAI_BUILD_EXAMPLES=ON',
104-
'-DDEPTHAI_BUILD_PYTHON=ON',
105-
'-DDEPTHAI_PYTHON_ENABLE_TESTS=ON',
106-
'-DDEPTHAI_TEST_EXAMPLES=ON',
107-
'-DDEPTHAI_PYTHON_TEST_EXAMPLES=ON',
108-
'-DDEPTHAI_PYTHON_ENABLE_EXAMPLES=ON'
109-
) -join ' '
110-
}
111-
112-
$cmakeConfigureCommand = "cmake -S . -B build -D CMAKE_BUILD_TYPE=Release -DDEPTHAI_VCPKG_INTERNAL_ONLY=OFF -DVCPKG_OVERLAY_TRIPLETS=./cmake/triplets/release -DDEPTHAI_BUILD_TESTS=ON $extraFlags"
113-
Write-Host "Running: $cmakeConfigureCommand"
114-
Invoke-Expression $cmakeConfigureCommand
88+
uses: ./.github/workflows/test_child_windows.yml
89+
with:
90+
luxonis_os_versions_to_test: "['1.18.3']"
91+
secrets:
92+
CONTAINER_REGISTRY: ${{ secrets.CONTAINER_REGISTRY }}
93+
HIL_PAT_TOKEN: ${{ secrets.HIL_PAT_TOKEN }}
11594

116-
$cmakeBuildCommand = "cmake --build build --parallel 4 --config Release"
117-
Write-Host "Running: $cmakeBuildCommand"
118-
Invoke-Expression $cmakeBuildCommand
119-
cd tests
120-
python run_tests.py
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Run hil tests for windows
2+
on:
3+
workflow_call:
4+
inputs:
5+
luxonis_os_versions_to_test:
6+
required: true
7+
type: string
8+
secrets:
9+
CONTAINER_REGISTRY:
10+
required: true
11+
HIL_PAT_TOKEN:
12+
required: true
13+
14+
jobs:
15+
build_windows_tests:
16+
runs-on: windows-latest
17+
outputs:
18+
artifact_id: ${{ steps.reuse.outputs.artifact_id || steps.artifact-upload-step.outputs.artifact-id }}
19+
env:
20+
BUILD_TYPE: Release
21+
VCPKG_ROOT: C:\vcpkg
22+
VCPKG_FEATURE_FLAGS: manifests,registries,binarycaching
23+
VCPKG_DEFAULT_TRIPLET: x64-windows
24+
VCPKG_DOWNLOADS: C:\vcpkg_downloads
25+
VCPKG_DEFAULT_BINARY_CACHE: C:\vcpkg_binaries
26+
steps:
27+
28+
- name: Try reusing existing artifact for this commit
29+
id: reuse
30+
shell: pwsh
31+
env:
32+
GH_TOKEN: ${{ github.token }}
33+
REPO: ${{ github.repository }}
34+
RUN_ID: ${{ github.run_id }}
35+
ARTIFACT_NAME: depthai-core-win-${{ github.sha }}
36+
run: |
37+
Write-Host "REPO=$env:REPO RUN_ID=$env:RUN_ID NAME=$env:ARTIFACT_NAME"
38+
$id = gh api "repos/$env:REPO/actions/runs/$env:RUN_ID/artifacts" `
39+
--jq ".artifacts[] | select(.name==""$env:ARTIFACT_NAME"" and .expired==false) | .id"
40+
if ($id) {
41+
"skip_build=true" >> $env:GITHUB_OUTPUT
42+
"artifact_id=$id" >> $env:GITHUB_OUTPUT
43+
Write-Host "Found artifact id=$id on this run; skipping build."
44+
} else {
45+
"skip_build=false" >> $env:GITHUB_OUTPUT
46+
Write-Host "No artifact named $env:ARTIFACT_NAME on this run."
47+
}
48+
49+
50+
- name: Checkout depthai
51+
uses: actions/checkout@v4
52+
if: steps.reuse.outputs.skip_build != 'true'
53+
with:
54+
submodules: recursive
55+
56+
- name: Ensure cache dirs and build dir
57+
shell: powershell
58+
if: steps.reuse.outputs.skip_build != 'true'
59+
run: |
60+
New-Item -ItemType Directory -Force -Path "C:\vcpkg_binaries" | Out-Null
61+
New-Item -ItemType Directory -Force -Path "C:\depthai-core" | Out-Null
62+
Write-Host "Copying source from $env:GITHUB_WORKSPACE to C:\depthai-core ..."
63+
Copy-Item -Path "$env:GITHUB_WORKSPACE\*" -Destination "C:\depthai-core" -Recurse -Force
64+
65+
- name: Cache vcpkg binary cache
66+
uses: actions/cache@v4
67+
if: steps.reuse.outputs.skip_build != 'true'
68+
with:
69+
path: C:\vcpkg_binaries
70+
key: vcpkg-archives-${{ runner.os }}-${{ hashFiles('vcpkg.json') }}-${{ env.VCPKG_DEFAULT_TRIPLET }}
71+
restore-keys: |
72+
vcpkg-archives-${{ runner.os }}-${{ hashFiles('vcpkg.json') }}-${{ env.VCPKG_DEFAULT_TRIPLET }}
73+
74+
- name: Configure and Build
75+
if: steps.reuse.outputs.skip_build != 'true'
76+
run: |
77+
cd C:\depthai-core
78+
Invoke-WebRequest `
79+
-Uri "https://github.com/winpython/winpython/releases/download/17.2.20250920/WinPython64-3.13.7.0dotrc.zip" `
80+
-OutFile "winpython.zip"
81+
New-Item -ItemType Directory -Force -Path "C:\depthai-core\winpython" | Out-Null
82+
Expand-Archive -Path winpython.zip -DestinationPath "C:\depthai-core\winpython"
83+
$PYROOT = "C:\depthai-core\winpython\WPy64-31700\python\"
84+
C:\depthai-core\winpython\WPy64-31700\python\python.exe -m venv venv
85+
.\venv\Scripts\Activate.ps1
86+
python -c "import sys; print('using:', sys.executable)"
87+
pip install --upgrade pip
88+
pip install numpy pytest pytest-html
89+
$buildDir = 'C:/depthai-core/build'
90+
$overlay = 'C:/depthai-core/cmake/triplets/release' # make it absolute
91+
$isPR = "${{ github.head_ref }}" -ne ""
92+
$extraFlags = ""
93+
94+
# Base args
95+
$cmakeArgs = @(
96+
'-S','.',
97+
'-B', $buildDir,
98+
'-DCMAKE_BUILD_TYPE=Release',
99+
'-DDEPTHAI_VCPKG_INTERNAL_ONLY=OFF',
100+
"-DVCPKG_OVERLAY_TRIPLETS=$overlay",
101+
'-DDEPTHAI_BUILD_TESTS=ON'
102+
)
103+
104+
# Conditionally add extras (only on non-PR builds)
105+
if (-not $isPR) {
106+
$cmakeArgs += @(
107+
'-DDEPTHAI_BUILD_EXAMPLES=ON',
108+
'-DDEPTHAI_BUILD_PYTHON=ON',
109+
'-DDEPTHAI_PYTHON_ENABLE_TESTS=ON',
110+
'-DDEPTHAI_TEST_EXAMPLES=ON',
111+
'-DDEPTHAI_PYTHON_TEST_EXAMPLES=ON',
112+
'-DDEPTHAI_PYTHON_ENABLE_EXAMPLES=ON'
113+
)
114+
}
115+
116+
# Show & run
117+
Write-Host "cmake args:`n$($cmakeArgs -join ' ')"
118+
& cmake @cmakeArgs
119+
120+
$cmakeBuildCommand = "cmake --build C:/depthai-core/build --parallel 2 --config Release"
121+
Write-Host "Running: $cmakeBuildCommand"
122+
Invoke-Expression $cmakeBuildCommand
123+
124+
- name: Upload artifact
125+
if: steps.reuse.outputs.skip_build != 'true'
126+
id: artifact-upload-step
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: depthai-core-win-${{ github.sha }}
130+
path: C:\depthai-core
131+
retention-days: 1
132+
133+
run_windows_tests_rvc4:
134+
needs: [build_windows_tests]
135+
strategy:
136+
matrix:
137+
rvc4os: ${{ fromJson(inputs.luxonis_os_versions_to_test) }}
138+
fail-fast: false
139+
runs-on: ['self-hosted', 'testbed-runner']
140+
steps:
141+
142+
- name: Run RVC4 tests
143+
run: |
144+
source scripts/hil/prepare_hil_framework.sh ${{ secrets.HIL_PAT_TOKEN }}
145+
export RESERVATION_NAME="https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID#rvc4-windows-${{ matrix.rvc4os }}"
146+
exec hil --models "oak4_pro or oak4_d" -os windows --reservation-name $RESERVATION_NAME --wait --rvc4-os-version ${{ matrix.rvc4os }} --commands "rmdir /S /Q depthai-core & git clone https://github.com/luxonis/depthai-core.git && cd depthai-core && git fetch origin ${{ github.sha }} && git checkout ${{ github.sha }} && scripts\hil\get_artifacts_and_run_tests.cmd \"${{ github.repository }}\" \"${{ github.token }}\" \"C:\depthai-core\" \"${{ needs.build_windows_tests.outputs.artifact_id }}\""

examples/cpp/cmake/ExecuteTestTimeout.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.2)
1+
cmake_minimum_required(VERSION 3.5)
22

33
# Parse out arguments
44
foreach(_arg RANGE ${CMAKE_ARGC})
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@echo off
2+
setlocal enabledelayedexpansion
3+
4+
REM Usage:
5+
REM get_artifacts_and_run_tests.cmd <repo> <gh_token> <dest> <artifact_id>
6+
7+
set "REPO=%~1"
8+
set "GH_TOKEN=%~2"
9+
set "DEST=%~3"
10+
set "ARTIFACT_ID=%~4"
11+
12+
if "%REPO%"=="" ( echo [!] REPO required & exit /b 2 )
13+
if "%GH_TOKEN%"=="" ( echo [!] GH_TOKEN required & exit /b 2 )
14+
if "%DEST%"=="" ( echo [!] DEST required & exit /b 2 )
15+
if "%ARTIFACT_ID%"=="" ( echo [!] ARTIFACT_ID required & exit /b 2 )
16+
17+
echo [*] REPO=%REPO%
18+
echo [*] DEST =%DEST%
19+
echo [*] ARTIFACT_ID=%ARTIFACT_ID%
20+
21+
echo [*] Recreating %DEST%
22+
rmdir /S /Q "%DEST%" 2>nul
23+
mkdir "%DEST%" || exit /b 1
24+
25+
26+
set "ZIP=%TEMP%\artifact_%ARTIFACT_ID%.zip"
27+
echo [*] Downloading artifact id=%ARTIFACT_ID%
28+
curl -sSL -H "Authorization: Bearer %GH_TOKEN%" -H "Accept: application/vnd.github+json" ^
29+
--retry 5 --retry-delay 2 --retry-all-errors ^
30+
-o "%ZIP%" "https://api.github.com/repos/%REPO%/actions/artifacts/%ARTIFACT_ID%/zip" || exit /b 1
31+
32+
echo [*] Extracting to %DEST%
33+
tar -xf "%ZIP%" -C "%DEST%"
34+
del /q "%ZIP%"
35+
36+
call venv\Scripts\activate.bat
37+
python -c "import sys; print(sys.executable)"
38+
39+
if exist "%DEST%\tests" (
40+
echo [*] Running tests from %DEST%\tests
41+
cd "%DEST%\tests"
42+
python run_tests.py --rvc4
43+
) else (
44+
echo [*] No tests directory at %DEST%\tests — skipping test phase.
45+
exit /b 1
46+
)

0 commit comments

Comments
 (0)