From 5b29d34e16d853cf8f9c6777211e1e935846d988 Mon Sep 17 00:00:00 2001 From: ewfian Date: Sat, 30 Sep 2023 22:22:32 +0900 Subject: [PATCH 1/7] fix #44 --- .github/workflows/test_install_import_docker.yml | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_install_import_docker.yml b/.github/workflows/test_install_import_docker.yml index 69507ec..7b39f2e 100644 --- a/.github/workflows/test_install_import_docker.yml +++ b/.github/workflows/test_install_import_docker.yml @@ -33,10 +33,10 @@ jobs: distro: '-alpine', arch: 'linux/arm64' }, - # { - # distro: '-alpine', - # arch: 'linux/arm/v7' - # } + { + distro: '-alpine', + arch: 'linux/arm/v7' + } ] runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index e584956..11093b2 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "build:clean": "cmake-js clean", "build:test": "npm run build && npm run test", "prebuild-package": "prebuild --verbose --runtime napi --include-regex \"^(faiss-node\\.node)|(mkl_sequential\\.2\\.dll)|(faiss\\.lib)|(libfaiss\\.a)|(libmkl_intel_lp64\\.so)|(libmkl_sequential\\.so)|(libmkl_core\\.so)|(libomp\\.dylib)|(libgomp\\.so\\.1)|(libopenblas\\.so\\.3)|(libopenblas\\.so\\.0)|(libgfortran\\.so\\.5)|(libquadmath\\.so\\.0)$\" --backend cmake-js", - "install": "prebuild-install --runtime napi --verbose || (npm i cmake-js && npm run build)", + "install": "prebuild-install --runtime napi --verbose || (git clone -b v1.7.4 --depth 1 https://github.com/facebookresearch/faiss.git deps/faiss && npm i cmake-js && npm run build)", "test": "jest", "doc": "typedoc --includeVersion" }, From 0fb2a78df548187bb4d4efdf521c00d049b423a5 Mon Sep 17 00:00:00 2001 From: ewfian Date: Sat, 30 Sep 2023 22:53:29 +0900 Subject: [PATCH 2/7] fix ci --- test-import/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-import/Dockerfile b/test-import/Dockerfile index aab6cdd..f11df0a 100644 --- a/test-import/Dockerfile +++ b/test-import/Dockerfile @@ -10,7 +10,7 @@ COPY faiss-node.tgz ./ RUN set -eux; \ if [ $TARGETPLATFORM == "linux/arm/v7" ]; then \ - apk add cmake build-base openblas-dev; \ + apk add git cmake build-base openblas-dev; \ fi RUN npm install ./faiss-node.tgz --verbose From 70c84f9abdd3adf610ca830ab7939df2d7a1715d Mon Sep 17 00:00:00 2001 From: ewfian Date: Mon, 2 Oct 2023 15:41:14 +0900 Subject: [PATCH 3/7] update test --- .../workflows/test_install_import_docker.yml | 8 ++--- ...install_import_docker_without_prebuild.yml | 29 +++++++++++++++++++ test-import/Dockerfile | 17 ++++++----- test-import/Dockerfile.withoutprebuild | 22 ++++++++++++++ 4 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/test_install_import_docker_without_prebuild.yml create mode 100644 test-import/Dockerfile.withoutprebuild diff --git a/.github/workflows/test_install_import_docker.yml b/.github/workflows/test_install_import_docker.yml index 7b39f2e..69507ec 100644 --- a/.github/workflows/test_install_import_docker.yml +++ b/.github/workflows/test_install_import_docker.yml @@ -33,10 +33,10 @@ jobs: distro: '-alpine', arch: 'linux/arm64' }, - { - distro: '-alpine', - arch: 'linux/arm/v7' - } + # { + # distro: '-alpine', + # arch: 'linux/arm/v7' + # } ] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test_install_import_docker_without_prebuild.yml b/.github/workflows/test_install_import_docker_without_prebuild.yml new file mode 100644 index 0000000..6b5bccc --- /dev/null +++ b/.github/workflows/test_install_import_docker_without_prebuild.yml @@ -0,0 +1,29 @@ +name: Test Install & Import without Pre-build Binary + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Node.js 18 + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Bump version to simulate a non-existed pre-build + run: npm version prerelease --preid=test --no-commit-hooks --no-git-tag-version + - name: NPM Pack + run: npm pack + - name: Rename Package + run: mv faiss-node-*.tgz test-import/faiss-node.tgz + - name: Build docker on Ubuntu + working-directory: ./test-import + run: docker build -f Dockerfile.withoutprebuild -t test-import . + - name: Run test + working-directory: ./test-import + run: docker run test-import diff --git a/test-import/Dockerfile b/test-import/Dockerfile index f11df0a..a01e6ca 100644 --- a/test-import/Dockerfile +++ b/test-import/Dockerfile @@ -1,5 +1,4 @@ -ARG BASE_IMAGE=node:18-alpine -FROM $BASE_IMAGE +FROM ubuntu:22.04 ARG TARGETPLATFORM ARG BUILDPLATFORM RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM"; @@ -8,12 +7,16 @@ WORKDIR /app COPY package.json ./ COPY faiss-node.tgz ./ -RUN set -eux; \ - if [ $TARGETPLATFORM == "linux/arm/v7" ]; then \ - apk add git cmake build-base openblas-dev; \ - fi +RUN apt update && \ + apt install -y ca-certificates curl gnupg && \ + mkdir -p /etc/apt/keyrings && \ + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ + echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ + curl -fsSL https://apt.kitware.com/keys/kitware-archive-latest.asc | gpg --dearmor -o /etc/apt/keyrings/kitware-archive-keyring.gpg && \ + echo 'deb [signed-by=/etc/apt/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | tee /etc/apt/sources.list.d/kitware.list && \ + apt update && apt install -y nodejs cmake git build-essential libopenblas-dev patchelf -RUN npm install ./faiss-node.tgz --verbose +RUN npm install ./faiss-node.tgz --foreground-scripts COPY . . CMD [ "node", "index.js" ] \ No newline at end of file diff --git a/test-import/Dockerfile.withoutprebuild b/test-import/Dockerfile.withoutprebuild new file mode 100644 index 0000000..a01e6ca --- /dev/null +++ b/test-import/Dockerfile.withoutprebuild @@ -0,0 +1,22 @@ +FROM ubuntu:22.04 +ARG TARGETPLATFORM +ARG BUILDPLATFORM +RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM"; + +WORKDIR /app +COPY package.json ./ +COPY faiss-node.tgz ./ + +RUN apt update && \ + apt install -y ca-certificates curl gnupg && \ + mkdir -p /etc/apt/keyrings && \ + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ + echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ + curl -fsSL https://apt.kitware.com/keys/kitware-archive-latest.asc | gpg --dearmor -o /etc/apt/keyrings/kitware-archive-keyring.gpg && \ + echo 'deb [signed-by=/etc/apt/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | tee /etc/apt/sources.list.d/kitware.list && \ + apt update && apt install -y nodejs cmake git build-essential libopenblas-dev patchelf + +RUN npm install ./faiss-node.tgz --foreground-scripts +COPY . . + +CMD [ "node", "index.js" ] \ No newline at end of file From 74cde6a9a4238e2b6549f3c5612b2e107679d975 Mon Sep 17 00:00:00 2001 From: ewfian Date: Mon, 2 Oct 2023 15:46:42 +0900 Subject: [PATCH 4/7] revert Dockerfile --- test-import/Dockerfile | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/test-import/Dockerfile b/test-import/Dockerfile index a01e6ca..95227fb 100644 --- a/test-import/Dockerfile +++ b/test-import/Dockerfile @@ -1,4 +1,5 @@ -FROM ubuntu:22.04 +ARG BASE_IMAGE=node:18-alpine +FROM $BASE_IMAGE ARG TARGETPLATFORM ARG BUILDPLATFORM RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM"; @@ -7,14 +8,10 @@ WORKDIR /app COPY package.json ./ COPY faiss-node.tgz ./ -RUN apt update && \ - apt install -y ca-certificates curl gnupg && \ - mkdir -p /etc/apt/keyrings && \ - curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ - echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ - curl -fsSL https://apt.kitware.com/keys/kitware-archive-latest.asc | gpg --dearmor -o /etc/apt/keyrings/kitware-archive-keyring.gpg && \ - echo 'deb [signed-by=/etc/apt/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | tee /etc/apt/sources.list.d/kitware.list && \ - apt update && apt install -y nodejs cmake git build-essential libopenblas-dev patchelf +RUN set -eux; \ + if [ $TARGETPLATFORM == "linux/arm/v7" ]; then \ + apk add cmake build-base openblas-dev; \ + fi RUN npm install ./faiss-node.tgz --foreground-scripts COPY . . From e46c609edc89e94c7aa4a92813946e726d6e29b1 Mon Sep 17 00:00:00 2001 From: ewfian Date: Mon, 2 Oct 2023 16:01:16 +0900 Subject: [PATCH 5/7] fix detailed logs on install hook --- .github/workflows/test_install_import.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_install_import.yml b/.github/workflows/test_install_import.yml index 98e4712..0012b62 100644 --- a/.github/workflows/test_install_import.yml +++ b/.github/workflows/test_install_import.yml @@ -26,7 +26,7 @@ jobs: run: mv faiss-node-*.tgz faiss-node.tgz - name: NPM Install working-directory: ./test-import - run: npm install ../faiss-node.tgz --verbose + run: npm install ../faiss-node.tgz --foreground-scripts - name: Test working-directory: ./test-import run: npm test From 042b98259d8603310ea903489e78bffd0c25a3cc Mon Sep 17 00:00:00 2001 From: ewfian Date: Mon, 2 Oct 2023 16:07:41 +0900 Subject: [PATCH 6/7] remove useless code --- .github/workflows/test_install_import_docker.yml | 6 +----- test-import/Dockerfile | 5 ----- test-import/Dockerfile.withoutprebuild | 3 --- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/test_install_import_docker.yml b/.github/workflows/test_install_import_docker.yml index 69507ec..bf2455a 100644 --- a/.github/workflows/test_install_import_docker.yml +++ b/.github/workflows/test_install_import_docker.yml @@ -32,11 +32,7 @@ jobs: { distro: '-alpine', arch: 'linux/arm64' - }, - # { - # distro: '-alpine', - # arch: 'linux/arm/v7' - # } + } ] runs-on: ubuntu-latest steps: diff --git a/test-import/Dockerfile b/test-import/Dockerfile index 95227fb..9e1e518 100644 --- a/test-import/Dockerfile +++ b/test-import/Dockerfile @@ -8,11 +8,6 @@ WORKDIR /app COPY package.json ./ COPY faiss-node.tgz ./ -RUN set -eux; \ - if [ $TARGETPLATFORM == "linux/arm/v7" ]; then \ - apk add cmake build-base openblas-dev; \ - fi - RUN npm install ./faiss-node.tgz --foreground-scripts COPY . . diff --git a/test-import/Dockerfile.withoutprebuild b/test-import/Dockerfile.withoutprebuild index a01e6ca..6d74935 100644 --- a/test-import/Dockerfile.withoutprebuild +++ b/test-import/Dockerfile.withoutprebuild @@ -1,7 +1,4 @@ FROM ubuntu:22.04 -ARG TARGETPLATFORM -ARG BUILDPLATFORM -RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM"; WORKDIR /app COPY package.json ./ From 4b57bc41bda10cf7da825f4db8076dc37b750dbf Mon Sep 17 00:00:00 2001 From: ewfian Date: Mon, 2 Oct 2023 16:48:45 +0900 Subject: [PATCH 7/7] move import test with pre-build into release checks --- .github/workflows/test_install_import.yml | 6 +++--- .github/workflows/test_install_import_docker.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_install_import.yml b/.github/workflows/test_install_import.yml index 0012b62..a6c8fa0 100644 --- a/.github/workflows/test_install_import.yml +++ b/.github/workflows/test_install_import.yml @@ -1,10 +1,10 @@ name: Test Install & Import on: + workflow_dispatch: push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + tags: + - "*" jobs: test: diff --git a/.github/workflows/test_install_import_docker.yml b/.github/workflows/test_install_import_docker.yml index bf2455a..dacc2d4 100644 --- a/.github/workflows/test_install_import_docker.yml +++ b/.github/workflows/test_install_import_docker.yml @@ -1,10 +1,10 @@ name: Test Install & Import on Docker on: + workflow_dispatch: push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + tags: + - "*" jobs: test: