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
[GHA] Add openvino-provider action (#26050)
Alina Kladievaf4c3f8880875
diff --git a/.github/actions/openvino_provider/action.yml b/.github/actions/openvino_provider/action.ymlnew file mode 100644index 00000000000..cb6cb7859b8--- /dev/null+++ b/.github/actions/openvino_provider/action.yml@@ -0,0 +1,157 @@+name: 'OpenVINO provider'+description: 'Provides OpenVINO build artifacts from a requested source'+inputs:+ revision:+ description: 'Version of OpenVINO to provide - latest_available | HEAD | specific commit hash'+ required: true+ branch_name:+ description: 'Branch of OpenVINO to take the revision from if no specific hash was provided.+ Taken from github context by default'+ required: false+ ov_artifact_name:+ description: "Name under which to upload provided OpenVINO build artifacts, set automatically by default"+ required: false+ commit_packages_to_provide:+ description: "Comma-separated list of OpenVINO packages from post-commit to provide ('all' to get everything)"+ required: false+ commit_build_key:+ description: 'public_linux_ubuntu_20_04_release | public_linux_ubuntu_22_04_release |+ public_linux_ubuntu_24_04_release | public_windows_vs2019_release'+ required: false+ commit_share_path:+ description: 'Path to share holding OpenVINO post-commit artifacts'+ required: false+ default: '/mount/build-artifacts'+ nightly_build_key:+ description: 'centos7_x86_64 | debian9_armhf | rhel8_x86_64 | ubuntu20_arm64 | ubuntu20_x86_64 | ubuntu22_x86_64 |+ ubuntu24_x86_64 | macos_12_6_arm64 | macos_12_6_x86_64 | windows_x86_64'+ required: false+ nightly_package_source:+ description: 'Source URL hosting OpenVINO nightly archives'+ required: false+ default: 'https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/latest.json'+ nightly_pip_extra_url:+ description: 'Source URL hosting OpenVINO nightly wheels, for passing to pip as --extra-index-url'+ required: false+ default: 'https://storage.openvinotoolkit.org/simple/wheels/nightly'+outputs:+ ov_artifact_name:+ description: "Name of the artifact to upload OpenVINO build artifacts under"+ value: ${{ steps.openvino_nightly_download.outputs.ov_artifact_name || steps.openvino_commit_output.outputs.ov_artifact_name }}+ ov_package_path:+ description: "Path to OpenVINO core package relative to the root of uploaded artifacts"+ value: ${{ steps.openvino_nightly_download.outputs.ov_package_path || steps.openvino_commit_output.outputs.ov_package_path }}+ ov_wheel_input:+ description: "Input for pip to install OpenVINO python wheel"+ value: ${{ steps.openvino_nightly_wheel.outputs.ov_wheel_input || steps.openvino_commit_wheel.outputs.ov_wheel_input }}++runs:+ using: "composite"+ steps:+ - name: Verify parameters+ if: ${{ !inputs.nightly_build_key && !inputs.commit_build_key || inputs.nightly_build_key && inputs.commit_build_key }}+ shell: bash+ run: |+ echo "Please, set one parameter for action - nightly_build_key or commit_build_key"+ exit 1++ - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7+ with:+ sparse-checkout: .github/actions++ # --- Post-commit case ---+ - name: Clone OpenVINO to get HEAD commit+ if: inputs.revision == 'HEAD'+ uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7+ with:+ repository: 'openvinotoolkit/openvino'+ path: 'openvino'+ ref: ${{ inputs.branch_name }}++ - name: Get OpenVINO HEAD commit+ id: get_openvino_head_commit+ if: inputs.revision == 'HEAD'+ shell: bash+ run: |+ head=$(git -C openvino rev-parse HEAD)+ echo "head=$head" >> $GITHUB_OUTPUT++ - name: Download post-commit OpenVINO archives+ id: openvino_commit_download+ if: inputs.commit_build_key+ uses: ./.github/actions/restore_artifacts+ with:+ storage_dir: ${{ inputs.commit_build_key }}+ storage_root: ${{ inputs.commit_share_path }}+ event_name: "commit"+ trigger_repo_sha: ${{ env.OV_REVISION }}+ branch_name: ${{ inputs.branch_name }}+ artifacts_key: ${{ inputs.ov_artifact_name || inputs.commit_build_key }}+ to_restore: ${{ inputs.commit_packages_to_provide }}+ env:+ OV_REVISION: ${{ inputs.revision == 'HEAD' && steps.get_openvino_head_commit.outputs.head || inputs.revision }}++ - name: Set action outputs+ id: openvino_commit_output+ if: steps.openvino_commit_download.outcome == 'success'+ shell: bash+ run: |+ ov_artifact_name=${{ inputs.ov_artifact_name || steps.openvino_commit_download.outputs.restored_artifacts_key }}+ cd ${{ steps.openvino_commit_download.outputs.artifacts_workspace_path }}+ ov_package_path=$(find . -name 'openvino_package*' -printf "%P\n" -quit)+ [ -z "$ov_package_path" ] && echo "No openvino_package found in restored artifacts" && exit 1+ echo "ov_artifact_name=$ov_artifact_name" >> $GITHUB_OUTPUT+ echo "ov_package_path=$ov_package_path" >> $GITHUB_OUTPUT++ - name: Get commit wheel+ id: openvino_commit_wheel+ if: steps.openvino_commit_download.outcome == 'success'+ shell: bash+ run: |+ cd ${{ steps.openvino_commit_download.outputs.artifacts_workspace_path }}+ version=$(yq eval '.components.dldt.custom_params.wheel_product_version' manifest.yml)+ wheel_path=${{ steps.openvino_commit_output.outputs.ov_package_path }}/tools+ find_links_cmd=$([[ -n "$PIP_FIND_LINKS" ]] && echo "" || echo "--find-links=./$wheel_path")+ wheel_input="$find_links_cmd openvino==$version"+ echo "ov_wheel_input=$wheel_input" >> $GITHUB_OUTPUT+++ # --- Nightly case ---+ - name: Verify nightly parameters+ if: inputs.nightly_build_key && inputs.revision != 'latest_available'+ shell: bash+ run: |+ echo "Nightly build source provides only 'latest' artifacts, specific revision not yet supported"+ exit 1++ - name: Download nightly OpenVINO archives+ id: openvino_nightly_download+ if: inputs.nightly_build_key+ shell: bash+ run: |+ ov_package_url=$(curl -s ${{ inputs.nightly_package_source }} | jq -r '.${{ inputs.nightly_build_key }}')+ package_basename=$(basename $ov_package_url)+ wget $ov_package_url --progress=bar:force:noscroll -O $package_basename+ package_folder=${package_basename%.*} && mkdir $package_folder+ [[ "$package_basename" == *.zip ]] && unzip "$package_basename" -d $package_folder || tar -xvf "$package_basename" -C $package_folder+ ov_artifact_name=$([ ${{ inputs.ov_artifact_name }} ] && echo ${{ inputs.ov_artifact_name }} || echo $package_folder)+ echo "ov_artifact_name=$ov_artifact_name" >> $GITHUB_OUTPUT+ echo "ov_package_path=$package_folder" >> $GITHUB_OUTPUT++ - name: Upload nightly OpenVINO archives+ if: steps.openvino_nightly_download.outcome == 'success'+ uses: actions/upload-artifact@v4+ with:+ name: ${{ steps.openvino_nightly_download.outputs.ov_artifact_name }}+ path: ${{ steps.openvino_nightly_download.outputs.ov_package_path }}+ if-no-files-found: 'error'++ - name: Get nightly wheel+ id: openvino_nightly_wheel+ if: steps.openvino_nightly_download.outcome == 'success'+ shell: bash+ run: |+ version=$(echo ${{ steps.openvino_nightly_download.outputs.ov_package_path }} |+ grep -oP '(?<=_)\d{4}\.\d\.\d\.dev\d{8}(?=_)')+ wheel_input="--pre --extra-index-url ${{ inputs.nightly_pip_extra_url }} openvino==$version"+ echo "ov_wheel_input=$wheel_input" >> $GITHUB_OUTPUTdiff --git a/.github/actions/restore_artifacts/action.yml b/.github/actions/restore_artifacts/action.ymlindex bfae333c230..f86bd006086 100644--- a/.github/actions/restore_artifacts/action.yml+++ b/.github/actions/restore_artifacts/action.yml@@ -19,12 +19,19 @@ inputs:artifacts_key:description: "A key under which to upload the artifacts to storage, product type by default"required: false+ to_restore:+ description: "Comma-separated list of packages to restore, all available by default"+ required: false+ unpack_archives:+ description: "Whether to unpack all artifact archives once retrieved"+ required: false+ default: 'true'outputs:- artifacts_storage_path:- description: "Path on a shared drive where the artifacts are stored"- value: ${{ steps.restore.outputs.artifacts_storage_path }}+ artifacts_workspace_path:+ description: "Path within the workspace where the artifacts are stored"+ value: ${{ steps.restore.outputs.artifacts_workspace_path }}restored_artifacts_key:description: "Key under which the restored artifacts, if any, were uploaded to GitHub"value: ${{ steps.restore.outputs.restored_artifacts_key }}@@ -41,13 +48,16 @@ runs:-t "${{ env.GITHUB_WORKSPACE }}/${{ inputs.storage_dir }}"--storage_dir "${{ inputs.storage_dir }}" --storage_root "${{ inputs.storage_root }}"-s "${{ inputs.trigger_repo_sha || github.event.pull_request.head.sha || github.sha }}"+ ${{ inputs.unpack_archives == 'true' && '--unpack_archives' || '' }}${{ inputs.branch_name && env.BRANCH_PARAM || '' }}${{ inputs.event_name && env.EVENT_PARAM || '' }}+ ${{ inputs.to_restore && env.TO_RESTORE || '' }}env:ACTION_PATH: ${{ runner.os == 'Windows' && '$env:GITHUB_ACTION_PATH' || '$GITHUB_ACTION_PATH' }}GITHUB_WORKSPACE: ${{ runner.os == 'Windows' && '$env:GITHUB_WORKSPACE' || '$GITHUB_WORKSPACE' }}BRANCH_PARAM: "-b ${{ inputs.branch_name }}"EVENT_PARAM: "-e ${{ inputs.event_name }}"+ TO_RESTORE: "-r ${{ inputs.to_restore }}"- name: Upload artifactsif: "!inputs.artifacts"diff --git a/.github/actions/restore_artifacts/restore_artifacts.py b/.github/actions/restore_artifacts/restore_artifacts.pyindex 4e753c71ce0..8a780ce1744 100644--- a/.github/actions/restore_artifacts/restore_artifacts.py+++ b/.github/actions/restore_artifacts/restore_artifacts.py@@ -5,9 +5,12 @@ from __future__ import annotationsimport argparseimport logging+import osimport shutilimport sys-from pathlib import Path+import tarfile+import zipfile+from pathlib import Path, PureWindowsPathsys.path.append(str(Path(__file__).parents[1]))from common import artifact_utils, action_utils@@ -21,19 +24,37 @@ def parse_args():parser.add_argument('-k', '--artifact_key', type=str,help='A key under which to upload the artifacts to storage, product type by default',required=False)+ parser.add_argument('-r', '--to_restore', type=str, required=False,+ help='Comma-separated list of packages to restore, all available by default')+ parser.add_argument('-u', '--unpack_archives', action='store_true', required=False,+ help='Whether to unpack all artifact archives once retrieved')args = parser.parse_args()return args+def include_filter(include_list: set | list):+ """+ Returns input for shutil.copytree ignore - to copy only files from include list+ """+ def _filter(_, files: list):+ if not include_list:+ return []+ return [f for f in files if f not in include_list]++ return _filter++def main():action_utils.init_logger()logger = logging.getLogger(__name__)args = parse_args()- if args.commit_sha == 'latest':+ if args.commit_sha == 'latest_available':latest_artifacts_link = artifact_utils.get_latest_artifacts_link(args.storage_dir, args.storage_root,args.branch_name, args.event_name)- storage = Path(args.storage_root) / latest_artifacts_link.read_text()+ latest_artifacts_path = PureWindowsPath(latest_artifacts_link.read_text())+ normalized_path = latest_artifacts_path.as_posix() if os.name == 'posix' else latest_artifacts_path+ storage = Path(args.storage_root) / normalized_pathelse:storage = artifact_utils.get_storage_dir(args.storage_dir, args.commit_sha, args.storage_root, args.branch_name,args.event_name)@@ -41,9 +62,26 @@ def main():action_utils.set_github_output("artifacts_storage_path", str(storage))logger.info(f"Artifacts are taken from here: {storage}")- shutil.copytree(storage, args.target_dir, dirs_exist_ok=True)+ main_package_extension = 'zip' if 'windows' in args.storage_dir else 'tar.gz'+ main_package_name = f'openvino_package.{main_package_extension}'+ defaults = [main_package_name, 'manifest.yml']+ to_restore = set(args.to_restore.split(',')).union(defaults) if args.to_restore else defaults+ if args.to_restore == 'all':+ to_restore = None+ shutil.copytree(storage, args.target_dir, dirs_exist_ok=True,+ ignore=include_filter(to_restore))logger.info(f"Artifacts are copied here: {args.target_dir}")+ if args.unpack_archives:+ for file in Path(args.target_dir).iterdir():+ logger.info(f"file: {file}")+ if not file.is_file() or file.is_file() and not (tarfile.is_tarfile(file) or zipfile.is_zipfile(file)):+ continue+ output_dir = Path(args.target_dir) / Path(str(file).removesuffix('.tar.gz')).stem+ logger.info(f"Unpacking: {file} to {output_dir}")+ shutil.unpack_archive(file, output_dir)+ file.unlink()+action_utils.set_github_output("artifacts_workspace_path", args.target_dir)action_utils.set_github_output("restored_artifacts_key", args.artifact_key or args.storage_dir)