Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add windows build #6

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 69 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ jobs:
build: |
pnpm build --target aarch64-apple-darwin
strip -x *.node
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
build: |-
set -e &&
rustup target add aarch64-unknown-linux-gnu &&
pnpm build --target aarch64-unknown-linux-gnu &&
aarch64-unknown-linux-gnu-strip *.node
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
# build: |-
# set -e &&
# sudo apt-get update &&
# sudo apt-get install perl -y &&
# rustup target add aarch64-unknown-linux-gnu &&
# # Required to build OpenSSL
# export LDFLAGS="-L/usr/aarch64-unknown-linux-gnu/lib/gcc/aarch64-unknown-linux-gnu/4.8.5" &&
# export CFLAGS="-fuse-ld=lld -mcrc -B/usr/aarch64-unknown-linux-gnu/lib/gcc/aarch64-unknown-linux-gnu/4.8.5 --sysroot=/usr/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot" &&
# export CXXFLAGS="-fuse-ld=lld -mcrc -B/usr/aarch64-unknown-linux-gnu/lib/gcc/aarch64-unknown-linux-gnu/4.8.5 --sysroot=/usr/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot" &&
# pnpm build --target aarch64-unknown-linux-gnu &&
# strip *.node
name: stable - ${{ matrix.settings.target }} - node@20
runs-on: ${{ matrix.settings.host }}
steps:
Expand All @@ -64,7 +84,7 @@ jobs:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
Expand All @@ -74,9 +94,9 @@ jobs:
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- uses: goto-bus-stop/setup-zig@v2
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }}
with:
version: 0.10.1
version: 0.13.1
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
Expand All @@ -88,7 +108,7 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: Setup node x86
uses: actions/setup-node@v3
uses: actions/setup-node@v4
if: matrix.settings.target == 'i686-pc-windows-msvc'
with:
node-version: 20
Expand All @@ -106,7 +126,7 @@ jobs:
if: ${{ !matrix.settings.docker }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: ${{ env.APP_NAME }}.*.node
Expand All @@ -132,12 +152,13 @@ jobs:
with:
node-version: ${{ matrix.node }}
check-latest: true
architecture: x64
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: true
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: .
Expand Down Expand Up @@ -169,7 +190,7 @@ jobs:
with:
run_install: true
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings-x86_64-unknown-linux-gnu
path: .
Expand All @@ -179,6 +200,46 @@ jobs:
- name: Test bindings
run: pnpm test
# run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim pnpm test
test-linux-aarch64-gnu-binding:
name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }}
needs:
- build
strategy:
fail-fast: false
matrix:
node:
- '18'
- '20'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: bindings-aarch64-unknown-linux-gnu
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Install dependencies
run: |
pnpm config set supportedArchitectures.cpu "arm64"
pnpm config set supportedArchitectures.libc "glibc"
pnpm install
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: node:${{ matrix.node }}-slim
options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build'
run: |
set -e
pnpm test
ls -la
publish:
name: Publish
runs-on: ubuntu-latest
Expand All @@ -196,7 +257,7 @@ jobs:
with:
run_install: true
- name: Download all artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Move artifacts
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ tokio = { version = "1", features = ["full"] }

tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["json"] }
openssl = { version = "*", features = ["vendored"] }

[build-dependencies]
napi-build = "2.0.1"
napi-build = "2.1"

[profile.release]
lto = true
Expand Down
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,23 @@ export interface KafkaCrabError {
code: number
message: string
}
export class KafkaConsumer {
export declare class KafkaConsumer {
startConsumer(callback: (error: Error | undefined, result: Payload) => Promise<ConsumerResult | undefined>): Promise<void>
}
export class KafkaStreamConsumer {
export declare class KafkaStreamConsumer {
subscribe(topicConfigs: string | Array<TopicPartitionConfig>): Promise<void>
unsubscribe(): void
seek(topic: string, partition: number, offsetModel: OffsetModel, timeout?: number | undefined | null): void
recv(): Promise<Message>
commit(topic: string, partition: number, offset: number, commit: CommitMode): void
}
export class KafkaClient {
export declare class KafkaClient {
readonly kafkaConfiguration: KafkaConfiguration
constructor(kafkaConfiguration: KafkaConfiguration)
createProducer(producerConfiguration: ProducerConfiguration): KafkaProducer
createConsumer(consumerConfiguration: KafkaConsumerConfiguration): KafkaConsumer
createStreamConsumer(consumerConfiguration: ConsumerConfiguration): KafkaStreamConsumer
}
export class KafkaProducer {
export declare class KafkaProducer {
send(producerRecord: ProducerRecord): Promise<Array<RecordMetadata>>
}
3 changes: 3 additions & 0 deletions npm/linux-arm64-gnu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `kafka-crab-js-linux-arm64-gnu`

This is the **aarch64-unknown-linux-gnu** binary for `kafka-crab-js`
25 changes: 25 additions & 0 deletions npm/linux-arm64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "kafka-crab-js-linux-arm64-gnu",
"version": "0.0.0",
"os": [
"linux"
],
"cpu": [
"arm64"
],
"main": "kafka-crab-js.linux-arm64-gnu.node",
"files": [
"kafka-crab-js.linux-arm64-gnu.node"
],
"repository": {
"type": "git",
"url": "https://github.com/inaiat/kafka-crab-js.git"
},
"license": "MIT",
"engines": {
"node": ">= 10"
},
"libc": [
"glibc"
]
}
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"defaults": false,
"additional": [
"aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-unknown-linux-gnu"
]
Expand All @@ -30,12 +31,12 @@
},
"devDependencies": {
"@faker-js/faker": "^8.4.1",
"@napi-rs/cli": "^2.18.3",
"@types/node": "^20.12.12",
"ava": "^6.1.2",
"@napi-rs/cli": "^2.18.4",
"@types/node": "22.1.0",
"ava": "^6.1.3",
"nanoid": "^5.0.7",
"typescript": "^5.4.5",
"xo": "^0.58.0"
"xo": "0.59.3"
},
"ava": {
"timeout": "3m"
Expand All @@ -59,5 +60,5 @@
"universal": "napi universal",
"version": "napi version"
},
"packageManager": "[email protected].1"
"packageManager": "[email protected].4"
}
Loading