Skip to content

Commit

Permalink
CI: add buildx for check import on arm64 (#18)
Browse files Browse the repository at this point in the history
* test buildx

* test buildx build

* fix test failed

* fix inspect

* test

* fix

* test

* test

* test

* fix

* add logs

* test install

* fix install

* test

* fix

* diable armv7 test
  • Loading branch information
ewfian committed Jun 15, 2023
1 parent a3fe14b commit 1e9be67
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
39 changes: 32 additions & 7 deletions .github/workflows/test_install_import_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,50 @@ jobs:
fail-fast: false
matrix:
node: ['14', '16', '18', '20']
distro:
- ''
- -buster
- -bullseye
- -alpine
platform: [
{
distro: '',
arch: 'linux/amd64'
},
{
distro: '-buster',
arch: 'linux/amd64'
},
{
distro: '-bullseye',
arch: 'linux/amd64'
},
{
distro: '-alpine',
arch: 'linux/amd64'
},
{
distro: '-alpine',
arch: 'linux/arm64'
},
# {
# distro: '-alpine',
# arch: 'linux/arm/v7'
# }
]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: NPM Pack
run: npm pack
- name: Rename Package
run: mv faiss-node-*.tgz test-import/faiss-node.tgz
- name: Build docker on node:${{ matrix.node }}${{ matrix.distro }}
- name: Build docker on node:${{ matrix.node }}${{ matrix.platform.distro }}
working-directory: ./test-import
run: docker build -t test-import --build-arg BASE_IMAGE=node:${{ matrix.node }}${{ matrix.distro }} .
run: docker buildx build --platform ${{ matrix.platform.arch }} -o type=docker -t test-import --build-arg BASE_IMAGE=node:${{ matrix.node }}${{ matrix.platform.distro }} .
- 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)|(libgfortran\\.so\\.5)|(libquadmath\\.so\\.0)$\" --backend cmake-js",
"install": "prebuild-install --runtime napi --verbose || npm run build",
"install": "prebuild-install --runtime napi --verbose || (npm i cmake-js && npm run build)",
"test": "jest",
"doc": "typedoc"
},
Expand Down
10 changes: 9 additions & 1 deletion test-import/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
ARG BASE_IMAGE=node:18-alpine
FROM $BASE_IMAGE
WORKDIR /app
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM";

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
COPY . .

Expand Down
4 changes: 4 additions & 0 deletions test-import/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ const { IndexFlatL2 } = require('faiss-node');
const dimension = 4096;
const index = new IndexFlatL2(dimension);
assert.equal(index.getDimension(), dimension);

console.log(process.version);
console.log(process.platform);
console.log(process.arch);
console.log(index.getDimension());

0 comments on commit 1e9be67

Please sign in to comment.