Skip to content

Commit

Permalink
typecheck and format on ci (#66)
Browse files Browse the repository at this point in the history
* typecheck and format on ci

* fmt

* use link: for local rust test package to avoid checksum
(checksum is different when built on ci, which fails)
  • Loading branch information
kylebarron committed Jan 31, 2024
1 parent c228139 commit 6aa0ac1
Show file tree
Hide file tree
Showing 6 changed files with 735 additions and 700 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,27 @@ on:
- master
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
node-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Volta
uses: volta-cli/action@v4

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ".yarn/cache"
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand All @@ -31,8 +46,14 @@ jobs:
- name: Build Rust wasm test helper
run: cd tests/rust-arrow-ffi && yarn build && cd ../../

- name: Install dev dependencies
run: yarn
- name: Install
run: yarn install

- name: Prettier check
run: yarn fmt:check

- name: Type check
run: yarn typecheck

- name: Run Node tests
- name: Test
run: yarn test
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
"type": "module",
"scripts": {
"build": "rollup -c rollup.config.js",
"watch": "tsc --watch --declaration",
"test": "vitest run"
"fmt:check": "prettier './src/**/*.ts' --check",
"fmt": "prettier './src/**/*.ts' --write",
"test": "vitest run",
"typecheck": "tsc --build",
"watch": "tsc --watch --declaration"
},
"files": [
"dist/",
Expand All @@ -35,14 +38,16 @@
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.2",
"apache-arrow": "^14",
"prettier": "^3.1.0",
"rollup": "^4.1.5",
"rollup-plugin-dts": "^6.1.0",
"rust-arrow-ffi": "./tests/rust-arrow-ffi/pkg/",
"rust-arrow-ffi": "link:./tests/rust-arrow-ffi/pkg/",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"vitest": "^0.34.6"
},
"volta": {
"node": "20.9.0"
"node": "20.9.0",
"yarn": "4.0.2"
}
}
10 changes: 5 additions & 5 deletions src/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function parseField(buffer: ArrayBuffer, ptr: number): arrow.Field {
for (let i = 0; i < nChildren; i++) {
childrenFields[i] = parseField(
buffer,
dataView.getUint32(ptrToChildrenPtrs + i * 4, true)
dataView.getUint32(ptrToChildrenPtrs + i * 4, true),
);
}

Expand Down Expand Up @@ -194,7 +194,7 @@ function parseFlags(flag: bigint): Flags {
function parseNullTerminatedString(
dataView: DataView,
ptr: number,
maxBytesToRead: number = Infinity
maxBytesToRead: number = Infinity,
): string {
const maxPtr = Math.min(ptr + maxBytesToRead, dataView.byteLength);
let end = ptr;
Expand All @@ -213,7 +213,7 @@ function parseNullTerminatedString(
*/
function parseMetadata(
dataView: DataView,
ptr: number
ptr: number,
): Map<string, string> | null {
const numEntries = dataView.getInt32(ptr, true);
if (numEntries === 0) {
Expand All @@ -227,14 +227,14 @@ function parseMetadata(
const keyByteLength = dataView.getInt32(ptr, true);
ptr += 4;
const key = UTF8_DECODER.decode(
new Uint8Array(dataView.buffer, ptr, keyByteLength)
new Uint8Array(dataView.buffer, ptr, keyByteLength),
);
ptr += keyByteLength;

const valueByteLength = dataView.getInt32(ptr, true);
ptr += 4;
const value = UTF8_DECODER.decode(
new Uint8Array(dataView.buffer, ptr, valueByteLength)
new Uint8Array(dataView.buffer, ptr, valueByteLength),
);
ptr += valueByteLength;

Expand Down
2 changes: 1 addition & 1 deletion src/record-batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function parseRecordBatch(
buffer: ArrayBuffer,
arrayPtr: number,
schemaPtr: number,
copy: boolean = false
copy: boolean = false,
): arrow.RecordBatch {
const field = parseField(buffer, schemaPtr);
if (!isStructField(field)) {
Expand Down
Loading

0 comments on commit 6aa0ac1

Please sign in to comment.