Skip to content

Commit 6aa0ac1

Browse files
committed
typecheck and format on ci (#66)
* 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)
1 parent c228139 commit 6aa0ac1

File tree

6 files changed

+735
-700
lines changed

6 files changed

+735
-700
lines changed

.github/workflows/test.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,27 @@ on:
66
- master
77
pull_request:
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
node-test:
1115
runs-on: ubuntu-latest
1216
steps:
1317
- uses: actions/checkout@v4
1418

19+
- name: Set up Volta
20+
uses: volta-cli/action@v4
21+
22+
- uses: actions/cache@v3
23+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
24+
with:
25+
path: ".yarn/cache"
26+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
27+
restore-keys: |
28+
${{ runner.os }}-yarn-
29+
1530
- name: Install Rust
1631
uses: actions-rs/toolchain@v1
1732
with:
@@ -31,8 +46,14 @@ jobs:
3146
- name: Build Rust wasm test helper
3247
run: cd tests/rust-arrow-ffi && yarn build && cd ../../
3348

34-
- name: Install dev dependencies
35-
run: yarn
49+
- name: Install
50+
run: yarn install
51+
52+
- name: Prettier check
53+
run: yarn fmt:check
54+
55+
- name: Type check
56+
run: yarn typecheck
3657

37-
- name: Run Node tests
58+
- name: Test
3859
run: yarn test

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
"type": "module",
2222
"scripts": {
2323
"build": "rollup -c rollup.config.js",
24-
"watch": "tsc --watch --declaration",
25-
"test": "vitest run"
24+
"fmt:check": "prettier './src/**/*.ts' --check",
25+
"fmt": "prettier './src/**/*.ts' --write",
26+
"test": "vitest run",
27+
"typecheck": "tsc --build",
28+
"watch": "tsc --watch --declaration"
2629
},
2730
"files": [
2831
"dist/",
@@ -35,14 +38,16 @@
3538
"@rollup/plugin-terser": "^0.4.3",
3639
"@rollup/plugin-typescript": "^11.1.2",
3740
"apache-arrow": "^14",
41+
"prettier": "^3.1.0",
3842
"rollup": "^4.1.5",
3943
"rollup-plugin-dts": "^6.1.0",
40-
"rust-arrow-ffi": "./tests/rust-arrow-ffi/pkg/",
44+
"rust-arrow-ffi": "link:./tests/rust-arrow-ffi/pkg/",
4145
"ts-node": "^10.9.1",
4246
"typescript": "^5.2.2",
4347
"vitest": "^0.34.6"
4448
},
4549
"volta": {
46-
"node": "20.9.0"
50+
"node": "20.9.0",
51+
"yarn": "4.0.2"
4752
}
4853
}

src/field.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function parseField(buffer: ArrayBuffer, ptr: number): arrow.Field {
6767
for (let i = 0; i < nChildren; i++) {
6868
childrenFields[i] = parseField(
6969
buffer,
70-
dataView.getUint32(ptrToChildrenPtrs + i * 4, true)
70+
dataView.getUint32(ptrToChildrenPtrs + i * 4, true),
7171
);
7272
}
7373

@@ -194,7 +194,7 @@ function parseFlags(flag: bigint): Flags {
194194
function parseNullTerminatedString(
195195
dataView: DataView,
196196
ptr: number,
197-
maxBytesToRead: number = Infinity
197+
maxBytesToRead: number = Infinity,
198198
): string {
199199
const maxPtr = Math.min(ptr + maxBytesToRead, dataView.byteLength);
200200
let end = ptr;
@@ -213,7 +213,7 @@ function parseNullTerminatedString(
213213
*/
214214
function parseMetadata(
215215
dataView: DataView,
216-
ptr: number
216+
ptr: number,
217217
): Map<string, string> | null {
218218
const numEntries = dataView.getInt32(ptr, true);
219219
if (numEntries === 0) {
@@ -227,14 +227,14 @@ function parseMetadata(
227227
const keyByteLength = dataView.getInt32(ptr, true);
228228
ptr += 4;
229229
const key = UTF8_DECODER.decode(
230-
new Uint8Array(dataView.buffer, ptr, keyByteLength)
230+
new Uint8Array(dataView.buffer, ptr, keyByteLength),
231231
);
232232
ptr += keyByteLength;
233233

234234
const valueByteLength = dataView.getInt32(ptr, true);
235235
ptr += 4;
236236
const value = UTF8_DECODER.decode(
237-
new Uint8Array(dataView.buffer, ptr, valueByteLength)
237+
new Uint8Array(dataView.buffer, ptr, valueByteLength),
238238
);
239239
ptr += valueByteLength;
240240

src/record-batch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function parseRecordBatch(
2020
buffer: ArrayBuffer,
2121
arrayPtr: number,
2222
schemaPtr: number,
23-
copy: boolean = false
23+
copy: boolean = false,
2424
): arrow.RecordBatch {
2525
const field = parseField(buffer, schemaPtr);
2626
if (!isStructField(field)) {

0 commit comments

Comments
 (0)