Skip to content

Commit

Permalink
add support linux-x64-musl, linux-aarch64 for nodejs sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Sep 23, 2024
1 parent ba48486 commit c7617ff
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 16 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,16 @@ jobs:
- host: macos-13
architecture: x64
build: |
npm run build:debug
yarn build:debug
strip -x *.node
- host: windows-latest
build: npm run build:debug
build: yarn build:debug
architecture: x64

- host: ubuntu-latest
build: |
npm run build:debug
yarn build:debug
strip *.node
- host: macos-13
Expand All @@ -296,7 +296,7 @@ jobs:
export CXX=$(xcrun -f clang++);
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
yarn build --target aarch64-apple-darwin
yarn build:debug --target aarch64-apple-darwin
strip -x *.node
runs-on: ${{ matrix.settings.host }}
Expand All @@ -323,8 +323,9 @@ jobs:
- name: Check with clippy
run: cargo clippy -p longport-nodejs --all-features

- name: Install napi-rs/cli
run: npm install -g @napi-rs/cli
- name: Install dependencies
working-directory: nodejs
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000

- name: Build
working-directory: nodejs
Expand Down
48 changes: 39 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,43 @@ jobs:
fail-fast: true
matrix:
settings:
- host: ubuntu-latest
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: |
yarn build
strip -x *.node
artifact-name: linux-x64-musl

- host: ubuntu-latest
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
build: |
yarn build --target aarch64-unknown-linux-gnu
aarch64-unknown-linux-gnu-strip *.node
artifact-name: linux-aarch64

# - host: ubuntu-latest
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
# build: |
# rustup target add aarch64-unknown-linux-musl
# yarn build --target aarch64-unknown-linux-musl
# /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
# artifact-name: linux-aarch64-musl

- host: macos-13
architecture: x64
build: |
npm run build
yarn build
strip -x *.node
artifact-name: macos

- host: windows-latest
build: npm run build
build: yarn build
architecture: x64
artifact-name: windows

- host: ubuntu-latest
build: |
npm run build
yarn build
strip *.node
artifact-name: linux-x64

Expand All @@ -218,29 +240,38 @@ jobs:

- name: Setup node
uses: actions/setup-node@v3
if: ${{ !matrix.settings.docker }}
with:
node-version: 16
check-latest: true
architecture: ${{ matrix.settings.architecture }}

- name: Install Rust
uses: actions-rs/toolchain@v1
if: ${{ !matrix.settings.docker }}
with:
toolchain: stable
override: true
components: rustfmt, clippy
target: ${{ matrix.settings.target }}

- name: Check with clippy
run: cargo clippy -p longport-nodejs --all-features

- name: Install napi-rs/cli
run: npm install -g @napi-rs/cli
- name: Install dependencies
working-directory: nodejs
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000

- name: Build
if: ${{ !matrix.settings.docker }}
working-directory: nodejs
run: ${{ matrix.settings.build }}

- 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 }}:/build -w /build/nodejs"
run: ${{ matrix.settings.build }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -802,7 +833,6 @@ jobs:
check-latest: true
- name: Install napi-rs/cli
run: npm install -g @napi-rs/cli

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
Expand Down
12 changes: 11 additions & 1 deletion rust/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::collections::HashMap;
use std::{
collections::HashMap,
fmt::{self, Display},
};

use http::Method;
pub(crate) use http::{header, HeaderValue, Request};
Expand Down Expand Up @@ -38,6 +41,12 @@ impl Language {
}
}

impl Display for Language {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}

/// Push mode for candlestick
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum PushCandlestickMode {
Expand Down Expand Up @@ -216,6 +225,7 @@ impl Config {
/// Create metadata for auth/reconnect request
pub fn create_metadata(&self) -> HashMap<String, String> {
let mut metadata = HashMap::new();
metadata.insert("accept-language".to_string(), self.language.to_string());
if self.enable_overnight {
metadata.insert("need_over_night_quote".to_string(), "true".to_string());
}
Expand Down

0 comments on commit c7617ff

Please sign in to comment.