Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clone faiss into install hook #45

Merged
merged 7 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/test_install_import.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Test Install & Import

on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
tags:
- "*"

jobs:
test:
Expand All @@ -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
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/test_install_import_docker.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Test Install & Import on Docker

on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
tags:
- "*"

jobs:
test:
Expand Down Expand Up @@ -32,11 +32,7 @@ jobs:
{
distro: '-alpine',
arch: 'linux/arm64'
},
# {
# distro: '-alpine',
# arch: 'linux/arm/v7'
# }
}
]
runs-on: ubuntu-latest
steps:
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/test_install_import_docker_without_prebuild.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
7 changes: 1 addition & 6 deletions test-import/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ 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 --verbose
RUN npm install ./faiss-node.tgz --foreground-scripts
COPY . .

CMD [ "node", "index.js" ]
19 changes: 19 additions & 0 deletions test-import/Dockerfile.withoutprebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM ubuntu:22.04

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" ]