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

feat(ci): add address sanitizer workflow #61

Merged
merged 50 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
95b5f6a
fix: avoid deadlock when calling proxy methods synchronously
MarkusJx Feb 25, 2023
1a838a1
fix: only load napi library on windows
MarkusJx Feb 25, 2023
7a40fe2
fix(ci): remove unsupported config values
MarkusJx Feb 25, 2023
9953db4
chore: run prettier
MarkusJx Feb 25, 2023
34501b9
fix: only run uv loop if interface proxy exists
MarkusJx Feb 26, 2023
c42661c
feat(tsDefGen): create interface proxy definitions
MarkusJx Feb 26, 2023
a9f109a
chore: update version
MarkusJx Feb 26, 2023
d93353d
feat(tsDefGen): make interface proxies more generic
MarkusJx Feb 26, 2023
899c791
chore: update dependencies
MarkusJx Feb 26, 2023
438b4e9
feat: allow proxies to be used after they are garbage collected
MarkusJx Feb 27, 2023
c06bf18
chore: run prettier
MarkusJx Feb 27, 2023
6cf3a33
feat(ci): create address sanitizer workflow
MarkusJx Feb 28, 2023
0bfb55a
chore: run prettier
MarkusJx Feb 28, 2023
be165df
fix(ci): asan workflow issues
MarkusJx Feb 28, 2023
90bb555
fix(ci): asan workflow issues
MarkusJx Feb 28, 2023
c90fa90
fix(ci): asan workflow issues
MarkusJx Feb 28, 2023
b1bf184
ci: run more tests
MarkusJx Feb 28, 2023
f4ba7e2
ci: generate test types
MarkusJx Feb 28, 2023
6903b64
fix(ci): update rust-cache
MarkusJx Feb 28, 2023
90ea55d
test: add buffer overflow
MarkusJx Feb 28, 2023
10dc5a5
ci: cache java definitions
MarkusJx Feb 28, 2023
3852f5b
ci: generate test types with asan
MarkusJx Feb 28, 2023
7648396
ci: fix asan.yml
MarkusJx Feb 28, 2023
fb96455
ci: fix asan.yml
MarkusJx Feb 28, 2023
d7e6f0e
ci: fix asan.yml
MarkusJx Feb 28, 2023
e10be37
ci: increase test timeouts
MarkusJx Feb 28, 2023
b40a797
ci: update packages
MarkusJx Feb 28, 2023
c55ec46
ci: update packages
MarkusJx Feb 28, 2023
aa23ce2
ci: stuff
MarkusJx Feb 28, 2023
8a2270e
ci: stuff
MarkusJx Mar 1, 2023
6474320
ci: run tests in docker
MarkusJx Mar 3, 2023
82c8ce6
ci: stuff
MarkusJx Mar 3, 2023
d3ad612
ci: stuff
MarkusJx Mar 3, 2023
05d427a
ci: stuff
MarkusJx Mar 3, 2023
1ec0dae
ci: stuff
MarkusJx Mar 3, 2023
ccec1b7
ci: stuff
MarkusJx Mar 3, 2023
ba071b7
ci: stuff
MarkusJx Mar 3, 2023
2b9f228
ci: stuff
MarkusJx Mar 3, 2023
c8c7d43
ci: stuff
MarkusJx Mar 3, 2023
b49f978
ci: stuff
MarkusJx Mar 3, 2023
37696bf
ci: stuff
MarkusJx Mar 3, 2023
450da9c
chore: remove unused package scripts
MarkusJx Mar 3, 2023
10767af
Merge remote-tracking branch 'origin/main' into feat/interfaceProxyDe…
MarkusJx Mar 3, 2023
9c14438
feat(tsDefGen): add proxy options to generated proxy creators
MarkusJx Mar 3, 2023
b8dd6d1
Merge remote-tracking branch 'origin/main' into ci/asan
MarkusJx Mar 4, 2023
6cd3414
Merge branch 'feat/interfaceProxyDefinitions' into ci/asan
MarkusJx Mar 4, 2023
cd12263
chore: update package-lock.json
MarkusJx Mar 4, 2023
dc0217d
chore: update version
MarkusJx Mar 4, 2023
042b8d3
docs: add experimental comments and exports
MarkusJx Mar 4, 2023
582a7f3
Merge remote-tracking branch 'origin/main' into ci/asan
MarkusJx Mar 4, 2023
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
43 changes: 43 additions & 0 deletions .github/workflows/asan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Address Sanitizer

