OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[CI] [GHA] Build Samples in the `Build` jobs, and add them to the `openvino_package` (#37221)
Andrei Kashchikhinc02097d98eda
diff --git a/.github/workflows/dev_gpu_linux_level_zero.yml b/.github/workflows/dev_gpu_linux_level_zero.ymlindex 4187bad8e70..6b83b1ae792 100644--- a/.github/workflows/dev_gpu_linux_level_zero.yml+++ b/.github/workflows/dev_gpu_linux_level_zero.yml@@ -105,6 +105,7 @@ jobs:build-additional-python-packages: truebuild-variant: 'levelzero'store_artifacts: false+ build-samples: truetarget-branch: ${{ inputs.target-branch }}cmake-options: >--G 'Ninja Multi-Config'diff --git a/.github/workflows/job_build_linux.yml b/.github/workflows/job_build_linux.ymlindex adbb18dec0d..34367ff2c27 100644--- a/.github/workflows/job_build_linux.yml+++ b/.github/workflows/job_build_linux.yml@@ -85,6 +85,11 @@ on:type: booleanrequired: falsedefault: true+ build-samples:+ description: 'Whether to build OpenVINO C++/C samples and include them in the OpenVINO package'+ type: boolean+ required: false+ default: falsepermissions: read-all@@ -232,7 +237,7 @@ jobs:- name: CMake configure - OpenVINOrun: eval cmake ${{ env.CMAKE_OPTIONS }} -S ${{ env.OPENVINO_REPO }} -B ${{ env. BUILD_DIR }}env:- CMAKE_OPTIONS: ${{ inputs.cmake-options }}+ CMAKE_OPTIONS: ${{ inputs.cmake-options }} -DENABLE_SAMPLES=${{ inputs.build-samples && 'ON' || 'OFF' }}- name: Clean sccache statsrun: ${SCCACHE_PATH} --zero-stats@@ -249,6 +254,11 @@ jobs:cmake --install ${BUILD_DIR} --config ${{ env.CMAKE_BUILD_TYPE }} --prefix ${INSTALL_TEST_DIR} --component testscmake --install ${BUILD_DIR} --config ${{ env.CMAKE_BUILD_TYPE }} --prefix ${DEVELOPER_PACKAGE_DIR} --component developer_package+ # Samples are built by the main build (ENABLE_SAMPLES=ON); install their binaries into the package+ - name: Install OpenVINO samples+ if: ${{ inputs.build-samples }}+ run: cmake --install ${BUILD_DIR} --config ${{ env.CMAKE_BUILD_TYPE }} --prefix ${INSTALL_DIR} --component samples_bin+- name: Install Python wheels for the main Pythonif: ${{ ! inputs.build-additional-python-packages }}run: cmake --install ${BUILD_DIR} --config ${{ env.CMAKE_BUILD_TYPE }} --prefix ${INSTALL_WHEELS_DIR} --component python_wheelsdiff --git a/.github/workflows/job_build_windows.yml b/.github/workflows/job_build_windows.ymlindex c569683d20f..8c7c6111deb 100644--- a/.github/workflows/job_build_windows.yml+++ b/.github/workflows/job_build_windows.yml@@ -31,6 +31,11 @@ on:type: stringrequired: falsedefault: 'vs2022'+ build-samples:+ description: 'Whether to build OpenVINO C++/C samples and include them in the OpenVINO package'+ type: boolean+ required: false+ default: falsepermissions: read-all@@ -137,7 +142,7 @@ jobs:# python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/paddle/tests/requirements.txt# For getting rid of SSL issues during model downloading for unit tests- python3 -m pip install certifi+ python3 -m pip install certifi==2026.7.22 packaging==26.3## Build@@ -172,7 +177,7 @@ jobs:- name: CMake configureenv:- CMAKE_OPTIONS: ${{ inputs.cmake-options }}+ CMAKE_OPTIONS: ${{ inputs.cmake-options }} -DENABLE_SAMPLES=${{ inputs.build-samples && 'ON' || 'OFF' }}run: |$cmakeOptions = "$env:CMAKE_OPTIONS"$splitCmakeOptions = $cmakeOptions.Split(" ")@@ -197,6 +202,11 @@ jobs:cmake --install ${{ env.BUILD_DIR }} --config ${{ env.CMAKE_BUILD_TYPE }} --prefix ${{ env.INSTALL_PDB_DIR }} --component pdbcmake --install ${{ env.BUILD_DIR }} --config ${{ env.CMAKE_BUILD_TYPE }} --prefix ${{ env.INSTALL_DEV_PACKAGE }} --component developer_package+ # Samples are built by the main build (ENABLE_SAMPLES=ON); install their binaries into the package+ - name: Install OpenVINO samples+ if: ${{ inputs.build-samples }}+ run: cmake --install ${{ env.BUILD_DIR }} --config ${{ env.CMAKE_BUILD_TYPE }} --prefix ${{ env.INSTALL_DIR }} --component samples_bin+# Setup additional Python versions for wheels building- name: Setup Python 3.10if: ${{ inputs.build-additional-python-wheels }}diff --git a/.github/workflows/job_gpu_tests.yml b/.github/workflows/job_gpu_tests.ymlindex 62a80f866dc..e3755d03fb7 100644--- a/.github/workflows/job_gpu_tests.yml+++ b/.github/workflows/job_gpu_tests.yml@@ -91,10 +91,7 @@ jobs:# Samples#- - name: Build cpp samples- if: ${{ inputs.test_type == 'unit' }}- run: $INSTALL_DIR/samples/cpp/build_samples.sh -i $INSTALL_DIR -b $BUILD_DIR/cpp_samples-+ # Samples are built in the Build job and reused from openvino_package# git uses the system CA bundle, so add the proxy root CA (mounted at# /usr/local/share/ca-certificates) to it before cloning over HTTPS,# otherwise git fails with "server certificate verification failed".diff --git a/.github/workflows/job_samples_tests.yml b/.github/workflows/job_samples_tests.ymlindex b175ddb81ae..49b4fda6a3d 100644--- a/.github/workflows/job_samples_tests.yml+++ b/.github/workflows/job_samples_tests.yml@@ -99,19 +99,15 @@ jobs:with:toolset: 14.42 # v2022- - name: Build cpp samples- run: $INSTALL_DIR/samples/cpp/build_samples.sh -i $INSTALL_DIR -b $BUILD_DIR/cpp_samples-+ # C++/C samples are built in the Build job and reused from openvino_package.+ # This step only validates that the C++ samples still compile with Clang- name: Build cpp samples - Clangif: runner.os == 'Linux'- run: $INSTALL_DIR/samples/cpp/build_samples.sh -i $INSTALL_DIR -b $BUILD_DIR/cpp_samples_clang+ run: $INSTALL_DIR/samples/cpp/build_samples.sh -b $BUILD_DIR/cpp_samples_clangenv:CC: clangCXX: clang++- - name: Build c samples- run: $INSTALL_DIR/samples/c/build_samples.sh -i $INSTALL_DIR -b $BUILD_DIR/c_samples-## Tests#diff --git a/.github/workflows/linux_arm64.yml b/.github/workflows/linux_arm64.ymlindex c1f7f85a1db..0f35846032b 100644--- a/.github/workflows/linux_arm64.yml+++ b/.github/workflows/linux_arm64.yml@@ -109,6 +109,7 @@ jobs:build-debian-packages: falsebuild-rpm-packages: falsebuild-additional-python-packages: true+ build-samples: truetarget-branch: ${{ inputs.target-branch }}cmake-options: >--G 'Ninja Multi-Config'diff --git a/.github/workflows/mac_arm64.yml b/.github/workflows/mac_arm64.ymlindex ef1cd1dc7ac..4dd41f53a68 100644--- a/.github/workflows/mac_arm64.yml+++ b/.github/workflows/mac_arm64.yml@@ -218,6 +218,10 @@ jobs:run: tar -cvf - * | pigz > ${{ env.BUILD_DIR }}/developer_package.tar.gzworking-directory: ${{ env.DEVELOPER_PACKAGE_DIR }}/developer_package+ # Samples are built by the main build (ENABLE_SAMPLES=ON); install their binaries into the package+ - name: Install OpenVINO samples+ run: cmake -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCOMPONENT=samples_bin -P ${{ env.BUILD_DIR }}/cmake_install.cmake+- name: Pack Artifactsrun: |pushd ${{ env.INSTALL_DIR }}diff --git a/.github/workflows/ubuntu_22.yml b/.github/workflows/ubuntu_22.ymlindex fe67b90f408..263cb6c96d8 100644--- a/.github/workflows/ubuntu_22.yml+++ b/.github/workflows/ubuntu_22.yml@@ -131,6 +131,7 @@ jobs:build-debian-packages: truebuild-rpm-packages: falsebuild-additional-python-packages: true+ build-samples: truetarget-branch: ${{ inputs.target-branch }}cmake-options: >--G 'Ninja Multi-Config'diff --git a/.github/workflows/ubuntu_24.yml b/.github/workflows/ubuntu_24.ymlindex acc4ec98e47..7d0d36fc8d0 100644--- a/.github/workflows/ubuntu_24.yml+++ b/.github/workflows/ubuntu_24.yml@@ -109,6 +109,7 @@ jobs:build-debian-packages: truebuild-contrib: truebuild-additional-python-packages: true+ build-samples: truetarget-branch: ${{ inputs.target-branch }}cmake-options: >--G 'Ninja Multi-Config'diff --git a/.github/workflows/windows_vs2022_release.yml b/.github/workflows/windows_vs2022_release.ymlindex d7af3413161..59338851335 100644--- a/.github/workflows/windows_vs2022_release.yml+++ b/.github/workflows/windows_vs2022_release.yml@@ -71,6 +71,7 @@ jobs:build-type: 'Release'target-branch: ${{ needs.smart_ci.outputs.target_branch }}build-additional-python-wheels: true+ build-samples: truecmake-options: >--G 'Ninja Multi-Config'-DENABLE_PYTHON=ON@@ -143,16 +144,6 @@ jobs:self-hosted-runner: 'true'use-pip-proxy: 'true'- # Test with the short names of the arguments- - name: Build cpp samples- run: |- & ${{ env.SAMPLES_INSTALL_DIR }}/cpp/build_samples.ps1 -i ${{ env.INSTALL_DIR }} -b ${{ env.BUILD_DIR }}/cpp_samples-- # Test with the full names of the arguments- - name: Build c samples- run: |- & ${{ env.SAMPLES_INSTALL_DIR }}/c/build_samples.ps1 -InstallDirectory ${{ env.INSTALL_DIR }} -BuildDirectory ${{ env.BUILD_DIR }}/c_samples-# Install Python benchmark_app by installing openvino-*.whl- name: Install OpenVINO Python wheelsuses: ./openvino/.github/actions/install_ov_wheelsdiff --git a/samples/cpp/common/utils/CMakeLists.txt b/samples/cpp/common/utils/CMakeLists.txtindex d4bca2d6c5b..eefb9ffd555 100644--- a/samples/cpp/common/utils/CMakeLists.txt+++ b/samples/cpp/common/utils/CMakeLists.txt@@ -7,7 +7,7 @@ set(TARGET_NAME "ie_samples_utils")file(GLOB_RECURSE SOURCES "*.cpp" "*.hpp" "*.h")source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES})-add_library(${TARGET_NAME} STATIC EXCLUDE_FROM_ALL ${SOURCES})+add_library(${TARGET_NAME} STATIC ${SOURCES})set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "src")target_include_directories(${TARGET_NAME}