Skip to content
Merged
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
41 changes: 0 additions & 41 deletions .github/workflows/alpine-container.yml

This file was deleted.

10 changes: 7 additions & 3 deletions .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
pull_request:
workflow_dispatch:

env:
JAVA_VERSION: 21
NODE_VERSION: 24

concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }}
cancel-in-progress: true
Expand Down Expand Up @@ -35,14 +39,14 @@ jobs:
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 20
node-version: ${{env.NODE_VERSION}}
check-latest: true
cache: 'npm'
- name: Setup java 17
- name: Setup java
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
java-version: ${{env.JAVA_VERSION}}

- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
Expand Down
29 changes: 8 additions & 21 deletions .github/workflows/test-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,19 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: java-bridge-asan-testcontainer
IMAGE_NAME: ghcr.io/markusjx/node-java-bridge/java-bridge-asan-testcontainer:latest

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Create dockerfile
uses: edgardleal/mustache-template-action@v1.0.4
env:
DEBIAN_VERSION: ${{github.event.inputs.debian-version}}
JDK_VERSION: ${{github.event.inputs.jdk-version}}
NODE_VERSION: ${{github.event.inputs.node-version}}
with:
input: ./docker/Dockerfile-test-template.hbs
output: Dockerfile

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log into registry
- uses: actions/checkout@v6
- name: Docker login
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login $REGISTRY -u ${{ github.actor }} --password-stdin
- name: Push latest image
- name: Build image
run: |
IMAGE_ID=$REGISTRY/${{ github.repository }}
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')/$IMAGE_NAME
docker tag $IMAGE_NAME $IMAGE_ID:latest
docker push $IMAGE_ID:latest
docker build --push -f docker/Dockerfile.asan -t $IMAGE_NAME\
--build-arg JDK_VERSION=${{github.event.inputs.jdk-version}} \
--build-arg NODE_VERSION=${{github.event.inputs.node-version}} \
--build-arg DEBIAN_VERSION=${{github.event.inputs.debian-version}} .
53 changes: 40 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:

env:
CARGO_TERM_COLOR: always
DEBIAN_VERSION: trixie
JAVA_VERSION: 21

concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }}
Expand Down Expand Up @@ -86,10 +88,18 @@ jobs:
architecture: ${{matrix.arch}}
- name: Setup java 17
uses: actions/setup-java@v5
if: ${{matrix.os == 'windows-latest'}}
with:
distribution: 'temurin'
java-version: '17'
architecture: ${{matrix.arch}}
- name: Setup java
uses: actions/setup-java@v5
if: ${{matrix.os != 'windows-latest'}}
with:
distribution: 'temurin'
java-version: ${{env.JAVA_VERSION}}
architecture: ${{matrix.arch}}
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
if: ${{matrix.os != 'ubuntu-latest' && matrix.os != 'ubuntu-20.04'}}
Expand Down Expand Up @@ -146,7 +156,7 @@ jobs:
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
java-version: ${{env.JAVA_VERSION}}
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
Expand All @@ -171,19 +181,26 @@ jobs:
run: npm install
- name: Init qemu
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Docker login
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build test container
run: |
if docker manifest inspect ghcr.io/markusjx/node-java-bridge/test-arm:${{matrix.node-version}}-$JAVA_VERSION-$DEBIAN_VERSION;
then
echo "Docker container already exists"
else
docker build --push --platform linux/arm64 --build-arg NODE_VERSION=${{matrix.node-version}} \
--build-arg DEBIAN_VERSION=$DEBIAN_VERSION \
--build-arg JAVA_VERSION=$JAVA_VERSION -f docker/Dockerfile.arm \
-t ghcr.io/markusjx/node-java-bridge/test-arm:${{matrix.node-version}}-$JAVA_VERSION-$DEBIAN_VERSION .
fi
- name: Run tests
uses: addnab/docker-run-action@v3
timeout-minutes: 180
with:
image: arm64v8/node:${{matrix.node-version}}-trixie
image: ghcr.io/markusjx/node-java-bridge/test-arm:${{matrix.node-version}}-${{env.JAVA_VERSION}}-${{env.DEBIAN_VERSION}}
options: -v ${{ github.workspace }}:/github/workspace -w /github/workspace --platform linux/arm64
run: |
apt-get update
apt-get install ca-certificates-java -y
apt-get install openjdk-21-jre-headless -y
apt-get remove -y openjdk-11*
npm config set cache /tmp --global
export CI=true
npm install
npm run testOnly
- name: Create test summary
Expand All @@ -209,20 +226,30 @@ jobs:
fail-fast: false
matrix:
node-version: [20, 22]
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
- name: Docker login
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build test container
run: |
if docker manifest inspect ghcr.io/markusjx/node-java-bridge/test-alpine:${{matrix.node-version}}-$JAVA_VERSION;
then
echo "Docker container already exists"
else
docker build --push --build-arg NODE_VERSION=${{matrix.node-version}} \
--build-arg JAVA_VERSION=$JAVA_VERSION -f docker/Dockerfile.alpine \
-t ghcr.io/markusjx/node-java-bridge/test-alpine:${{matrix.node-version}}-$JAVA_VERSION .
fi
- name: Run tests
uses: addnab/docker-run-action@v3
timeout-minutes: 180
with:
image: ghcr.io/markusjx/node-java-bridge/java-bridge-node-alpine-build:node-${{matrix.node-version}}-jdk-17
image: ghcr.io/markusjx/node-java-bridge/test-alpine:${{matrix.node-version}}-${{env.JAVA_VERSION}}
options: -v ${{ github.workspace }}:/github/workspace -w /github/workspace
run: |
npm config set cache /tmp --global
export CI=true
npm ci
npm test
- name: Create test summary
Expand Down Expand Up @@ -254,7 +281,7 @@ jobs:
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
java-version: ${{env.JAVA_VERSION}}
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
- name: Install
Expand Down
30 changes: 23 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ ensureJvm({

All threads will be attached as daemon threads, allowing the jvm to exit when the main
thread exits.
This behaviour can not be changed, as it may introduce undefined behaviour.
This behavior can not be changed, as it may introduce undefined behaviour.

Important note on jvm options: Different arguments must be parsed as separate strings in
the `opts` array.
Expand Down Expand Up @@ -266,7 +266,7 @@ await str.toString(); // 'Hello World'

When using asynchronous functions, by default, the number of threads used by these functions
is determined by the number of physical CPUs available.
In order to change this behaviour, set the `JAVA_BRIDGE_THREAD_POOL_SIZE` environment variable
In order to change this behavior, set the `JAVA_BRIDGE_THREAD_POOL_SIZE` environment variable
to the desired amount of threads.

Note: Setting this to a non-numeric value will cause an error to be thrown during startup.
Expand Down
4 changes: 2 additions & 2 deletions crates/java-bridge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "java"
version = "2.8.0"
version = "2.8.1"

[lib]
crate-type = ["cdylib"]
Expand All @@ -25,7 +25,7 @@ glob = "0.3.1"
java-rs = { path = "../java-rs" }
app-state = { git = "https://github.com/MarkusJx/app-state" }
# TODO: remove this once the next version of napi-sys is released
libloading = "0.8.6"
libloading = "0.9.0"
anyhow = "1.0.97"
log = { version = "0.4.27", optional = true }
log4rs = { version = "1.3.0", features = ["json_format"], optional = true }
Expand Down
6 changes: 3 additions & 3 deletions crates/java-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ version = "1.0.0"
edition = "2021"

[dependencies]
libloading = "0.8"
libloading = "0.9"
lazy_static = "1.4.0"
java-locator = "0.1.5"
regex = { version = "1.11.1", optional = true }
log = { version = "0.4.22", optional = true }

[build-dependencies]
bindgen = "0.71.1"
bindgen = "0.72.1"
java-locator = "0.1.8"
build-target = "0.4.0"
build-target = "0.8.0"

[features]
type_check = ["dep:regex"]
Expand Down
4 changes: 1 addition & 3 deletions crates/java-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ fn main() {
.clang_arg(format!("-I{}", java_home.join(os_dir).as_path().to_str().unwrap()).as_str())
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()));

if build_target::target_os().unwrap() == Os::Linux
&& build_target::target_arch().unwrap() == Arch::AARCH64
{
if build_target::target_os() == Os::Linux && build_target::target_arch() == Arch::AArch64 {
bindings = bindings.size_t_is_usize(false);
}

Expand Down
14 changes: 0 additions & 14 deletions docker/Dockerfile-build-alpine.hbs

This file was deleted.

Loading
Loading