Skip to content

Commit

Permalink
fix(nodejs-polars): missing build and publish targets (#2102)
Browse files Browse the repository at this point in the history
Co-authored-by: Ritchie Vink <ritchie46@gmail.com>
  • Loading branch information
Brooooooklyn and ritchie46 committed Dec 21, 2021
1 parent 7a2e0a9 commit 6dd84b3
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 91 deletions.
129 changes: 103 additions & 26 deletions .github/workflows/create-js-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,102 @@ jobs:

- host: macos-latest
target: 'x86_64-apple-darwin'
architecture: x64
build: |
npm run build
yarn build
strip -x polars/*.node
- host: macos-latest
target: "aarch64-apple-darwin"
architecture: x64
build: |
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*;
export CC=$(xcrun -f clang);
export CXX=$(xcrun -f clang++);
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
npm run build -- --target aarch64-apple-darwin
yarn build --target aarch64-apple-darwin
strip -x polars/*.node
# Windows
##########

- host: windows-latest
architecture: x64
target: "x86_64-pc-windows-msvc"
build: npm run build
build: yarn build

- host: windows-latest
target: "i686-pc-windows-msvc"
setup: |
choco install nodejs-lts --x86 -y --force
echo "C:\\Program Files (x86)\\nodejs" >> $GITHUB_PATH
architecture: x86
build: |
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=32;
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=128;
export CARGO_PROFILE_RELEASE_LTO=false
npm run build -- --target i686-pc-windows-msvc
- host: windows-latest
architecture: x64
target: "aarch64-pc-windows-msvc"
build: npm run build -- --target aarch64-pc-windows-msvc
build: yarn build --target aarch64-pc-windows-msvc

# Linux
########

- host: ubuntu-latest
target: "x86_64-unknown-linux-gnu"
build: npm run build
target: x86_64-unknown-linux-gnu
architecture: x64
docker: |
docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian builder
build: |
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v "$GITHUB_WORKSPACE:/build" -w /build/nodejs-polars builder yarn build && strip polars/*.node
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
architecture: x64
docker: |
docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder
build: |
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v "$GITHUB_WORKSPACE:/build" -w /build/nodejs-polars builder yarn build && strip polars/*.node
- host: ubuntu-latest
architecture: x64
target: aarch64-unknown-linux-gnu
setup: |
sudo apt-get update
sudo apt-get install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu -y
build: |
yarn build --target=aarch64-unknown-linux-gnu
aarch64-linux-gnu-strip polars/*.node
- host: ubuntu-latest
architecture: x64
target: armv7-unknown-linux-gnueabihf
setup: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
build: |
yarn build --target=armv7-unknown-linux-gnueabihf
arm-linux-gnueabihf-strip polars/*.node
- host: ubuntu-latest
target: "aarch64-linux-android"
architecture: x64
build: |
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang"
export PATH="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH}"
npm run build -- --target aarch64-linux-android
yarn build --target aarch64-linux-android
${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip polars/*.node
- host: ubuntu-latest
architecture: x64
target: aarch64-unknown-linux-musl
downloadTarget: aarch64-unknown-linux-musl
docker: |
docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder
build: |
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v "$GITHUB_WORKSPACE:/build" -w /build/nodejs-polars builder sh -c "rustup toolchain install $(cat ./rust-toolchain) && rustup target add aarch64-unknown-linux-musl && yarn build --target=aarch64-unknown-linux-musl && /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip polars/*.node"
name: ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
Expand All @@ -74,10 +123,14 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 16
architecture: ${{ matrix.settings.architecture }}
cache: yarn
cache-dependency-path: nodejs-polars/yarn.lock
- name: Copy rust-toolchain to root
run: cp rust-toolchain ..
- name: Install latest Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-12-02
override: true
target: ${{ matrix.settings.target }}

Expand All @@ -104,31 +157,53 @@ jobs:
DOCKER_REGISTRY_URL: ghcr.io
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}

if: ${{ matrix.settings.docker }}

- name: "Setup toolchain"
if: ${{ matrix.settings.setup }}
run: ${{ matrix.settings.setup }}

- name: "Install dependencies"
run: npm install --ignore-scripts
run: yarn install
if: ${{ matrix.settings.target != 'i686-pc-windows-msvc' }}

- name: "Install dependencies"
run: npm install
if: ${{ matrix.settings.target == 'i686-pc-windows-msvc' }}

- name: "Build"
run: ${{ matrix.settings.build }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
path: nodejs-polars/artifacts
- name: List artifacts
run: ls -R artifacts
shell: bash
path: nodejs-polars/polars/*.node
name: bindings-${{ matrix.settings.target }}
if-no-files-found: error

test-macos:
defaults:
run:
working-directory: nodejs-polars
needs:
- build-js
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: yarn install
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
name: bindings-x86_64-apple-darwin
path: nodejs-polars/polars
- name: Run test
run: yarn test

publish:
name: Publish
needs:
- build-js
- test-macos
defaults:
run:
working-directory: nodejs-polars
Expand All @@ -139,24 +214,26 @@ jobs:
with:
node-version: "16"
registry-url: "https://registry.npmjs.org"
cache: yarn
cache-dependency-path: nodejs-polars/yarn.lock

- name: "Install dependencies"
run: npm install --ignore-scripts
run: yarn install

- name: Download all artifacts
uses: actions/download-artifact@v2
with:
path: nodejs-polars/artifacts

- name: List artifacts
run: ls -R artifacts
shell: bash

- name: Move artifacts
run: npm run artifacts
run: yarn artifacts

- name: Build TypeScript
run: npm run build:ts
run: yarn build:ts

- name: List artifacts
run: ls -R npm
shell: bash

- name: Publish to npm
run: npm publish
Expand Down
9 changes: 9 additions & 0 deletions nodejs-polars/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
rustflags = ["-C", "target-feature=-crt-static"]

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
1 change: 0 additions & 1 deletion nodejs-polars/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ node_modules/
coverage/
bin/
.vscode
.cargo
*.node
docs/
19 changes: 7 additions & 12 deletions nodejs-polars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ license = "MIT"
repository = "https://github.com/pola-rs/polars"

[lib]
name = "nodejs_polars"
crate-type = ["cdylib"]
name = "nodejs_polars"

[dependencies]
ahash = "0.7"
Expand All @@ -22,18 +22,16 @@ serde_json = { version = "1" }
thiserror = "1.0.20"

[dependencies.napi]
version = "1"
features = [
"serde-json",
"napi5",
"napi6",
]
version = "1"

[build-dependencies]
napi-build = "1"

[dependencies.polars]
path = "../polars"
features = [
"abs",
"zip_with",
Expand All @@ -54,8 +52,7 @@ features = [
"dot_product",
"concat_str",
"row_hash",
"reinterpret",
# "decompress-fast",
"reinterpret", # "decompress-fast",
"mode",
"extract_jsonpath",
"json",
Expand All @@ -67,18 +64,16 @@ features = [
"rank",
"diff",
"moment",
"arange",
# "true_div",
"arange", # "true_div",
"diagonal_concat",
"serde",
# "asof_join",
# "cross_join",
"serde", # "asof_join", # "cross_join",
"lazy",
"repeat_by",
]
path = "../polars"

[profile.release]
lto = "fat"
codegen-units = 1
lto = "fat"

[workspace]
1 change: 1 addition & 0 deletions nodejs-polars/__tests__/lazyframe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ describe("lazyframe", () => {
});
expect(actual).toFrameEqualIgnoringOrder(expected);
});

test("dropDuplicates:maintainOrder", () => {
const actual = pl.DataFrame({
"foo": [1, 2, 2, 2],
Expand Down
3 changes: 0 additions & 3 deletions nodejs-polars/npm/freebsd-x64/README.md

This file was deleted.

18 changes: 0 additions & 18 deletions nodejs-polars/npm/freebsd-x64/package.json

This file was deleted.

0 comments on commit 6dd84b3

Please sign in to comment.