on:
push:

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3.6.0
with:
node-version: 18
check-latest: true
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run tests with address sanitizer
uses: addnab/docker-run-action@v3
with:
registry: gcr.io
image: ghcr.io/markusjx/prebuilt-debug-jdk:17-bullseye
options: -v ${{ github.workspace }}:/app
run: |
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - >> /dev/null
apt-get install -yqq nodejs
cargo update
npm run build:napi:debug -- --target=x86_64-unknown-linux-gnu \
--cargo-flags="-Zbuild-std"
npm run postbuild

export LD_PRELOAD=$(clang -print-file-name=libclang_rt.asan-x86_64.so)
export RUST_BACKTRACE=1
export FORCE_RUN_ALL_TESTS=true
export INCREASE_TIMEOUT=true
export SKIP_CLASS_TEST=true
export DEBUG='napi:*'
npm run testOnly
2 changes: 1 addition & 1 deletion .github/workflows/check-style.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Check-style
on: [push, pull_request]
on: [push]

jobs:
check-style:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
node-version: 16.x
- name: Rust Cache
uses: Swatinem/rust-cache@v2.0.0
uses: Swatinem/rust-cache@v2.2.1
- name: Build docs
run: |
npm ci
Expand Down
24 changes: 13 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Test

on:
push:
pull_request:

env:
CARGO_TERM_COLOR: always
Expand All @@ -14,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Rust Cache
uses: Swatinem/rust-cache@v2.0.0
uses: Swatinem/rust-cache@v2.2.1
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down Expand Up @@ -53,7 +52,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Setup Node.js ${{matrix.node-version}} environment
uses: actions/setup-node@v3.4.1
uses: actions/setup-node@v3.6.0
with:
node-version: ${{matrix.node-version}}
architecture: ${{matrix.arch}}
Expand All @@ -64,7 +63,12 @@ jobs:
java-version: '17'
architecture: ${{matrix.arch}}
- name: Rust Cache
uses: Swatinem/rust-cache@v2.0.0
uses: Swatinem/rust-cache@v2.2.1
- name: Cache java definitions
uses: actions/cache@v3
with:
path: '**/test/javaDefinitions'
key: ${{runner.os}}-${{matrix.node-version}}-${{matrix.arch}}-javaDefinitions
- name: Install
run: npm ci
- name: Build
Expand All @@ -78,6 +82,7 @@ jobs:
- name: Run tests
run: npm run testOnly
timeout-minutes: 20

