Skip to content

Commit 819728c

Browse files
[JS] Add a dependency on the openvino-node package (#1667)
CVS-161725 --------- Signed-off-by: Kirill Suvorov <kirill.suvorov@intel.com>
1 parent 3a8e054 commit 819728c

File tree

10 files changed

+1004
-142
lines changed

10 files changed

+1004
-142
lines changed

.github/workflows/linux.yml

+27-23
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
id: openvino_download
5252
with:
5353
platform: ubuntu22
54-
commit_packages_to_provide: wheels
54+
commit_packages_to_provide: wheels,openvino_js_package.tar.gz
5555
revision: latest_available_commit
5656

5757
- name: Clone docker tag from OpenVINO repo
@@ -420,8 +420,9 @@ jobs:
420420
env:
421421
CMAKE_GENERATOR: Unix Makefiles
422422
OV_INSTALL_DIR: ${{ github.workspace }}/ov
423+
SRC_DIR: ${{ github.workspace }}/openvino.genai
424+
INSTALL_DIR: ${{ github.workspace }}/openvino.genai/src/js/bin
423425
BUILD_DIR: ${{ github.workspace }}/build
424-
SRC_DIR: ${{ github.workspace }}/src
425426

426427
steps:
427428
- name: Clone openvino.genai
@@ -437,27 +438,19 @@ jobs:
437438
path: ${{ env.OV_INSTALL_DIR }}
438439
merge-multiple: true
439440

440-
- name: Build with ENABLE_JS=ON
441+
- name: Build GenAI Node.js bindings
441442
run: |
442443
source ${{ env.OV_INSTALL_DIR }}/setupvars.sh
443-
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DENABLE_JS=ON -S ${{ env.SRC_DIR }} -B ${{ env.BUILD_DIR }}
444+
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
445+
-DENABLE_JS=ON -DCPACK_GENERATOR=NPM \
446+
-DENABLE_PYTHON=OFF -DENABLE_WHEEL=OFF \
447+
-S ${{ env.SRC_DIR }} -B ${{ env.BUILD_DIR }}
444448
cmake --build ${{ env.BUILD_DIR }} --config ${{ matrix.build-type }} --parallel $(nproc) --verbose
445-
cmake --install ${{ env.BUILD_DIR }} --config ${{ matrix.build-type }} --prefix ${{ env.OV_INSTALL_DIR }}
446-
447-
- name: Combine binaries for Node.js package
448-
run: |
449-
mkdir -p nodejs
450-
cp -r runtime/lib/intel64/* nodejs
451-
cp -r runtime/3rdparty/tbb/lib/* nodejs
452-
cp genai_node_addon.node nodejs
453-
GENAI_VERSION=$(grep -oP '(?<=CMAKE_PROJECT_VERSION:STATIC=)[^"]*' ${{ env.BUILD_DIR }}/CMakeCache.txt)
454-
OV_VERSION=$(echo $GENAI_VERSION | sed 's/..$//')
455-
patchelf --set-rpath '$ORIGIN' nodejs/libopenvino.so.$OV_VERSION nodejs/libopenvino_genai.so.$GENAI_VERSION
456-
working-directory: ${{ env.OV_INSTALL_DIR }}
457-
449+
cmake --install ${{ env.BUILD_DIR }} --config ${{ matrix.build-type }} --prefix ${{ env.INSTALL_DIR }}
450+
458451
- name: Pack Node.js bindings libs
459452
run: tar -cvf - * | pigz > ${{ env.BUILD_DIR }}/genai_nodejs_bindings.tar.gz
460-
working-directory: ${{ env.OV_INSTALL_DIR }}/nodejs
453+
working-directory: ${{ env.INSTALL_DIR }}
461454

462455
- name: Upload Archive Package with Node.js bindings
463456
if: ${{ always() }}
@@ -467,16 +460,27 @@ jobs:
467460
path: ${{ env.BUILD_DIR }}/genai_nodejs_bindings.tar.gz
468461
if-no-files-found: 'error'
469462

470-
- name: Run npm package tests
463+
# JS pacakges uses the OpenVINO and OpenVINO GenAI libraries from the bin directory.
464+
# Here we emulate the installation of the openvino-node package from NPM. The latest
465+
# release of the openvino-node package is installed, and we need to update the binaries
466+
# in the node_modules/openvino-node/bin directory to work correctly with GenAI
467+
- name: Install npm package tests dependencies
471468
working-directory: ${{ env.SRC_DIR }}/src/js
472469
run: |
473-
cp -R ${{ env.OV_INSTALL_DIR }}/nodejs bin
474-
npm install
475-
npm test
470+
npm install --verbose
471+
rm -rf node_modules/openvino-node/bin
472+
cp -R ${{ env.OV_INSTALL_DIR }}/openvino_js_package node_modules/openvino-node/bin
473+
474+
- name: Run npm package tests
475+
working-directory: ${{ env.SRC_DIR }}/src/js
476+
run: npm test
476477

477478
- name: Install genai-node samples dependencies
478-
run: npm install
479479
working-directory: ${{ env.SRC_DIR }}/samples/js/text_generation
480+
run: |
481+
npm install --verbose
482+
rm -rf node_modules/openvino-node/bin
483+
cp -R ${{ env.OV_INSTALL_DIR }}/openvino_js_package node_modules/openvino-node/bin
480484
481485
- name: Run samples tests
482486
run: npm test

0 commit comments

Comments
 (0)