forked from yoshoku/hnswlib-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
450 additions
and
67 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
name: CI | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- '*' | ||
env: | ||
FORCE_COLOR: 1 | ||
concurrency: | ||
group: ${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- macos-latest | ||
- ubuntu-20.04 | ||
- windows-latest | ||
host: | ||
- x64 | ||
target: | ||
- x64 | ||
node: | ||
- 16 | ||
- 18 | ||
- 20 | ||
name: ${{ matrix.os }} (node=${{ matrix.node }}, host=${{ matrix.host }}, target=${{ matrix.target }}) | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
architecture: ${{ matrix.host }} | ||
|
||
- name: Add yarn (self-hosted) | ||
if: matrix.os == 'macos-m1' | ||
run: npm install -g yarn | ||
|
||
- name: Add msbuild to PATH | ||
uses: microsoft/setup-msbuild@v1.3 | ||
if: contains(matrix.os, 'windows') | ||
with: | ||
msbuild-architecture: ${{ matrix.target }} | ||
|
||
- name: Install dependencies | ||
run: yarn install --ignore-scripts | ||
|
||
- name: Add env vars | ||
shell: bash | ||
run: | | ||
echo "V=1" >> $GITHUB_ENV | ||
if [ "${{ matrix.target }}" = "x86" ]; then | ||
echo "TARGET=ia32" >> $GITHUB_ENV | ||
else | ||
echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV | ||
fi | ||
- name: Configure build | ||
run: yarn node-pre-gyp configure --target_arch=${{ env.TARGET }} | ||
|
||
- name: Build binaries | ||
run: yarn node-pre-gyp build --target_arch=${{ env.TARGET }} | ||
|
||
- name: Print binary info | ||
if: contains(matrix.os, 'ubuntu') | ||
run: | | ||
ldd lib/binding/*/addon.node | ||
echo "---" | ||
nm lib/binding/*/addon.node | grep "GLIBC_" | c++filt || true | ||
echo "---" | ||
file lib/binding/napi-v*/* | ||
- name: Run tests | ||
run: yarn test | ||
|
||
- name: Package prebuilt binaries | ||
run: yarn node-pre-gyp package --target_arch=${{ env.TARGET }} | ||
|
||
- name: Upload binaries to commit artifacts | ||
uses: actions/upload-artifact@v3 | ||
if: matrix.node == 16 | ||
with: | ||
name: prebuilt-binaries | ||
path: build/stage/*/* | ||
retention-days: 7 | ||
|
||
- name: Upload binaries to GitHub Release | ||
run: yarn node-pre-gyp-github publish | ||
if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/') | ||
env: | ||
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
build-qemu: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: | ||
- 16 | ||
target: | ||
- linux/arm64 | ||
variant: | ||
- bullseye | ||
- alpine3.15 | ||
include: | ||
# musl x64 builds | ||
- target: linux/amd64 | ||
variant: alpine3.15 | ||
node: 16 | ||
name: ${{ matrix.variant }} (node=${{ matrix.node }}, target=${{ matrix.target }}) | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build binaries and test | ||
run: | | ||
docker buildx build \ | ||
--file ./tools/BinaryBuilder.Dockerfile \ | ||
--load \ | ||
--tag builder \ | ||
--platform ${{ matrix.target }} \ | ||
--no-cache \ | ||
--build-arg VARIANT=${{ matrix.variant }} \ | ||
--build-arg NODE_VERSION=${{ matrix.node }} \ | ||
. | ||
CONTAINER_ID=$(docker create -it builder) | ||
docker cp $CONTAINER_ID:/usr/src/build/build/ ./build | ||
- name: Upload binaries to commit artifacts | ||
uses: actions/upload-artifact@v3 | ||
if: matrix.node == 16 | ||
with: | ||
name: prebuilt-binaries | ||
path: build/stage/*/* | ||
retention-days: 7 | ||
|
||
- name: Upload binaries to GitHub Release | ||
run: yarn install --ignore-scripts && yarn node-pre-gyp-github publish | ||
if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/') | ||
env: | ||
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
/node_modules | ||
/doc | ||
.DS_Store | ||
|
||
build-tmp-* | ||
lib/binding |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ARG NODE_VERSION=16 | ||
ARG VARIANT=bullseye | ||
|
||
FROM node:$NODE_VERSION-$VARIANT | ||
|
||
ARG VARIANT | ||
|
||
RUN if case $VARIANT in "alpine"*) true;; *) false;; esac; then apk add build-base python3 --update-cache ; fi | ||
|
||
WORKDIR /usr/src/build | ||
|
||
COPY . . | ||
RUN npm install --ignore-scripts | ||
|
||
# Workaround for https://github.com/mapbox/node-pre-gyp/issues/644 | ||
RUN cd node_modules/\@mapbox/node-pre-gyp \ | ||
&& npm install fs-extra@10.0.1 \ | ||
&& sed -i -e s/\'fs/\'fs-extra/ -e s/fs\.renameSync/fs.moveSync/ ./lib/util/napi.js | ||
|
||
RUN npx node-pre-gyp configure | ||
RUN npx node-pre-gyp build | ||
|
||
RUN if case $VARIANT in "alpine"*) false;; *) true;; esac; then ldd lib/binding/*/addon.node; nm lib/binding/*/addon.node | grep \"GLIBC_\" | c++filt || true ; fi | ||
|
||
RUN npm run test | ||
RUN npx node-pre-gyp package | ||
|
||
CMD ["sh"] |
Oops, something went wrong.