Skip to content

Commit

Permalink
chore: add musl abi support for arrch64 and x86 scyall_pg_js package (#…
Browse files Browse the repository at this point in the history
…11)

Co-authored-by: Amninder Kaur <[email protected]>
  • Loading branch information
akaur13 and Amninder Kaur authored Feb 21, 2024
1 parent fc19bf0 commit f6febd9
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 109 deletions.
9 changes: 9 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"]

[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"]

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


61 changes: 42 additions & 19 deletions .github/workflows/npm.yml → .github/workflows/npm_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ env:
jobs:
npm_build:
uses: ./.github/workflows/npm_build.yml
rust_build:
uses: ./.github/workflows/rust_build.yml
build:
needs: npm_build
if: needs.npm_build.result == 'success'
# multiple needs
needs:
- npm_build
- rust_build
# if all needs pass
if:
always() && needs.npm_build.result == 'success' && needs.rust_build.result == 'success'
strategy:
fail-fast: false
matrix:
Expand All @@ -22,28 +29,44 @@ jobs:
target: x86_64-apple-darwin
build: |
cd scylla_pg_js && npm run build -- --target x86_64-apple-darwin
- host: macos-latest
target: aarch64-apple-darwin
build: |
cd scylla_pg_js && npm run build -- --target aarch64-apple-darwin
- host: windows-latest
build: cd scylla_pg_js && npm run build -- --target x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
build: |-
set -e &&
cd scylla_pg_js && npm run build -- --target x86_64-unknown-linux-gnu
- host: macos-latest
target: aarch64-apple-darwin
build: |
cd scylla_pg_js && npm run build -- --target aarch64-apple-darwin
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: |-
set -e &&
rustup target add x86_64-unknown-linux-musl &&
cd scylla_pg_js && npm run build -- --target x86_64-unknown-linux-musl
- host: ubuntu-latest
target: arm64-unknown-linux-musl
target: aarch64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: |-
set -e &&
cd scylla_pg_js && npm run build -- --target arm64-unknown-linux-musl
cd scylla_pg_js &&
rustup target add aarch64-unknown-linux-musl &&
npm run build -- --target aarch64-unknown-linux-musl &&
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
# TODO add aarch64-unknown-linux-gnu
# - host: ubuntu-latest
# target: aarch64-unknown-linux-gnu
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
# build: |-
# set -e &&
# PATH=$PATH:$(pwd) chmod -R 555 $PATH &&
# cd scylla_pg_js && npm run build -- --target aarch64-unknown-linux-gnu &&
# aarch64-unknown-linux-gnu-strip *.node
name: stable - ${{ matrix.settings.target }} - node@18
runs-on: ${{ matrix.settings.host }}
steps:
Expand All @@ -54,16 +77,14 @@ jobs:
with:
node-version: 18
check-latest: true
- name: Install
uses: actions-rs/toolchain@v1
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
if: ${{ !matrix.settings.docker }}
with:
profile: minimal
override: true
toolchain: stable
target: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
Expand All @@ -76,13 +97,17 @@ jobs:
- name: Install dependencies
run: cd scylla_pg_js && npm install

- name: cargo build
run: cargo build

- run: bin/clippy-pedantic.sh
- name: Build in docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
with:
image: ${{ matrix.settings.docker }}
options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build'
run: ${{ matrix.settings.build }}

- name: Build
run: ${{ matrix.settings.build }}
if: ${{ !matrix.settings.docker }}
shell: bash

# - name: setup docker container env for macos
Expand Down Expand Up @@ -127,8 +152,6 @@ jobs:
environment: publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
needs:
- build
Expand Down
Loading

0 comments on commit f6febd9

Please sign in to comment.