- name: Create test summary
uses: test-summary/action@dist
if: always()
Expand Down Expand Up @@ -106,7 +111,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Setup Node.js ${{matrix.node-version}} environment
uses: actions/setup-node@v3.4.1
uses: actions/setup-node@v3.6.0
with:
node-version: ${{matrix.node-version}}
- name: Setup java 17
Expand All @@ -122,7 +127,7 @@ jobs:
override: true
target: aarch64-unknown-linux-gnu
- name: Rust Cache
uses: Swatinem/rust-cache@v2.0.0
uses: Swatinem/rust-cache@v2.2.1
- name: Install cross compile toolchain
run: |
sudo apt-get update
Expand All @@ -138,9 +143,6 @@ jobs:
run: npm run build -- -- --target aarch64-unknown-linux-gnu
- name: Install test dependencies
run: npm install
# npm config set supportedArchitectures.cpu "arm64"
# npm config set supportedArchitectures.libc "glibc"
# npm install
- name: Init qemu
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Run tests
Expand Down Expand Up @@ -179,15 +181,15 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Setup Node.js environment
uses: actions/setup-node@v3.4.1
uses: actions/setup-node@v3.6.0
with:
node-version: 16.x
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Rust Cache
uses: Swatinem/rust-cache@v2.0.0
uses: Swatinem/rust-cache@v2.2.1
- name: Install
run: npm ci
- name: Run benchmarks
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,5 @@ test.js
Dockerfile
test/javaDefinitions/**
/testResults.xml
test/testUtil.js
test/testUtil.js
testOut/
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,5 @@ Temporary Items

docs/
test/javaDefinitions/**
/test/system_test/javaDefinitions/
/test/system_test/javaDefinitions/
testOut/
44 changes: 42 additions & 2 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "java-bridge",
"version": "2.2.3-beta.3",
"version": "2.2.3",
"main": "dist/index.prod.min.js",
"types": "dist/ts-src/index.d.ts",
"description": "A bridge between Node.js and Java APIs",
Expand Down Expand Up @@ -78,6 +78,7 @@
"devDependencies": {
"@napi-rs/cli": "^2.14.8",
"@types/chai": "^4.3.4",
"@types/folder-hash": "^4.0.2",
"@types/glob": "^8.1.0",
"@types/is-ci": "^3.0.0",
"@types/mocha": "^10.0.1",
Expand All @@ -89,6 +90,7 @@
"chai": "^4.3.7",
"cpy-cli": "^4.2.0",
"expose-gc": "^1.0.0",
"folder-hash": "^4.0.4",
"is-ci": "^3.0.1",
"mocha": "^10.2.0",
"mocha-junit-reporter": "^2.2.0",
Expand Down
12 changes: 8 additions & 4 deletions test/ClassTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { expect } from 'chai';
import { ClassTool, shouldIncreaseTimeout } from './testUtil';
import path from 'path';

const shouldSkip = process.env.SKIP_CLASS_TEST === 'true';
const timeout = shouldIncreaseTimeout ? 60e3 : 20e3;
let classTool: ClassTool | null = null;

Expand Down Expand Up @@ -35,6 +36,8 @@ function createJarWithBasicClass(
}

describe('ClassTest', () => {
if (shouldSkip) return;

before(function () {
this.timeout(timeout);
if (!classTool) classTool = new ClassTool();
Expand Down Expand Up @@ -428,7 +431,7 @@ describe('ClassTest', () => {

const ext = instance.getExtSync();
expect(ext).to.be.an('object');
});
}).timeout(timeout);

it('Class with external dependency loaded dynamically', () => {
expect(() => importClass('dyn.importing.Class2')).to.throw();
Expand All @@ -450,7 +453,7 @@ describe('ClassTest', () => {

const instance2 = ext.newInstanceSync();
expect(instance2).to.be.an('object');
});
}).timeout(timeout);

it('Class with properties', () => {
const Class = importClass('ClassWithProperties');
Expand All @@ -475,7 +478,7 @@ describe('ClassTest', () => {
expect(instance.s2).to.be.a('string');
expect(instance.s2).to.equal('def');
expect(() => (instance.s2 = 'def')).to.throw();
});
}).timeout(timeout);

it('Class with complex properties', () => {
const Class = importClass('ClassWithComplexProperties');
Expand All @@ -492,9 +495,10 @@ describe('ClassTest', () => {
expect(instance.innerClass).to.have.property('s1');
expect(instance.innerClass.s1).to.be.a('string');
expect(instance.innerClass.s1).to.equal('abc');
});
}).timeout(timeout);

after(function () {
this.timeout(timeout);
try {
classTool?.dispose();
} catch (_) {}
Expand Down
3 changes: 2 additions & 1 deletion test/ProxyTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ declare class JavaString extends JavaClass {
function getJavaVersion(): string {
const version: string = importClass('java.lang.System')
.getPropertySync('java.version')
.split('_')[0];
.split('_')[0]
.replace(/^(\d+)-internal$/gm, '$1.0.0');

const arr = version.split('.');
arr.length = Math.min(arr.length, 3);
Expand Down
6 changes: 3 additions & 3 deletions test/TypescriptDefinitionGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from 'chai';
import ts from 'typescript';
import path from 'path';
import * as fs from 'fs';
import { shouldIncreaseTimeout } from './testUtil';
import { forceRunAllTests, shouldIncreaseTimeout } from './testUtil';
import isCi from 'is-ci';

interface Diagnostics {
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('TypescriptDefinitionGenerator test', () => {
}).timeout(timeoutMs);

it("Generate 'java.io.FileOutputSteam' definitions", async function () {
if (isCi) {
if (isCi && !forceRunAllTests) {
this.skip();
}

Expand All @@ -145,5 +145,5 @@ describe('TypescriptDefinitionGenerator test', () => {
FileOutputStream.nullOutputStreamSync()!.flushSync();
`
);
}).timeout(timeoutMs * 2);
}).timeout(timeoutMs * 4);
});
Loading