From a41c8509cf8def16099eb2f20336aac5438f819a Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 18:13:29 +0800 Subject: [PATCH 01/14] feat: add y-octo-node --- Cargo.toml | 2 +- y-octo-node/Cargo.toml | 11 +++++++++++ y-octo-node/src/lib.rs | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 y-octo-node/Cargo.toml create mode 100644 y-octo-node/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 744b2b4..858b8c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] -members = ["./y-octo", "./y-octo-utils"] +members = ["./y-octo", "./y-octo-node", "./y-octo-utils"] resolver = "2" [workspace.dependencies] diff --git a/y-octo-node/Cargo.toml b/y-octo-node/Cargo.toml new file mode 100644 index 0000000..bb873d2 --- /dev/null +++ b/y-octo-node/Cargo.toml @@ -0,0 +1,11 @@ +[package] +authors = ["DarkSky "] +edition = "2021" +license = "MIT" +name = "y-octo-node" +repository = "https://github.com/toeverything/y-octo" +version = "0.0.1" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/y-octo-node/src/lib.rs b/y-octo-node/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/y-octo-node/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} From 59302bc38b3f88d4f6cf87a662de6bf15a0c382f Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 18:23:07 +0800 Subject: [PATCH 02/14] feat: add deps --- y-octo-node/Cargo.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/y-octo-node/Cargo.toml b/y-octo-node/Cargo.toml index bb873d2..97536a5 100644 --- a/y-octo-node/Cargo.toml +++ b/y-octo-node/Cargo.toml @@ -7,5 +7,15 @@ repository = "https://github.com/toeverything/y-octo" version = "0.0.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +crate-type = ["cdylib"] [dependencies] +napi = "2" +napi-derive = "2" + +[build-dependencies] +napi-build = "2" + +[profile.release] +lto = true From 7a1c804eede33730467f009cf28844905fff4d31 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 18:42:58 +0800 Subject: [PATCH 03/14] feat: init build --- package.json | 9 +- y-octo-node/.gitignore | 1 + y-octo-node/Cargo.toml | 1 + y-octo-node/build.rs | 3 + y-octo-node/index.d.ts | 9 ++ y-octo-node/index.js | 257 ++++++++++++++++++++++++++++++++++++ y-octo-node/package.json | 42 ++++++ y-octo-node/src/doc.rs | 26 ++++ y-octo-node/src/lib.rs | 15 +-- yarn.lock | 278 +++++++++++++++++++++++++++++++++++++-- 10 files changed, 614 insertions(+), 27 deletions(-) create mode 100644 y-octo-node/.gitignore create mode 100644 y-octo-node/build.rs create mode 100644 y-octo-node/index.d.ts create mode 100644 y-octo-node/index.js create mode 100644 y-octo-node/package.json create mode 100644 y-octo-node/src/doc.rs diff --git a/package.json b/package.json index 196aee2..014d7f0 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,15 @@ { - "name": "y-octo", + "name": "@y-octo/format", "version": "0.0.0", "packageManager": "yarn@3.6.2", "license": "MIT", + "workspaces": [ + ".", + "y-octo-node" + ], + "engines": { + "node": ">=18.16.1 <19.0.0" + }, "scripts": { "format": "run-p format:toml format:prettier format:rs", "format:toml": "taplo format", diff --git a/y-octo-node/.gitignore b/y-octo-node/.gitignore new file mode 100644 index 0000000..d849c50 --- /dev/null +++ b/y-octo-node/.gitignore @@ -0,0 +1 @@ +*.node \ No newline at end of file diff --git a/y-octo-node/Cargo.toml b/y-octo-node/Cargo.toml index 97536a5..34d9e3d 100644 --- a/y-octo-node/Cargo.toml +++ b/y-octo-node/Cargo.toml @@ -13,6 +13,7 @@ crate-type = ["cdylib"] [dependencies] napi = "2" napi-derive = "2" +y-octo = { path = "../y-octo" } [build-dependencies] napi-build = "2" diff --git a/y-octo-node/build.rs b/y-octo-node/build.rs new file mode 100644 index 0000000..0f1b010 --- /dev/null +++ b/y-octo-node/build.rs @@ -0,0 +1,3 @@ +fn main() { + napi_build::setup(); +} diff --git a/y-octo-node/index.d.ts b/y-octo-node/index.d.ts new file mode 100644 index 0000000..314a412 --- /dev/null +++ b/y-octo-node/index.d.ts @@ -0,0 +1,9 @@ +/* tslint:disable */ +/* eslint-disable */ + +/* auto-generated by NAPI-RS */ + +export class Doc { + constructor(clientId?: number | undefined | null) + get clientId(): number +} diff --git a/y-octo-node/index.js b/y-octo-node/index.js new file mode 100644 index 0000000..de30966 --- /dev/null +++ b/y-octo-node/index.js @@ -0,0 +1,257 @@ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +/* auto-generated by NAPI-RS */ + +const { existsSync, readFileSync } = require('fs') +const { join } = require('path') + +const { platform, arch } = process + +let nativeBinding = null +let localFileExisted = false +let loadError = null + +function isMusl() { + // For Node 10 + if (!process.report || typeof process.report.getReport !== 'function') { + try { + const lddPath = require('child_process').execSync('which ldd').toString().trim() + return readFileSync(lddPath, 'utf8').includes('musl') + } catch (e) { + return true + } + } else { + const { glibcVersionRuntime } = process.report.getReport().header + return !glibcVersionRuntime + } +} + +switch (platform) { + case 'android': + switch (arch) { + case 'arm64': + localFileExisted = existsSync(join(__dirname, 'y-octo.android-arm64.node')) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.android-arm64.node') + } else { + nativeBinding = require('@y-octo/node-android-arm64') + } + } catch (e) { + loadError = e + } + break + case 'arm': + localFileExisted = existsSync(join(__dirname, 'y-octo.android-arm-eabi.node')) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.android-arm-eabi.node') + } else { + nativeBinding = require('@y-octo/node-android-arm-eabi') + } + } catch (e) { + loadError = e + } + break + default: + throw new Error(`Unsupported architecture on Android ${arch}`) + } + break + case 'win32': + switch (arch) { + case 'x64': + localFileExisted = existsSync( + join(__dirname, 'y-octo.win32-x64-msvc.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.win32-x64-msvc.node') + } else { + nativeBinding = require('@y-octo/node-win32-x64-msvc') + } + } catch (e) { + loadError = e + } + break + case 'ia32': + localFileExisted = existsSync( + join(__dirname, 'y-octo.win32-ia32-msvc.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.win32-ia32-msvc.node') + } else { + nativeBinding = require('@y-octo/node-win32-ia32-msvc') + } + } catch (e) { + loadError = e + } + break + case 'arm64': + localFileExisted = existsSync( + join(__dirname, 'y-octo.win32-arm64-msvc.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.win32-arm64-msvc.node') + } else { + nativeBinding = require('@y-octo/node-win32-arm64-msvc') + } + } catch (e) { + loadError = e + } + break + default: + throw new Error(`Unsupported architecture on Windows: ${arch}`) + } + break + case 'darwin': + localFileExisted = existsSync(join(__dirname, 'y-octo.darwin-universal.node')) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.darwin-universal.node') + } else { + nativeBinding = require('@y-octo/node-darwin-universal') + } + break + } catch {} + switch (arch) { + case 'x64': + localFileExisted = existsSync(join(__dirname, 'y-octo.darwin-x64.node')) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.darwin-x64.node') + } else { + nativeBinding = require('@y-octo/node-darwin-x64') + } + } catch (e) { + loadError = e + } + break + case 'arm64': + localFileExisted = existsSync( + join(__dirname, 'y-octo.darwin-arm64.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.darwin-arm64.node') + } else { + nativeBinding = require('@y-octo/node-darwin-arm64') + } + } catch (e) { + loadError = e + } + break + default: + throw new Error(`Unsupported architecture on macOS: ${arch}`) + } + break + case 'freebsd': + if (arch !== 'x64') { + throw new Error(`Unsupported architecture on FreeBSD: ${arch}`) + } + localFileExisted = existsSync(join(__dirname, 'y-octo.freebsd-x64.node')) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.freebsd-x64.node') + } else { + nativeBinding = require('@y-octo/node-freebsd-x64') + } + } catch (e) { + loadError = e + } + break + case 'linux': + switch (arch) { + case 'x64': + if (isMusl()) { + localFileExisted = existsSync( + join(__dirname, 'y-octo.linux-x64-musl.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.linux-x64-musl.node') + } else { + nativeBinding = require('@y-octo/node-linux-x64-musl') + } + } catch (e) { + loadError = e + } + } else { + localFileExisted = existsSync( + join(__dirname, 'y-octo.linux-x64-gnu.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.linux-x64-gnu.node') + } else { + nativeBinding = require('@y-octo/node-linux-x64-gnu') + } + } catch (e) { + loadError = e + } + } + break + case 'arm64': + if (isMusl()) { + localFileExisted = existsSync( + join(__dirname, 'y-octo.linux-arm64-musl.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.linux-arm64-musl.node') + } else { + nativeBinding = require('@y-octo/node-linux-arm64-musl') + } + } catch (e) { + loadError = e + } + } else { + localFileExisted = existsSync( + join(__dirname, 'y-octo.linux-arm64-gnu.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.linux-arm64-gnu.node') + } else { + nativeBinding = require('@y-octo/node-linux-arm64-gnu') + } + } catch (e) { + loadError = e + } + } + break + case 'arm': + localFileExisted = existsSync( + join(__dirname, 'y-octo.linux-arm-gnueabihf.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./y-octo.linux-arm-gnueabihf.node') + } else { + nativeBinding = require('@y-octo/node-linux-arm-gnueabihf') + } + } catch (e) { + loadError = e + } + break + default: + throw new Error(`Unsupported architecture on Linux: ${arch}`) + } + break + default: + throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`) +} + +if (!nativeBinding) { + if (loadError) { + throw loadError + } + throw new Error(`Failed to load native binding`) +} + +const { Doc } = nativeBinding + +module.exports.Doc = Doc diff --git a/y-octo-node/package.json b/y-octo-node/package.json new file mode 100644 index 0000000..9cc1739 --- /dev/null +++ b/y-octo-node/package.json @@ -0,0 +1,42 @@ +{ + "name": "@y-octo/node", + "private": true, + "main": "index.js", + "types": "index.d.ts", + "napi": { + "name": "y-octo", + "triples": { + "additional": [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "aarch64-pc-windows-msvc" + ] + }, + "ts": { + "constEnum": false + } + }, + "license": "MIT", + "devDependencies": { + "@napi-rs/cli": "^2.16.2", + "@types/node": "^18.17.5", + "@types/uuid": "^9.0.2", + "cross-env": "^7.0.3", + "rxjs": "^7.8.1", + "ts-node": "^10.9.1", + "typescript": "^5.1.6", + "uuid": "^9.0.0" + }, + "engines": { + "node": ">= 10" + }, + "scripts": { + "artifacts": "napi artifacts", + "build": "napi build --platform --release --no-const-enum", + "build:debug": "napi build --platform --no-const-enum", + "universal": "napi universal", + "test": "cross-env TS_NODE_TRANSPILE_ONLY=1 TS_NODE_PROJECT=./tsconfig.json node --test --loader ts-node/esm --experimental-specifier-resolution=node ./__tests__/**/*.mts", + "version": "napi version" + }, + "version": "0.0.1" +} diff --git a/y-octo-node/src/doc.rs b/y-octo-node/src/doc.rs new file mode 100644 index 0000000..b83d776 --- /dev/null +++ b/y-octo-node/src/doc.rs @@ -0,0 +1,26 @@ +use super::*; +use y_octo::Doc as YDoc; + +#[napi] +pub struct Doc { + doc: YDoc, +} + +#[napi] +impl Doc { + #[napi(constructor)] + pub fn new(client_id: Option) -> Self { + Self { + doc: if let Some(client_id) = client_id { + YDoc::with_client(client_id as u64) + } else { + YDoc::default() + }, + } + } + + #[napi(getter)] + pub fn client_id(&self) -> i64 { + self.doc.client() as i64 + } +} diff --git a/y-octo-node/src/lib.rs b/y-octo-node/src/lib.rs index 7d12d9a..ad8113f 100644 --- a/y-octo-node/src/lib.rs +++ b/y-octo-node/src/lib.rs @@ -1,14 +1,3 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} +use napi_derive::napi; -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} +mod doc; diff --git a/yarn.lock b/yarn.lock index 684940b..5af4aef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,6 +5,48 @@ __metadata: version: 6 cacheKey: 8 +"@cspotcode/source-map-support@npm:^0.8.0": + version: 0.8.1 + resolution: "@cspotcode/source-map-support@npm:0.8.1" + dependencies: + "@jridgewell/trace-mapping": 0.3.9 + checksum: 5718f267085ed8edb3e7ef210137241775e607ee18b77d95aa5bd7514f47f5019aa2d82d96b3bf342ef7aa890a346fa1044532ff7cc3009e7d24fce3ce6200fa + languageName: node + linkType: hard + +"@jridgewell/resolve-uri@npm:^3.0.3": + version: 3.1.1 + resolution: "@jridgewell/resolve-uri@npm:3.1.1" + checksum: f5b441fe7900eab4f9155b3b93f9800a916257f4e8563afbcd3b5a5337b55e52bd8ae6735453b1b745457d9f6cdb16d74cd6220bbdd98cf153239e13f6cbb653 + languageName: node + linkType: hard + +"@jridgewell/sourcemap-codec@npm:^1.4.10": + version: 1.4.15 + resolution: "@jridgewell/sourcemap-codec@npm:1.4.15" + checksum: b881c7e503db3fc7f3c1f35a1dd2655a188cc51a3612d76efc8a6eb74728bef5606e6758ee77423e564092b4a518aba569bbb21c9bac5ab7a35b0c6ae7e344c8 + languageName: node + linkType: hard + +"@jridgewell/trace-mapping@npm:0.3.9": + version: 0.3.9 + resolution: "@jridgewell/trace-mapping@npm:0.3.9" + dependencies: + "@jridgewell/resolve-uri": ^3.0.3 + "@jridgewell/sourcemap-codec": ^1.4.10 + checksum: d89597752fd88d3f3480845691a05a44bd21faac18e2185b6f436c3b0fd0c5a859fbbd9aaa92050c4052caf325ad3e10e2e1d1b64327517471b7d51babc0ddef + languageName: node + linkType: hard + +"@napi-rs/cli@npm:^2.16.2": + version: 2.16.3 + resolution: "@napi-rs/cli@npm:2.16.3" + bin: + napi: scripts/index.js + checksum: 11f78b09548bc5c22df56e4fab4a87b68c2d3f2a18a55cf11e775e6a4cb5739ec0e21a14e614db2cdc2b9773cb42536c6bd00c3f85d3b461f956594f8a89ddcb + languageName: node + linkType: hard + "@taplo/cli@npm:^0.5.2": version: 0.5.2 resolution: "@taplo/cli@npm:0.5.2" @@ -14,6 +56,91 @@ __metadata: languageName: node linkType: hard +"@tsconfig/node10@npm:^1.0.7": + version: 1.0.9 + resolution: "@tsconfig/node10@npm:1.0.9" + checksum: a33ae4dc2a621c0678ac8ac4bceb8e512ae75dac65417a2ad9b022d9b5411e863c4c198b6ba9ef659e14b9fb609bbec680841a2e84c1172df7a5ffcf076539df + languageName: node + linkType: hard + +"@tsconfig/node12@npm:^1.0.7": + version: 1.0.11 + resolution: "@tsconfig/node12@npm:1.0.11" + checksum: 5ce29a41b13e7897a58b8e2df11269c5395999e588b9a467386f99d1d26f6c77d1af2719e407621412520ea30517d718d5192a32403b8dfcc163bf33e40a338a + languageName: node + linkType: hard + +"@tsconfig/node14@npm:^1.0.0": + version: 1.0.3 + resolution: "@tsconfig/node14@npm:1.0.3" + checksum: 19275fe80c4c8d0ad0abed6a96dbf00642e88b220b090418609c4376e1cef81bf16237bf170ad1b341452feddb8115d8dd2e5acdfdea1b27422071163dc9ba9d + languageName: node + linkType: hard + +"@tsconfig/node16@npm:^1.0.2": + version: 1.0.4 + resolution: "@tsconfig/node16@npm:1.0.4" + checksum: 202319785901f942a6e1e476b872d421baec20cf09f4b266a1854060efbf78cde16a4d256e8bc949d31e6cd9a90f1e8ef8fb06af96a65e98338a2b6b0de0a0ff + languageName: node + linkType: hard + +"@types/node@npm:^18.17.5": + version: 18.17.6 + resolution: "@types/node@npm:18.17.6" + checksum: 70bc92adde47d569f25c5ed40b55040cdf189518d6149e0c3041c6e60b1098cad9c48a856f0b7868ebd74d4098a0ca508b0ec4373dd96216eb8a387ee898e14c + languageName: node + linkType: hard + +"@types/uuid@npm:^9.0.2": + version: 9.0.2 + resolution: "@types/uuid@npm:9.0.2" + checksum: 1754bcf3444e1e3aeadd6e774fc328eb53bc956665e2e8fb6ec127aa8e1f43d9a224c3d22a9a6233dca8dd81a12dc7fed4d84b8876dd5ec82d40f574f7ff8b68 + languageName: node + linkType: hard + +"@y-octo/format@workspace:.": + version: 0.0.0-use.local + resolution: "@y-octo/format@workspace:." + dependencies: + "@taplo/cli": ^0.5.2 + husky: ^8.0.3 + lint-staged: ^14.0.0 + npm-run-all: ^4.1.5 + prettier: ^3.0.2 + languageName: unknown + linkType: soft + +"@y-octo/node@workspace:y-octo-node": + version: 0.0.0-use.local + resolution: "@y-octo/node@workspace:y-octo-node" + dependencies: + "@napi-rs/cli": ^2.16.2 + "@types/node": ^18.17.5 + "@types/uuid": ^9.0.2 + cross-env: ^7.0.3 + rxjs: ^7.8.1 + ts-node: ^10.9.1 + typescript: ^5.1.6 + uuid: ^9.0.0 + languageName: unknown + linkType: soft + +"acorn-walk@npm:^8.1.1": + version: 8.2.0 + resolution: "acorn-walk@npm:8.2.0" + checksum: 1715e76c01dd7b2d4ca472f9c58968516a4899378a63ad5b6c2d668bba8da21a71976c14ec5f5b75f887b6317c4ae0b897ab141c831d741dc76024d8745f1ad1 + languageName: node + linkType: hard + +"acorn@npm:^8.4.1": + version: 8.10.0 + resolution: "acorn@npm:8.10.0" + bin: + acorn: bin/acorn + checksum: 538ba38af0cc9e5ef983aee196c4b8b4d87c0c94532334fa7e065b2c8a1f85863467bb774231aae91613fcda5e68740c15d97b1967ae3394d20faddddd8af61d + languageName: node + linkType: hard + "ansi-escapes@npm:^5.0.0": version: 5.0.0 resolution: "ansi-escapes@npm:5.0.0" @@ -46,6 +173,13 @@ __metadata: languageName: node linkType: hard +"arg@npm:^4.1.0": + version: 4.1.3 + resolution: "arg@npm:4.1.3" + checksum: 544af8dd3f60546d3e4aff084d451b96961d2267d668670199692f8d054f0415d86fc5497d0e641e91546f0aa920e7c29e5250e99fc89f5552a34b5d93b77f43 + languageName: node + linkType: hard + "array-buffer-byte-length@npm:^1.0.0": version: 1.0.0 resolution: "array-buffer-byte-length@npm:1.0.0" @@ -187,6 +321,25 @@ __metadata: languageName: node linkType: hard +"create-require@npm:^1.1.0": + version: 1.1.1 + resolution: "create-require@npm:1.1.1" + checksum: a9a1503d4390d8b59ad86f4607de7870b39cad43d929813599a23714831e81c520bddf61bcdd1f8e30f05fd3a2b71ae8538e946eb2786dc65c2bbc520f692eff + languageName: node + linkType: hard + +"cross-env@npm:^7.0.3": + version: 7.0.3 + resolution: "cross-env@npm:7.0.3" + dependencies: + cross-spawn: ^7.0.1 + bin: + cross-env: src/bin/cross-env.js + cross-env-shell: src/bin/cross-env-shell.js + checksum: 26f2f3ea2ab32617f57effb70d329c2070d2f5630adc800985d8b30b56e8bf7f5f439dd3a0358b79cee6f930afc23cf8e23515f17ccfb30092c6b62c6b630a79 + languageName: node + linkType: hard + "cross-spawn@npm:^6.0.5": version: 6.0.5 resolution: "cross-spawn@npm:6.0.5" @@ -200,7 +353,7 @@ __metadata: languageName: node linkType: hard -"cross-spawn@npm:^7.0.3": +"cross-spawn@npm:^7.0.1, cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" dependencies: @@ -233,6 +386,13 @@ __metadata: languageName: node linkType: hard +"diff@npm:^4.0.1": + version: 4.0.2 + resolution: "diff@npm:4.0.2" + checksum: f2c09b0ce4e6b301c221addd83bf3f454c0bc00caa3dd837cf6c127d6edf7223aa2bbe3b688feea110b7f262adbfc845b757c44c8a9f8c0c5b15d8fa9ce9d20d + languageName: node + linkType: hard + "eastasianwidth@npm:^0.2.0": version: 0.2.0 resolution: "eastasianwidth@npm:0.2.0" @@ -789,6 +949,13 @@ __metadata: languageName: node linkType: hard +"make-error@npm:^1.1.1": + version: 1.3.6 + resolution: "make-error@npm:1.3.6" + checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 + languageName: node + linkType: hard + "memorystream@npm:^0.3.1": version: 0.3.1 resolution: "memorystream@npm:0.3.1" @@ -1089,6 +1256,15 @@ __metadata: languageName: node linkType: hard +"rxjs@npm:^7.8.1": + version: 7.8.1 + resolution: "rxjs@npm:7.8.1" + dependencies: + tslib: ^2.1.0 + checksum: de4b53db1063e618ec2eca0f7965d9137cabe98cf6be9272efe6c86b47c17b987383df8574861bcced18ebd590764125a901d5506082be84a8b8e364bf05f119 + languageName: node + linkType: hard + "safe-array-concat@npm:^1.0.0": version: 1.0.0 resolution: "safe-array-concat@npm:1.0.0" @@ -1332,6 +1508,51 @@ __metadata: languageName: node linkType: hard +"ts-node@npm:^10.9.1": + version: 10.9.1 + resolution: "ts-node@npm:10.9.1" + dependencies: + "@cspotcode/source-map-support": ^0.8.0 + "@tsconfig/node10": ^1.0.7 + "@tsconfig/node12": ^1.0.7 + "@tsconfig/node14": ^1.0.0 + "@tsconfig/node16": ^1.0.2 + acorn: ^8.4.1 + acorn-walk: ^8.1.1 + arg: ^4.1.0 + create-require: ^1.1.0 + diff: ^4.0.1 + make-error: ^1.1.1 + v8-compile-cache-lib: ^3.0.1 + yn: 3.1.1 + peerDependencies: + "@swc/core": ">=1.2.50" + "@swc/wasm": ">=1.2.50" + "@types/node": "*" + typescript: ">=2.7" + peerDependenciesMeta: + "@swc/core": + optional: true + "@swc/wasm": + optional: true + bin: + ts-node: dist/bin.js + ts-node-cwd: dist/bin-cwd.js + ts-node-esm: dist/bin-esm.js + ts-node-script: dist/bin-script.js + ts-node-transpile-only: dist/bin-transpile.js + ts-script: dist/bin-script-deprecated.js + checksum: 090adff1302ab20bd3486e6b4799e90f97726ed39e02b39e566f8ab674fd5bd5f727f43615debbfc580d33c6d9d1c6b1b3ce7d8e3cca3e20530a145ffa232c35 + languageName: node + linkType: hard + +"tslib@npm:^2.1.0": + version: 2.6.2 + resolution: "tslib@npm:2.6.2" + checksum: 329ea56123005922f39642318e3d1f0f8265d1e7fcb92c633e0809521da75eeaca28d2cf96d7248229deb40e5c19adf408259f4b9640afd20d13aecc1430f3ad + languageName: node + linkType: hard + "type-fest@npm:^1.0.2": version: 1.4.0 resolution: "type-fest@npm:1.4.0" @@ -1386,6 +1607,26 @@ __metadata: languageName: node linkType: hard +"typescript@npm:^5.1.6": + version: 5.1.6 + resolution: "typescript@npm:5.1.6" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: b2f2c35096035fe1f5facd1e38922ccb8558996331405eb00a5111cc948b2e733163cc22fab5db46992aba7dd520fff637f2c1df4996ff0e134e77d3249a7350 + languageName: node + linkType: hard + +"typescript@patch:typescript@^5.1.6#~builtin": + version: 5.1.6 + resolution: "typescript@patch:typescript@npm%3A5.1.6#~builtin::version=5.1.6&hash=5da071" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: f53bfe97f7c8b2b6d23cf572750d4e7d1e0c5fff1c36d859d0ec84556a827b8785077bc27676bf7e71fae538e517c3ecc0f37e7f593be913d884805d931bc8be + languageName: node + linkType: hard + "unbox-primitive@npm:^1.0.2": version: 1.0.2 resolution: "unbox-primitive@npm:1.0.2" @@ -1398,6 +1639,22 @@ __metadata: languageName: node linkType: hard +"uuid@npm:^9.0.0": + version: 9.0.0 + resolution: "uuid@npm:9.0.0" + bin: + uuid: dist/bin/uuid + checksum: 8dd2c83c43ddc7e1c71e36b60aea40030a6505139af6bee0f382ebcd1a56f6cd3028f7f06ffb07f8cf6ced320b76aea275284b224b002b289f89fe89c389b028 + languageName: node + linkType: hard + +"v8-compile-cache-lib@npm:^3.0.1": + version: 3.0.1 + resolution: "v8-compile-cache-lib@npm:3.0.1" + checksum: 78089ad549e21bcdbfca10c08850022b22024cdcc2da9b168bcf5a73a6ed7bf01a9cebb9eac28e03cd23a684d81e0502797e88f3ccd27a32aeab1cfc44c39da0 + languageName: node + linkType: hard + "validate-npm-package-license@npm:^3.0.1": version: 3.0.4 resolution: "validate-npm-package-license@npm:3.0.4" @@ -1467,21 +1724,16 @@ __metadata: languageName: node linkType: hard -"y-octo@workspace:.": - version: 0.0.0-use.local - resolution: "y-octo@workspace:." - dependencies: - "@taplo/cli": ^0.5.2 - husky: ^8.0.3 - lint-staged: ^14.0.0 - npm-run-all: ^4.1.5 - prettier: ^3.0.2 - languageName: unknown - linkType: soft - "yaml@npm:2.3.1": version: 2.3.1 resolution: "yaml@npm:2.3.1" checksum: 2c7bc9a7cd4c9f40d3b0b0a98e370781b68b8b7c4515720869aced2b00d92f5da1762b4ffa947f9e795d6cd6b19f410bd4d15fdd38aca7bd96df59bd9486fb54 languageName: node linkType: hard + +"yn@npm:3.1.1": + version: 3.1.1 + resolution: "yn@npm:3.1.1" + checksum: 2c487b0e149e746ef48cda9f8bad10fc83693cd69d7f9dcd8be4214e985de33a29c9e24f3c0d6bcf2288427040a8947406ab27f7af67ee9456e6b84854f02dd6 + languageName: node + linkType: hard From 191c0feddda432f352420fcaadbcb0db88d5295e Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 19:05:43 +0800 Subject: [PATCH 04/14] chore: ignore auto generate files lint in prettier --- .prettierignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.prettierignore b/.prettierignore index a9b00ce..37b3d23 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,3 +4,5 @@ target y-octo/README.md .cargo vendor +index.d.ts +index.js \ No newline at end of file From 123d31d90ded64c83d58e091571fcdef2a2c7639 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 19:26:34 +0800 Subject: [PATCH 05/14] test: add test for node binding --- tsconfig.json | 73 ++++++++++++++++++++++++++++++++++ y-octo-node/package.json | 3 +- y-octo-node/tests/doc.spec.mts | 22 ++++++++++ y-octo-node/tsconfig.json | 13 ++++++ 4 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 tsconfig.json create mode 100644 y-octo-node/tests/doc.spec.mts create mode 100644 y-octo-node/tsconfig.json diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..c014b81 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,73 @@ +{ + "compilerOptions": { + "verbatimModuleSyntax": true, + // Classification follows https://www.typescriptlang.org/tsconfig + + // Type Checking + "strict": true, + // exactOptionalPropertyTypes: false, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitOverride": true, + "noImplicitReturns": true, + "noImplicitThis": true, + // "noUnusedLocals": true, + // "noUnusedParameters": true, + // noPropertyAccessFromIndexSignature: false, + // noUncheckedIndexedAccess: false, + "useUnknownInCatchVariables": true, + + // Modules + "module": "ESNext", + "moduleResolution": "bundler", + "resolveJsonModule": true, + // Emit + "declaration": true, + "declarationMap": true, + "sourceMap": true, + // skip type emit for @internal types + // "stripInternal": true, + + // JavaScript Support + "allowJs": false, + "checkJs": false, + + // Interop Constraints + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true, + "isolatedModules": true, + + // Language and Environment + "jsx": "preserve", + "jsxImportSource": "@emotion/react", + "lib": ["ESNext", "DOM"], + "target": "ES2022", + "useDefineForClassFields": false, + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + + // Projects + "composite": true, + "incremental": true, + + // Completeness + "skipLibCheck": true, // skip all type checks for .d.ts files + "paths": { + "@y-octo/node/*": ["./y-octo-node/src/*"] + } + }, + "include": [], + "references": [ + { + "path": "./y-octo-node" + } + ], + "files": [], + "exclude": ["node_modules", "target", "lib", "test-results"], + "ts-node": { + "compilerOptions": { + "module": "ESNext", + "moduleResolution": "Node" + } + } +} diff --git a/y-octo-node/package.json b/y-octo-node/package.json index 9cc1739..410322c 100644 --- a/y-octo-node/package.json +++ b/y-octo-node/package.json @@ -22,7 +22,6 @@ "@types/node": "^18.17.5", "@types/uuid": "^9.0.2", "cross-env": "^7.0.3", - "rxjs": "^7.8.1", "ts-node": "^10.9.1", "typescript": "^5.1.6", "uuid": "^9.0.0" @@ -35,7 +34,7 @@ "build": "napi build --platform --release --no-const-enum", "build:debug": "napi build --platform --no-const-enum", "universal": "napi universal", - "test": "cross-env TS_NODE_TRANSPILE_ONLY=1 TS_NODE_PROJECT=./tsconfig.json node --test --loader ts-node/esm --experimental-specifier-resolution=node ./__tests__/**/*.mts", + "test": "cross-env TS_NODE_TRANSPILE_ONLY=1 TS_NODE_PROJECT=./tsconfig.json node --test --loader ts-node/esm --experimental-specifier-resolution=node ./tests/**/*.mts", "version": "napi version" }, "version": "0.0.1" diff --git a/y-octo-node/tests/doc.spec.mts b/y-octo-node/tests/doc.spec.mts new file mode 100644 index 0000000..9ff18cb --- /dev/null +++ b/y-octo-node/tests/doc.spec.mts @@ -0,0 +1,22 @@ +import { equal } from "node:assert"; +import { test } from "node:test"; + +import { Doc } from "../index"; + +test("y-octo doc", { concurrency: false }, async (t) => { + let client_id: number; + let doc: Doc | null; + t.beforeEach(async () => { + client_id = (Math.random() * 100000) | 1; + doc = new Doc(client_id); + }); + + t.afterEach(async () => { + client_id = -1; + doc = null; + }); + + await t.test("doc id should be set", () => { + equal(doc?.clientId, client_id); + }); +}); diff --git a/y-octo-node/tsconfig.json b/y-octo-node/tsconfig.json new file mode 100644 index 0000000..dd11afc --- /dev/null +++ b/y-octo-node/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "noEmit": false, + "outDir": "lib", + "composite": true + }, + "include": ["index.d.ts", "tests/**/*.mts"], + "ts-node": { + "esm": true, + "experimentalSpecifierResolution": "node" + } +} From 457795102ddaa53ae2cc866e7e79a16bf64c2103 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 19:28:18 +0800 Subject: [PATCH 06/14] ci: extract rust toolchain action --- .github/actions/setup-rust/action.yml | 24 +++++++++++++++++++++ .github/workflows/{yocto.yml => y-octo.yml} | 5 +++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .github/actions/setup-rust/action.yml rename .github/workflows/{yocto.yml => y-octo.yml} (98%) diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.yml new file mode 100644 index 0000000..26f6d00 --- /dev/null +++ b/.github/actions/setup-rust/action.yml @@ -0,0 +1,24 @@ +name: "Y-Octo Rust setup" +description: "Rust setup, including cache configuration" +inputs: + components: + description: "Cargo components" + required: false + target: + description: "Cargo target" + required: true + toolchain: + description: "Rustup toolchain" + required: false + default: "stable" + +runs: + using: "composite" + steps: + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ inputs.toolchain }} + targets: ${{ inputs.target }} + components: ${{ inputs.components }} + - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/yocto.yml b/.github/workflows/y-octo.yml similarity index 98% rename from .github/workflows/yocto.yml rename to .github/workflows/y-octo.yml index 17b20ca..582cb58 100644 --- a/.github/workflows/yocto.yml +++ b/.github/workflows/y-octo.yml @@ -147,11 +147,12 @@ jobs: MIRIFLAGS: -Zmiri-backtrace=full -Zmiri-tree-borrows steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable + + - name: Setup Rust + uses: ./.github/actions/setup-rust with: toolchain: nightly-2023-08-19 components: miri - - uses: Swatinem/rust-cache@v2 - name: Install latest nextest release uses: taiki-e/install-action@nextest From d5347f0c81a2d279eb0134790d29c57b98434a91 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 19:31:57 +0800 Subject: [PATCH 07/14] feat: extract more actions --- .github/workflows/y-octo.yml | 27 +++++++++++++-------------- yarn.lock | 17 ----------------- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/.github/workflows/y-octo.yml b/.github/workflows/y-octo.yml index 582cb58..a1b9722 100644 --- a/.github/workflows/y-octo.yml +++ b/.github/workflows/y-octo.yml @@ -28,14 +28,12 @@ jobs: with: fetch-depth: 0 - - name: Install Rust - uses: dtolnay/rust-toolchain@master + - name: Setup Rust + uses: ./.github/actions/setup-rust with: toolchain: nightly-2023-08-19 components: clippy, rustfmt - - uses: Swatinem/rust-cache@v2 - - name: Install Node.js uses: actions/setup-node@v3 with: @@ -79,11 +77,11 @@ jobs: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable + + - name: Setup Rust + uses: ./.github/actions/setup-rust with: components: llvm-tools-preview - - uses: Swatinem/rust-cache@v2 - - name: Install latest nextest release uses: taiki-e/install-action@nextest - name: Install cargo-llvm-cov @@ -107,10 +105,11 @@ jobs: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable + + - name: Setup Rust + uses: ./.github/actions/setup-rust with: toolchain: nightly-2023-08-19 - - uses: Swatinem/rust-cache@v2 - name: Memory Check run: | @@ -127,9 +126,9 @@ jobs: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 + - name: Setup Rust + uses: ./.github/actions/setup-rust - name: Install latest nextest release uses: taiki-e/install-action@nextest @@ -153,7 +152,6 @@ jobs: with: toolchain: nightly-2023-08-19 components: miri - - name: Install latest nextest release uses: taiki-e/install-action@nextest @@ -170,10 +168,11 @@ jobs: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@master + + - name: Setup Rust + uses: ./.github/actions/setup-rust with: toolchain: nightly-2023-08-19 - - uses: Swatinem/rust-cache@v2 - name: fuzzing working-directory: ./y-octo diff --git a/yarn.lock b/yarn.lock index 5af4aef..6f6b3e9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -118,7 +118,6 @@ __metadata: "@types/node": ^18.17.5 "@types/uuid": ^9.0.2 cross-env: ^7.0.3 - rxjs: ^7.8.1 ts-node: ^10.9.1 typescript: ^5.1.6 uuid: ^9.0.0 @@ -1256,15 +1255,6 @@ __metadata: languageName: node linkType: hard -"rxjs@npm:^7.8.1": - version: 7.8.1 - resolution: "rxjs@npm:7.8.1" - dependencies: - tslib: ^2.1.0 - checksum: de4b53db1063e618ec2eca0f7965d9137cabe98cf6be9272efe6c86b47c17b987383df8574861bcced18ebd590764125a901d5506082be84a8b8e364bf05f119 - languageName: node - linkType: hard - "safe-array-concat@npm:^1.0.0": version: 1.0.0 resolution: "safe-array-concat@npm:1.0.0" @@ -1546,13 +1536,6 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^2.1.0": - version: 2.6.2 - resolution: "tslib@npm:2.6.2" - checksum: 329ea56123005922f39642318e3d1f0f8265d1e7fcb92c633e0809521da75eeaca28d2cf96d7248229deb40e5c19adf408259f4b9640afd20d13aecc1430f3ad - languageName: node - linkType: hard - "type-fest@npm:^1.0.2": version: 1.4.0 resolution: "type-fest@npm:1.4.0" From b7e0ffe941776b2320be13e9b0072371f87d5c57 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 20:22:10 +0800 Subject: [PATCH 08/14] feat: add test workflow for node --- .github/actions/setup-node/action.yml | 44 ++++++++++++++++ .github/workflows/y-octo-node.yml | 62 ++++++++++++++++++++++ package.json | 5 +- y-octo-node/package.json | 34 ++++++++++-- y-octo-node/scripts/run-test.mts | 74 +++++++++++++++++++++++++++ y-octo-node/src/doc.rs | 3 +- yarn.lock | 62 ++++++++++++++++------ 7 files changed, 263 insertions(+), 21 deletions(-) create mode 100644 .github/actions/setup-node/action.yml create mode 100644 .github/workflows/y-octo-node.yml create mode 100755 y-octo-node/scripts/run-test.mts diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml new file mode 100644 index 0000000..8ab046a --- /dev/null +++ b/.github/actions/setup-node/action.yml @@ -0,0 +1,44 @@ +name: "Y-Octo Node.js Setup" +description: "Node.js setup for CI, including cache configuration" +inputs: + extra-flags: + description: "Extra flags to pass to the yarn install." + required: false + default: "--immutable --inline-builds" + package-install: + description: "Run the install step." + required: false + default: "true" + hard-link-nm: + description: "set nmMode to hardlinks-local in .yarnrc.yml" + required: false + default: "true" + +runs: + using: "composite" + steps: + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version-file: ".nvmrc" + cache: "yarn" + + - name: Set nmMode + if: ${{ inputs.hard-link-nm == 'true' }} + shell: bash + run: yarn config set nmMode hardlinks-local + + - name: yarn install + if: ${{ inputs.package-install == 'true' }} + continue-on-error: true + shell: bash + run: yarn install ${{ inputs.extra-flags }} + env: + HUSKY: "0" + + - name: yarn install (try again) + if: ${{ steps.install.outcome == 'failure' }} + shell: bash + run: yarn install ${{ inputs.extra-flags }} + env: + HUSKY: "0" diff --git a/.github/workflows/y-octo-node.yml b/.github/workflows/y-octo-node.yml new file mode 100644 index 0000000..f68ce23 --- /dev/null +++ b/.github/workflows/y-octo-node.yml @@ -0,0 +1,62 @@ +name: Build & Test + +on: + workflow_dispatch: + push: + branches: [main] + pull_request: + branches: [main] + +env: + DEBUG: napi:* + COVERAGE: true + +jobs: + build-node: + name: Build Storage + runs-on: ubuntu-latest + env: + RUSTFLAGS: "-C debuginfo=1" + environment: development + + steps: + - uses: actions/checkout@v3 + - name: Setup Node.js + uses: ./.github/actions/setup-node + - name: Setup Rust + uses: ./.github/actions/setup-rust + with: + target: "x86_64-unknown-linux-gnu" + - name: Build node binding + run: yarn build:node + - name: Upload y-octo.node + uses: actions/upload-artifact@v3 + with: + name: y-octo.node + path: ./y-octo-node/y-octo.node + if-no-files-found: error + + node-binding-test: + name: Node Binding Test + runs-on: ubuntu-latest + needs: build-node + steps: + - uses: actions/checkout@v3 + - name: Setup Node.js + uses: ./.github/actions/setup-node + - name: Download y-octo.node + uses: actions/download-artifact@v3 + with: + name: y-octo.node + path: ./y-octo-node + - name: Run node binding tests + run: yarn test:node:coverage + working-directory: y-octo-node + - name: Upload server test coverage results + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./y-octo-node/.coverage/lcov.info + flags: node-binding-test + name: y-octo + fail_ci_if_error: false diff --git a/package.json b/package.json index 014d7f0..bf1bbd7 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@y-octo/format", + "name": "@y-octo/cli", "version": "0.0.0", "packageManager": "yarn@3.6.2", "license": "MIT", @@ -11,6 +11,9 @@ "node": ">=18.16.1 <19.0.0" }, "scripts": { + "build:node": "yarn workspace @y-octo/node build", + "test:node": "yarn workspace @y-octo/node test", + "test:node:coverage": "yarn workspace @y-octo/node test:coverage", "format": "run-p format:toml format:prettier format:rs", "format:toml": "taplo format", "format:prettier": "prettier --write .", diff --git a/y-octo-node/package.json b/y-octo-node/package.json index 410322c..cc04135 100644 --- a/y-octo-node/package.json +++ b/y-octo-node/package.json @@ -20,8 +20,9 @@ "devDependencies": { "@napi-rs/cli": "^2.16.2", "@types/node": "^18.17.5", + "@types/prompts": "^2.4.4", "@types/uuid": "^9.0.2", - "cross-env": "^7.0.3", + "prompts": "^2.4.2", "ts-node": "^10.9.1", "typescript": "^5.1.6", "uuid": "^9.0.0" @@ -34,8 +35,35 @@ "build": "napi build --platform --release --no-const-enum", "build:debug": "napi build --platform --no-const-enum", "universal": "napi universal", - "test": "cross-env TS_NODE_TRANSPILE_ONLY=1 TS_NODE_PROJECT=./tsconfig.json node --test --loader ts-node/esm --experimental-specifier-resolution=node ./tests/**/*.mts", + "test": "yarn exec ts-node-esm ./scripts/run-test.mts all", + "test:watch": "yarn exec ts-node-esm ./scripts/run-test.ts all --watch", + "test:coverage": "c8 yarn exec ts-node-esm ./scripts/run-test.ts all", "version": "napi version" }, - "version": "0.0.1" + "version": "0.0.1", + "sharedConfig": { + "nodeArgs": [ + "--loader", + "ts-node/esm", + "--es-module-specifier-resolution=node" + ], + "env": { + "TS_NODE_TRANSPILE_ONLY": "1", + "TS_NODE_PROJECT": "./tsconfig.json", + "NODE_ENV": "development", + "DEBUG": "napi:*" + } + }, + "c8": { + "reporter": [ + "text", + "lcov" + ], + "report-dir": ".coverage", + "exclude": [ + "scripts", + "node_modules", + "**/*.spec.ts" + ] + } } diff --git a/y-octo-node/scripts/run-test.mts b/y-octo-node/scripts/run-test.mts new file mode 100755 index 0000000..8a15acd --- /dev/null +++ b/y-octo-node/scripts/run-test.mts @@ -0,0 +1,74 @@ +#!/usr/bin/env ts-node-esm +import { resolve } from "node:path"; + +import prompts from "prompts"; +import { spawn } from "child_process"; +import { readdir } from "fs/promises"; +import * as process from "process"; +import { fileURLToPath } from "url"; + +import pkg from "../package.json" assert { type: "json" }; +const root = fileURLToPath(new URL("..", import.meta.url)); +const testDir = resolve(root, "tests"); +const files = await readdir(testDir); + +const watchMode = process.argv.includes("--watch"); + +const sharedArgs = [ + ...pkg.sharedConfig.nodeArgs, + "--test", + watchMode ? "--watch" : "", +]; + +const env = { + ...pkg.sharedConfig.env, + PATH: process.env.PATH, + NODE_ENV: "test", + NODE_NO_WARNINGS: "1", +}; + +if (process.argv[2] === "all") { + const cp = spawn("node", [...sharedArgs, resolve(testDir, "*")], { + cwd: root, + env, + stdio: "inherit", + shell: true, + }); + cp.on("exit", (code) => { + process.exit(code ?? 0); + }); +} else { + const result = await prompts([ + { + type: "select", + name: "file", + message: "Select a file to run", + choices: files.map((file) => ({ + title: file, + value: file, + })), + initial: 1, + }, + ]); + + const target = resolve(testDir, result.file); + + const cp = spawn( + "node", + [ + ...sharedArgs, + "--test-reporter=spec", + "--test-reporter-destination=stdout", + target, + ], + { + cwd: root, + env, + stdio: "inherit", + shell: true, + }, + ); + cp.on("exit", (code) => { + process.exit(code ?? 0); + }); +} diff --git a/y-octo-node/src/doc.rs b/y-octo-node/src/doc.rs index b83d776..54bf740 100644 --- a/y-octo-node/src/doc.rs +++ b/y-octo-node/src/doc.rs @@ -1,6 +1,7 @@ -use super::*; use y_octo::Doc as YDoc; +use super::*; + #[napi] pub struct Doc { doc: YDoc, diff --git a/yarn.lock b/yarn.lock index 6f6b3e9..d584be2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -84,6 +84,13 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:*": + version: 20.5.1 + resolution: "@types/node@npm:20.5.1" + checksum: 3dbe611cd67afa987102c8558ee70f848949c5dcfee5f60abc073e55c0d7b048e391bf06bb1e0dc052cb7210ca97136ac496cbaf6e89123c989de6bd125fde82 + languageName: node + linkType: hard + "@types/node@npm:^18.17.5": version: 18.17.6 resolution: "@types/node@npm:18.17.6" @@ -91,6 +98,16 @@ __metadata: languageName: node linkType: hard +"@types/prompts@npm:^2.4.4": + version: 2.4.4 + resolution: "@types/prompts@npm:2.4.4" + dependencies: + "@types/node": "*" + kleur: ^3.0.3 + checksum: fa8d9a6f63f5e7f4a5b9bd4d40527ca4b8c8c6a63bf0864bf72ea85706a9e1b292d73c8c9a3b7423fb80a5d3e7d563d0069d6644384438c1251adbd9efc03a12 + languageName: node + linkType: hard + "@types/uuid@npm:^9.0.2": version: 9.0.2 resolution: "@types/uuid@npm:9.0.2" @@ -98,9 +115,9 @@ __metadata: languageName: node linkType: hard -"@y-octo/format@workspace:.": +"@y-octo/cli@workspace:.": version: 0.0.0-use.local - resolution: "@y-octo/format@workspace:." + resolution: "@y-octo/cli@workspace:." dependencies: "@taplo/cli": ^0.5.2 husky: ^8.0.3 @@ -116,8 +133,9 @@ __metadata: dependencies: "@napi-rs/cli": ^2.16.2 "@types/node": ^18.17.5 + "@types/prompts": ^2.4.4 "@types/uuid": ^9.0.2 - cross-env: ^7.0.3 + prompts: ^2.4.2 ts-node: ^10.9.1 typescript: ^5.1.6 uuid: ^9.0.0 @@ -327,18 +345,6 @@ __metadata: languageName: node linkType: hard -"cross-env@npm:^7.0.3": - version: 7.0.3 - resolution: "cross-env@npm:7.0.3" - dependencies: - cross-spawn: ^7.0.1 - bin: - cross-env: src/bin/cross-env.js - cross-env-shell: src/bin/cross-env-shell.js - checksum: 26f2f3ea2ab32617f57effb70d329c2070d2f5630adc800985d8b30b56e8bf7f5f439dd3a0358b79cee6f930afc23cf8e23515f17ccfb30092c6b62c6b630a79 - languageName: node - linkType: hard - "cross-spawn@npm:^6.0.5": version: 6.0.5 resolution: "cross-spawn@npm:6.0.5" @@ -352,7 +358,7 @@ __metadata: languageName: node linkType: hard -"cross-spawn@npm:^7.0.1, cross-spawn@npm:^7.0.3": +"cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" dependencies: @@ -877,6 +883,13 @@ __metadata: languageName: node linkType: hard +"kleur@npm:^3.0.3": + version: 3.0.3 + resolution: "kleur@npm:3.0.3" + checksum: df82cd1e172f957bae9c536286265a5cdbd5eeca487cb0a3b2a7b41ef959fc61f8e7c0e9aeea9c114ccf2c166b6a8dd45a46fd619c1c569d210ecd2765ad5169 + languageName: node + linkType: hard + "lilconfig@npm:2.1.0": version: 2.1.0 resolution: "lilconfig@npm:2.1.0" @@ -1190,6 +1203,16 @@ __metadata: languageName: node linkType: hard +"prompts@npm:^2.4.2": + version: 2.4.2 + resolution: "prompts@npm:2.4.2" + dependencies: + kleur: ^3.0.3 + sisteransi: ^1.0.5 + checksum: d8fd1fe63820be2412c13bfc5d0a01909acc1f0367e32396962e737cb2fc52d004f3302475d5ce7d18a1e8a79985f93ff04ee03007d091029c3f9104bffc007d + languageName: node + linkType: hard + "read-pkg@npm:^3.0.0": version: 3.0.0 resolution: "read-pkg@npm:3.0.0" @@ -1344,6 +1367,13 @@ __metadata: languageName: node linkType: hard +"sisteransi@npm:^1.0.5": + version: 1.0.5 + resolution: "sisteransi@npm:1.0.5" + checksum: aba6438f46d2bfcef94cf112c835ab395172c75f67453fe05c340c770d3c402363018ae1ab4172a1026a90c47eaccf3af7b6ff6fa749a680c2929bd7fa2b37a4 + languageName: node + linkType: hard + "slice-ansi@npm:^5.0.0": version: 5.0.0 resolution: "slice-ansi@npm:5.0.0" From 8be744b765dcaafb398b89ed53ac858bffd41d0f Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 20:24:15 +0800 Subject: [PATCH 09/14] ci: fix coverage --- y-octo-node/.gitignore | 3 +- y-octo-node/package.json | 3 +- yarn.lock | 449 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 449 insertions(+), 6 deletions(-) diff --git a/y-octo-node/.gitignore b/y-octo-node/.gitignore index d849c50..28f2c68 100644 --- a/y-octo-node/.gitignore +++ b/y-octo-node/.gitignore @@ -1 +1,2 @@ -*.node \ No newline at end of file +*.node +.coverage \ No newline at end of file diff --git a/y-octo-node/package.json b/y-octo-node/package.json index cc04135..a966fb9 100644 --- a/y-octo-node/package.json +++ b/y-octo-node/package.json @@ -22,6 +22,7 @@ "@types/node": "^18.17.5", "@types/prompts": "^2.4.4", "@types/uuid": "^9.0.2", + "c8": "^8.0.1", "prompts": "^2.4.2", "ts-node": "^10.9.1", "typescript": "^5.1.6", @@ -37,7 +38,7 @@ "universal": "napi universal", "test": "yarn exec ts-node-esm ./scripts/run-test.mts all", "test:watch": "yarn exec ts-node-esm ./scripts/run-test.ts all --watch", - "test:coverage": "c8 yarn exec ts-node-esm ./scripts/run-test.ts all", + "test:coverage": "c8 yarn exec ts-node-esm ./scripts/run-test.mts all", "version": "napi version" }, "version": "0.0.1", diff --git a/yarn.lock b/yarn.lock index d584be2..647cc9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,6 +5,13 @@ __metadata: version: 6 cacheKey: 8 +"@bcoe/v8-coverage@npm:^0.2.3": + version: 0.2.3 + resolution: "@bcoe/v8-coverage@npm:0.2.3" + checksum: 850f9305536d0f2bd13e9e0881cb5f02e4f93fad1189f7b2d4bebf694e3206924eadee1068130d43c11b750efcc9405f88a8e42ef098b6d75239c0f047de1a27 + languageName: node + linkType: hard + "@cspotcode/source-map-support@npm:^0.8.0": version: 0.8.1 resolution: "@cspotcode/source-map-support@npm:0.8.1" @@ -14,14 +21,21 @@ __metadata: languageName: node linkType: hard -"@jridgewell/resolve-uri@npm:^3.0.3": +"@istanbuljs/schema@npm:^0.1.2, @istanbuljs/schema@npm:^0.1.3": + version: 0.1.3 + resolution: "@istanbuljs/schema@npm:0.1.3" + checksum: 5282759d961d61350f33d9118d16bcaed914ebf8061a52f4fa474b2cb08720c9c81d165e13b82f2e5a8a212cc5af482f0c6fc1ac27b9e067e5394c9a6ed186c9 + languageName: node + linkType: hard + +"@jridgewell/resolve-uri@npm:^3.0.3, @jridgewell/resolve-uri@npm:^3.1.0": version: 3.1.1 resolution: "@jridgewell/resolve-uri@npm:3.1.1" checksum: f5b441fe7900eab4f9155b3b93f9800a916257f4e8563afbcd3b5a5337b55e52bd8ae6735453b1b745457d9f6cdb16d74cd6220bbdd98cf153239e13f6cbb653 languageName: node linkType: hard -"@jridgewell/sourcemap-codec@npm:^1.4.10": +"@jridgewell/sourcemap-codec@npm:^1.4.10, @jridgewell/sourcemap-codec@npm:^1.4.14": version: 1.4.15 resolution: "@jridgewell/sourcemap-codec@npm:1.4.15" checksum: b881c7e503db3fc7f3c1f35a1dd2655a188cc51a3612d76efc8a6eb74728bef5606e6758ee77423e564092b4a518aba569bbb21c9bac5ab7a35b0c6ae7e344c8 @@ -38,6 +52,16 @@ __metadata: languageName: node linkType: hard +"@jridgewell/trace-mapping@npm:^0.3.12": + version: 0.3.19 + resolution: "@jridgewell/trace-mapping@npm:0.3.19" + dependencies: + "@jridgewell/resolve-uri": ^3.1.0 + "@jridgewell/sourcemap-codec": ^1.4.14 + checksum: 956a6f0f6fec060fb48c6bf1f5ec2064e13cd38c8be3873877d4b92b4a27ba58289a34071752671262a3e3c202abcc3fa2aac64d8447b4b0fa1ba3c9047f1c20 + languageName: node + linkType: hard + "@napi-rs/cli@npm:^2.16.2": version: 2.16.3 resolution: "@napi-rs/cli@npm:2.16.3" @@ -84,6 +108,13 @@ __metadata: languageName: node linkType: hard +"@types/istanbul-lib-coverage@npm:^2.0.1": + version: 2.0.4 + resolution: "@types/istanbul-lib-coverage@npm:2.0.4" + checksum: a25d7589ee65c94d31464c16b72a9dc81dfa0bea9d3e105ae03882d616e2a0712a9c101a599ec482d297c3591e16336962878cb3eb1a0a62d5b76d277a890ce7 + languageName: node + linkType: hard + "@types/node@npm:*": version: 20.5.1 resolution: "@types/node@npm:20.5.1" @@ -135,6 +166,7 @@ __metadata: "@types/node": ^18.17.5 "@types/prompts": ^2.4.4 "@types/uuid": ^9.0.2 + c8: ^8.0.1 prompts: ^2.4.2 ts-node: ^10.9.1 typescript: ^5.1.6 @@ -167,6 +199,13 @@ __metadata: languageName: node linkType: hard +"ansi-regex@npm:^5.0.1": + version: 5.0.1 + resolution: "ansi-regex@npm:5.0.1" + checksum: 2aa4bb54caf2d622f1afdad09441695af2a83aa3fe8b8afa581d205e57ed4261c183c4d3877cee25794443fde5876417d859c108078ab788d6af7e4fe52eb66b + languageName: node + linkType: hard + "ansi-regex@npm:^6.0.1": version: 6.0.1 resolution: "ansi-regex@npm:6.0.1" @@ -183,6 +222,15 @@ __metadata: languageName: node linkType: hard +"ansi-styles@npm:^4.0.0": + version: 4.3.0 + resolution: "ansi-styles@npm:4.3.0" + dependencies: + color-convert: ^2.0.1 + checksum: 513b44c3b2105dd14cc42a19271e80f386466c4be574bccf60b627432f9198571ebf4ab1e4c3ba17347658f4ee1711c163d574248c0c1cdc2d5917a0ad582ec4 + languageName: node + linkType: hard + "ansi-styles@npm:^6.0.0, ansi-styles@npm:^6.1.0": version: 6.2.1 resolution: "ansi-styles@npm:6.2.1" @@ -254,6 +302,28 @@ __metadata: languageName: node linkType: hard +"c8@npm:^8.0.1": + version: 8.0.1 + resolution: "c8@npm:8.0.1" + dependencies: + "@bcoe/v8-coverage": ^0.2.3 + "@istanbuljs/schema": ^0.1.3 + find-up: ^5.0.0 + foreground-child: ^2.0.0 + istanbul-lib-coverage: ^3.2.0 + istanbul-lib-report: ^3.0.1 + istanbul-reports: ^3.1.6 + rimraf: ^3.0.2 + test-exclude: ^6.0.0 + v8-to-istanbul: ^9.0.0 + yargs: ^17.7.2 + yargs-parser: ^21.1.1 + bin: + c8: bin/c8.js + checksum: 2c47531d21cb67b1e533fbb203ddb5a1c4b45d52c004dcf4eb1376ac8df205f2f4a1b2b9611777ca88dadbbcc2bbdad26b8c5f7ca58a02ecd52afa2aebef73fe + languageName: node + linkType: hard + "call-bind@npm:^1.0.0, call-bind@npm:^1.0.2": version: 1.0.2 resolution: "call-bind@npm:1.0.2" @@ -301,6 +371,17 @@ __metadata: languageName: node linkType: hard +"cliui@npm:^8.0.1": + version: 8.0.1 + resolution: "cliui@npm:8.0.1" + dependencies: + string-width: ^4.2.0 + strip-ansi: ^6.0.1 + wrap-ansi: ^7.0.0 + checksum: 79648b3b0045f2e285b76fb2e24e207c6db44323581e421c3acbd0e86454cba1b37aea976ab50195a49e7384b871e6dfb2247ad7dec53c02454ac6497394cb56 + languageName: node + linkType: hard + "color-convert@npm:^1.9.0": version: 1.9.3 resolution: "color-convert@npm:1.9.3" @@ -310,6 +391,15 @@ __metadata: languageName: node linkType: hard +"color-convert@npm:^2.0.1": + version: 2.0.1 + resolution: "color-convert@npm:2.0.1" + dependencies: + color-name: ~1.1.4 + checksum: 79e6bdb9fd479a205c71d89574fccfb22bd9053bd98c6c4d870d65c132e5e904e6034978e55b43d69fcaa7433af2016ee203ce76eeba9cfa554b373e7f7db336 + languageName: node + linkType: hard + "color-name@npm:1.1.3": version: 1.1.3 resolution: "color-name@npm:1.1.3" @@ -317,6 +407,13 @@ __metadata: languageName: node linkType: hard +"color-name@npm:~1.1.4": + version: 1.1.4 + resolution: "color-name@npm:1.1.4" + checksum: b0445859521eb4021cd0fb0cc1a75cecf67fceecae89b63f62b201cca8d345baf8b952c966862a9d9a2632987d4f6581f0ec8d957dfacece86f0a7919316f610 + languageName: node + linkType: hard + "colorette@npm:^2.0.20": version: 2.0.20 resolution: "colorette@npm:2.0.20" @@ -338,6 +435,13 @@ __metadata: languageName: node linkType: hard +"convert-source-map@npm:^1.6.0": + version: 1.9.0 + resolution: "convert-source-map@npm:1.9.0" + checksum: dc55a1f28ddd0e9485ef13565f8f756b342f9a46c4ae18b843fe3c30c675d058d6a4823eff86d472f187b176f0adf51ea7b69ea38be34be4a63cbbf91b0593c8 + languageName: node + linkType: hard + "create-require@npm:^1.1.0": version: 1.1.1 resolution: "create-require@npm:1.1.1" @@ -358,7 +462,7 @@ __metadata: languageName: node linkType: hard -"cross-spawn@npm:^7.0.3": +"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" dependencies: @@ -405,6 +509,13 @@ __metadata: languageName: node linkType: hard +"emoji-regex@npm:^8.0.0": + version: 8.0.0 + resolution: "emoji-regex@npm:8.0.0" + checksum: d4c5c39d5a9868b5fa152f00cada8a936868fd3367f33f71be515ecee4c803132d11b31a6222b2571b1e5f7e13890156a94880345594d0ce7e3c9895f560f192 + languageName: node + linkType: hard + "emoji-regex@npm:^9.2.2": version: 9.2.2 resolution: "emoji-regex@npm:9.2.2" @@ -490,6 +601,13 @@ __metadata: languageName: node linkType: hard +"escalade@npm:^3.1.1": + version: 3.1.1 + resolution: "escalade@npm:3.1.1" + checksum: a3e2a99f07acb74b3ad4989c48ca0c3140f69f923e56d0cba0526240ee470b91010f9d39001f2a4a313841d237ede70a729e92125191ba5d21e74b106800b133 + languageName: node + linkType: hard + "escape-string-regexp@npm:^1.0.5": version: 1.0.5 resolution: "escape-string-regexp@npm:1.0.5" @@ -530,6 +648,16 @@ __metadata: languageName: node linkType: hard +"find-up@npm:^5.0.0": + version: 5.0.0 + resolution: "find-up@npm:5.0.0" + dependencies: + locate-path: ^6.0.0 + path-exists: ^4.0.0 + checksum: 07955e357348f34660bde7920783204ff5a26ac2cafcaa28bace494027158a97b9f56faaf2d89a6106211a8174db650dd9f503f9c0d526b1202d5554a00b9095 + languageName: node + linkType: hard + "for-each@npm:^0.3.3": version: 0.3.3 resolution: "for-each@npm:0.3.3" @@ -539,6 +667,23 @@ __metadata: languageName: node linkType: hard +"foreground-child@npm:^2.0.0": + version: 2.0.0 + resolution: "foreground-child@npm:2.0.0" + dependencies: + cross-spawn: ^7.0.0 + signal-exit: ^3.0.2 + checksum: f77ec9aff621abd6b754cb59e690743e7639328301fbea6ff09df27d2befaf7dd5b77cec51c32323d73a81a7d91caaf9413990d305cbe3d873eec4fe58960956 + languageName: node + linkType: hard + +"fs.realpath@npm:^1.0.0": + version: 1.0.0 + resolution: "fs.realpath@npm:1.0.0" + checksum: 99ddea01a7e75aa276c250a04eedeffe5662bce66c65c07164ad6264f9de18fb21be9433ead460e54cff20e31721c811f4fb5d70591799df5f85dce6d6746fd0 + languageName: node + linkType: hard + "function-bind@npm:^1.1.1": version: 1.1.1 resolution: "function-bind@npm:1.1.1" @@ -565,6 +710,13 @@ __metadata: languageName: node linkType: hard +"get-caller-file@npm:^2.0.5": + version: 2.0.5 + resolution: "get-caller-file@npm:2.0.5" + checksum: b9769a836d2a98c3ee734a88ba712e62703f1df31b94b784762c433c27a386dd6029ff55c2a920c392e33657d80191edbf18c61487e198844844516f843496b9 + languageName: node + linkType: hard + "get-intrinsic@npm:^1.0.2, get-intrinsic@npm:^1.1.1, get-intrinsic@npm:^1.1.3, get-intrinsic@npm:^1.2.0, get-intrinsic@npm:^1.2.1": version: 1.2.1 resolution: "get-intrinsic@npm:1.2.1" @@ -594,6 +746,20 @@ __metadata: languageName: node linkType: hard +"glob@npm:^7.1.3, glob@npm:^7.1.4": + version: 7.2.3 + resolution: "glob@npm:7.2.3" + dependencies: + fs.realpath: ^1.0.0 + inflight: ^1.0.4 + inherits: 2 + minimatch: ^3.1.1 + once: ^1.3.0 + path-is-absolute: ^1.0.0 + checksum: 29452e97b38fa704dabb1d1045350fb2467cf0277e155aa9ff7077e90ad81d1ea9d53d3ee63bd37c05b09a065e90f16aec4a65f5b8de401d1dac40bc5605d133 + languageName: node + linkType: hard + "globalthis@npm:^1.0.3": version: 1.0.3 resolution: "globalthis@npm:1.0.3" @@ -633,6 +799,13 @@ __metadata: languageName: node linkType: hard +"has-flag@npm:^4.0.0": + version: 4.0.0 + resolution: "has-flag@npm:4.0.0" + checksum: 261a1357037ead75e338156b1f9452c016a37dcd3283a972a30d9e4a87441ba372c8b81f818cd0fbcd9c0354b4ae7e18b9e1afa1971164aef6d18c2b6095a8ad + languageName: node + linkType: hard + "has-property-descriptors@npm:^1.0.0": version: 1.0.0 resolution: "has-property-descriptors@npm:1.0.0" @@ -681,6 +854,13 @@ __metadata: languageName: node linkType: hard +"html-escaper@npm:^2.0.0": + version: 2.0.2 + resolution: "html-escaper@npm:2.0.2" + checksum: d2df2da3ad40ca9ee3a39c5cc6475ef67c8f83c234475f24d8e9ce0dc80a2c82df8e1d6fa78ddd1e9022a586ea1bd247a615e80a5cd9273d90111ddda7d9e974 + languageName: node + linkType: hard + "human-signals@npm:^4.3.0": version: 4.3.1 resolution: "human-signals@npm:4.3.1" @@ -697,6 +877,23 @@ __metadata: languageName: node linkType: hard +"inflight@npm:^1.0.4": + version: 1.0.6 + resolution: "inflight@npm:1.0.6" + dependencies: + once: ^1.3.0 + wrappy: 1 + checksum: f4f76aa072ce19fae87ce1ef7d221e709afb59d445e05d47fba710e85470923a75de35bfae47da6de1b18afc3ce83d70facf44cfb0aff89f0a3f45c0a0244dfd + languageName: node + linkType: hard + +"inherits@npm:2": + version: 2.0.4 + resolution: "inherits@npm:2.0.4" + checksum: 4a48a733847879d6cf6691860a6b1e3f0f4754176e4d71494c41f3475553768b10f84b5ce1d40fbd0e34e6bfbb864ee35858ad4dd2cf31e02fc4a154b724d7f1 + languageName: node + linkType: hard + "internal-slot@npm:^1.0.5": version: 1.0.5 resolution: "internal-slot@npm:1.0.5" @@ -770,6 +967,13 @@ __metadata: languageName: node linkType: hard +"is-fullwidth-code-point@npm:^3.0.0": + version: 3.0.0 + resolution: "is-fullwidth-code-point@npm:3.0.0" + checksum: 44a30c29457c7fb8f00297bce733f0a64cd22eca270f83e58c105e0d015e45c019491a4ab2faef91ab51d4738c670daff901c799f6a700e27f7314029e99e348 + languageName: node + linkType: hard + "is-fullwidth-code-point@npm:^4.0.0": version: 4.0.0 resolution: "is-fullwidth-code-point@npm:4.0.0" @@ -876,6 +1080,34 @@ __metadata: languageName: node linkType: hard +"istanbul-lib-coverage@npm:^3.0.0, istanbul-lib-coverage@npm:^3.2.0": + version: 3.2.0 + resolution: "istanbul-lib-coverage@npm:3.2.0" + checksum: a2a545033b9d56da04a8571ed05c8120bf10e9bce01cf8633a3a2b0d1d83dff4ac4fe78d6d5673c27fc29b7f21a41d75f83a36be09f82a61c367b56aa73c1ff9 + languageName: node + linkType: hard + +"istanbul-lib-report@npm:^3.0.0, istanbul-lib-report@npm:^3.0.1": + version: 3.0.1 + resolution: "istanbul-lib-report@npm:3.0.1" + dependencies: + istanbul-lib-coverage: ^3.0.0 + make-dir: ^4.0.0 + supports-color: ^7.1.0 + checksum: fd17a1b879e7faf9bb1dc8f80b2a16e9f5b7b8498fe6ed580a618c34df0bfe53d2abd35bf8a0a00e628fb7405462576427c7df20bbe4148d19c14b431c974b21 + languageName: node + linkType: hard + +"istanbul-reports@npm:^3.1.6": + version: 3.1.6 + resolution: "istanbul-reports@npm:3.1.6" + dependencies: + html-escaper: ^2.0.0 + istanbul-lib-report: ^3.0.0 + checksum: 44c4c0582f287f02341e9720997f9e82c071627e1e862895745d5f52ec72c9b9f38e1d12370015d2a71dcead794f34c7732aaef3fab80a24bc617a21c3d911d6 + languageName: node + linkType: hard + "json-parse-better-errors@npm:^1.0.1": version: 1.0.2 resolution: "json-parse-better-errors@npm:1.0.2" @@ -948,6 +1180,15 @@ __metadata: languageName: node linkType: hard +"locate-path@npm:^6.0.0": + version: 6.0.0 + resolution: "locate-path@npm:6.0.0" + dependencies: + p-locate: ^5.0.0 + checksum: 72eb661788a0368c099a184c59d2fee760b3831c9c1c33955e8a19ae4a21b4116e53fa736dc086cdeb9fce9f7cc508f2f92d2d3aae516f133e16a2bb59a39f5a + languageName: node + linkType: hard + "log-update@npm:^5.0.1": version: 5.0.1 resolution: "log-update@npm:5.0.1" @@ -961,6 +1202,24 @@ __metadata: languageName: node linkType: hard +"lru-cache@npm:^6.0.0": + version: 6.0.0 + resolution: "lru-cache@npm:6.0.0" + dependencies: + yallist: ^4.0.0 + checksum: f97f499f898f23e4585742138a22f22526254fdba6d75d41a1c2526b3b6cc5747ef59c5612ba7375f42aca4f8461950e925ba08c991ead0651b4918b7c978297 + languageName: node + linkType: hard + +"make-dir@npm:^4.0.0": + version: 4.0.0 + resolution: "make-dir@npm:4.0.0" + dependencies: + semver: ^7.5.3 + checksum: bf0731a2dd3aab4db6f3de1585cea0b746bb73eb5a02e3d8d72757e376e64e6ada190b1eddcde5b2f24a81b688a9897efd5018737d05e02e2a671dda9cff8a8a + languageName: node + linkType: hard + "make-error@npm:^1.1.1": version: 1.3.6 resolution: "make-error@npm:1.3.6" @@ -1006,7 +1265,7 @@ __metadata: languageName: node linkType: hard -"minimatch@npm:^3.0.4": +"minimatch@npm:^3.0.4, minimatch@npm:^3.1.1": version: 3.1.2 resolution: "minimatch@npm:3.1.2" dependencies: @@ -1097,6 +1356,15 @@ __metadata: languageName: node linkType: hard +"once@npm:^1.3.0": + version: 1.4.0 + resolution: "once@npm:1.4.0" + dependencies: + wrappy: 1 + checksum: cd0a88501333edd640d95f0d2700fbde6bff20b3d4d9bdc521bdd31af0656b5706570d6c6afe532045a20bb8dc0849f8332d6f2a416e0ba6d3d3b98806c7db68 + languageName: node + linkType: hard + "onetime@npm:^5.1.0": version: 5.1.2 resolution: "onetime@npm:5.1.2" @@ -1115,6 +1383,24 @@ __metadata: languageName: node linkType: hard +"p-limit@npm:^3.0.2": + version: 3.1.0 + resolution: "p-limit@npm:3.1.0" + dependencies: + yocto-queue: ^0.1.0 + checksum: 7c3690c4dbf62ef625671e20b7bdf1cbc9534e83352a2780f165b0d3ceba21907e77ad63401708145ca4e25bfc51636588d89a8c0aeb715e6c37d1c066430360 + languageName: node + linkType: hard + +"p-locate@npm:^5.0.0": + version: 5.0.0 + resolution: "p-locate@npm:5.0.0" + dependencies: + p-limit: ^3.0.2 + checksum: 1623088f36cf1cbca58e9b61c4e62bf0c60a07af5ae1ca99a720837356b5b6c5ba3eb1b2127e47a06865fee59dd0453cad7cc844cda9d5a62ac1a5a51b7c86d3 + languageName: node + linkType: hard + "parse-json@npm:^4.0.0": version: 4.0.0 resolution: "parse-json@npm:4.0.0" @@ -1125,6 +1411,20 @@ __metadata: languageName: node linkType: hard +"path-exists@npm:^4.0.0": + version: 4.0.0 + resolution: "path-exists@npm:4.0.0" + checksum: 505807199dfb7c50737b057dd8d351b82c033029ab94cb10a657609e00c1bc53b951cfdbccab8de04c5584d5eff31128ce6afd3db79281874a5ef2adbba55ed1 + languageName: node + linkType: hard + +"path-is-absolute@npm:^1.0.0": + version: 1.0.1 + resolution: "path-is-absolute@npm:1.0.1" + checksum: 060840f92cf8effa293bcc1bea81281bd7d363731d214cbe5c227df207c34cd727430f70c6037b5159c8a870b9157cba65e775446b0ab06fd5ecc7e54615a3b8 + languageName: node + linkType: hard + "path-key@npm:^2.0.1": version: 2.0.1 resolution: "path-key@npm:2.0.1" @@ -1235,6 +1535,13 @@ __metadata: languageName: node linkType: hard +"require-directory@npm:^2.1.1": + version: 2.1.1 + resolution: "require-directory@npm:2.1.1" + checksum: fb47e70bf0001fdeabdc0429d431863e9475e7e43ea5f94ad86503d918423c1543361cc5166d713eaa7029dd7a3d34775af04764bebff99ef413111a5af18c80 + languageName: node + linkType: hard + "resolve@npm:^1.10.0": version: 1.22.4 resolution: "resolve@npm:1.22.4" @@ -1278,6 +1585,17 @@ __metadata: languageName: node linkType: hard +"rimraf@npm:^3.0.2": + version: 3.0.2 + resolution: "rimraf@npm:3.0.2" + dependencies: + glob: ^7.1.3 + bin: + rimraf: bin.js + checksum: 87f4164e396f0171b0a3386cc1877a817f572148ee13a7e113b238e48e8a9f2f31d009a92ec38a591ff1567d9662c6b67fd8818a2dbbaed74bc26a87a2a4a9a0 + languageName: node + linkType: hard + "safe-array-concat@npm:^1.0.0": version: 1.0.0 resolution: "safe-array-concat@npm:1.0.0" @@ -1310,6 +1628,17 @@ __metadata: languageName: node linkType: hard +"semver@npm:^7.5.3": + version: 7.5.4 + resolution: "semver@npm:7.5.4" + dependencies: + lru-cache: ^6.0.0 + bin: + semver: bin/semver.js + checksum: 12d8ad952fa353b0995bf180cdac205a4068b759a140e5d3c608317098b3575ac2f1e09182206bf2eb26120e1c0ed8fb92c48c592f6099680de56bb071423ca3 + languageName: node + linkType: hard + "shebang-command@npm:^1.2.0": version: 1.2.0 resolution: "shebang-command@npm:1.2.0" @@ -1425,6 +1754,17 @@ __metadata: languageName: node linkType: hard +"string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3": + version: 4.2.3 + resolution: "string-width@npm:4.2.3" + dependencies: + emoji-regex: ^8.0.0 + is-fullwidth-code-point: ^3.0.0 + strip-ansi: ^6.0.1 + checksum: e52c10dc3fbfcd6c3a15f159f54a90024241d0f149cf8aed2982a2d801d2e64df0bf1dc351cf8e95c3319323f9f220c16e740b06faecd53e2462df1d2b5443fb + languageName: node + linkType: hard + "string-width@npm:^5.0.0, string-width@npm:^5.0.1": version: 5.1.2 resolution: "string-width@npm:5.1.2" @@ -1480,6 +1820,15 @@ __metadata: languageName: node linkType: hard +"strip-ansi@npm:^6.0.0, strip-ansi@npm:^6.0.1": + version: 6.0.1 + resolution: "strip-ansi@npm:6.0.1" + dependencies: + ansi-regex: ^5.0.1 + checksum: f3cd25890aef3ba6e1a74e20896c21a46f482e93df4a06567cebf2b57edabb15133f1f94e57434e0a958d61186087b1008e89c94875d019910a213181a14fc8c + languageName: node + linkType: hard + "strip-ansi@npm:^7.0.1": version: 7.1.0 resolution: "strip-ansi@npm:7.1.0" @@ -1512,6 +1861,15 @@ __metadata: languageName: node linkType: hard +"supports-color@npm:^7.1.0": + version: 7.2.0 + resolution: "supports-color@npm:7.2.0" + dependencies: + has-flag: ^4.0.0 + checksum: 3dda818de06ebbe5b9653e07842d9479f3555ebc77e9a0280caf5a14fb877ffee9ed57007c3b78f5a6324b8dbeec648d9e97a24e2ed9fdb81ddc69ea07100f4a + languageName: node + linkType: hard + "supports-preserve-symlinks-flag@npm:^1.0.0": version: 1.0.0 resolution: "supports-preserve-symlinks-flag@npm:1.0.0" @@ -1519,6 +1877,17 @@ __metadata: languageName: node linkType: hard +"test-exclude@npm:^6.0.0": + version: 6.0.0 + resolution: "test-exclude@npm:6.0.0" + dependencies: + "@istanbuljs/schema": ^0.1.2 + glob: ^7.1.4 + minimatch: ^3.0.4 + checksum: 3b34a3d77165a2cb82b34014b3aba93b1c4637a5011807557dc2f3da826c59975a5ccad765721c4648b39817e3472789f9b0fa98fc854c5c1c7a1e632aacdc28 + languageName: node + linkType: hard + "to-regex-range@npm:^5.0.1": version: 5.0.1 resolution: "to-regex-range@npm:5.0.1" @@ -1668,6 +2037,17 @@ __metadata: languageName: node linkType: hard +"v8-to-istanbul@npm:^9.0.0": + version: 9.1.0 + resolution: "v8-to-istanbul@npm:9.1.0" + dependencies: + "@jridgewell/trace-mapping": ^0.3.12 + "@types/istanbul-lib-coverage": ^2.0.1 + convert-source-map: ^1.6.0 + checksum: 2069d59ee46cf8d83b4adfd8a5c1a90834caffa9f675e4360f1157ffc8578ef0f763c8f32d128334424159bb6b01f3876acd39cd13297b2769405a9da241f8d1 + languageName: node + linkType: hard + "validate-npm-package-license@npm:^3.0.1": version: 3.0.4 resolution: "validate-npm-package-license@npm:3.0.4" @@ -1726,6 +2106,17 @@ __metadata: languageName: node linkType: hard +"wrap-ansi@npm:^7.0.0": + version: 7.0.0 + resolution: "wrap-ansi@npm:7.0.0" + dependencies: + ansi-styles: ^4.0.0 + string-width: ^4.1.0 + strip-ansi: ^6.0.0 + checksum: a790b846fd4505de962ba728a21aaeda189b8ee1c7568ca5e817d85930e06ef8d1689d49dbf0e881e8ef84436af3a88bc49115c2e2788d841ff1b8b5b51a608b + languageName: node + linkType: hard + "wrap-ansi@npm:^8.0.1, wrap-ansi@npm:^8.1.0": version: 8.1.0 resolution: "wrap-ansi@npm:8.1.0" @@ -1737,6 +2128,27 @@ __metadata: languageName: node linkType: hard +"wrappy@npm:1": + version: 1.0.2 + resolution: "wrappy@npm:1.0.2" + checksum: 159da4805f7e84a3d003d8841557196034155008f817172d4e986bd591f74aa82aa7db55929a54222309e01079a65a92a9e6414da5a6aa4b01ee44a511ac3ee5 + languageName: node + linkType: hard + +"y18n@npm:^5.0.5": + version: 5.0.8 + resolution: "y18n@npm:5.0.8" + checksum: 54f0fb95621ee60898a38c572c515659e51cc9d9f787fb109cef6fde4befbe1c4602dc999d30110feee37456ad0f1660fa2edcfde6a9a740f86a290999550d30 + languageName: node + linkType: hard + +"yallist@npm:^4.0.0": + version: 4.0.0 + resolution: "yallist@npm:4.0.0" + checksum: 343617202af32df2a15a3be36a5a8c0c8545208f3d3dfbc6bb7c3e3b7e8c6f8e7485432e4f3b88da3031a6e20afa7c711eded32ddfb122896ac5d914e75848d5 + languageName: node + linkType: hard + "yaml@npm:2.3.1": version: 2.3.1 resolution: "yaml@npm:2.3.1" @@ -1744,9 +2156,38 @@ __metadata: languageName: node linkType: hard +"yargs-parser@npm:^21.1.1": + version: 21.1.1 + resolution: "yargs-parser@npm:21.1.1" + checksum: ed2d96a616a9e3e1cc7d204c62ecc61f7aaab633dcbfab2c6df50f7f87b393993fe6640d017759fe112d0cb1e0119f2b4150a87305cc873fd90831c6a58ccf1c + languageName: node + linkType: hard + +"yargs@npm:^17.7.2": + version: 17.7.2 + resolution: "yargs@npm:17.7.2" + dependencies: + cliui: ^8.0.1 + escalade: ^3.1.1 + get-caller-file: ^2.0.5 + require-directory: ^2.1.1 + string-width: ^4.2.3 + y18n: ^5.0.5 + yargs-parser: ^21.1.1 + checksum: 73b572e863aa4a8cbef323dd911d79d193b772defd5a51aab0aca2d446655216f5002c42c5306033968193bdbf892a7a4c110b0d77954a7fdf563e653967b56a + languageName: node + linkType: hard + "yn@npm:3.1.1": version: 3.1.1 resolution: "yn@npm:3.1.1" checksum: 2c487b0e149e746ef48cda9f8bad10fc83693cd69d7f9dcd8be4214e985de33a29c9e24f3c0d6bcf2288427040a8947406ab27f7af67ee9456e6b84854f02dd6 languageName: node linkType: hard + +"yocto-queue@npm:^0.1.0": + version: 0.1.0 + resolution: "yocto-queue@npm:0.1.0" + checksum: f77b3d8d00310def622123df93d4ee654fc6a0096182af8bd60679ddcdfb3474c56c6c7190817c84a2785648cdee9d721c0154eb45698c62176c322fb46fc700 + languageName: node + linkType: hard From b52aec4eba3e4cc2cc6b464c708325a4fe993d37 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 20:27:10 +0800 Subject: [PATCH 10/14] fix: binding build --- .github/workflows/y-octo-node.yml | 2 +- .nvmrc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .nvmrc diff --git a/.github/workflows/y-octo-node.yml b/.github/workflows/y-octo-node.yml index f68ce23..276359f 100644 --- a/.github/workflows/y-octo-node.yml +++ b/.github/workflows/y-octo-node.yml @@ -13,7 +13,7 @@ env: jobs: build-node: - name: Build Storage + name: Build Node Binding runs-on: ubuntu-latest env: RUSTFLAGS: "-C debuginfo=1" diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..3c03207 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +18 From 322f7c8edc861f79c452e93a21a40bdc5907c986 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 20:30:27 +0800 Subject: [PATCH 11/14] ci: fix artifact name --- .github/workflows/y-octo-node.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/y-octo-node.yml b/.github/workflows/y-octo-node.yml index 276359f..73ffb03 100644 --- a/.github/workflows/y-octo-node.yml +++ b/.github/workflows/y-octo-node.yml @@ -33,7 +33,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: y-octo.node - path: ./y-octo-node/y-octo.node + path: ./y-octo-node/y-octo.linux-x64-gnu.node if-no-files-found: error node-binding-test: From 3c5095125f711fc71081a4992d2ff10ee9391e55 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 20:32:29 +0800 Subject: [PATCH 12/14] chore: ci name --- .github/actions/build-rust/action.yml | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/actions/build-rust/action.yml diff --git a/.github/actions/build-rust/action.yml b/.github/actions/build-rust/action.yml new file mode 100644 index 0000000..c043aa2 --- /dev/null +++ b/.github/actions/build-rust/action.yml @@ -0,0 +1,60 @@ +name: "AFFiNE Rust build" +description: "Rust build setup, including cache configuration" +inputs: + target: + description: "Cargo target" + required: true + nx_token: + description: "Nx Cloud access token" + required: false + +runs: + using: "composite" + steps: + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + targets: ${{ inputs.target }} + + - name: Cache cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + .cargo-cache + target/${{ inputs.target }} + key: stable-${{ inputs.target }}-cargo-cache + - name: Build + if: ${{ inputs.target != 'x86_64-unknown-linux-gnu' && inputs.target != 'aarch64-unknown-linux-gnu' }} + shell: bash + run: | + yarn nx build @affine/native --target ${{ inputs.target }} + env: + NX_CLOUD_ACCESS_TOKEN: ${{ inputs.nx_token }} + + - name: Build + if: ${{ inputs.target == 'x86_64-unknown-linux-gnu' }} + uses: addnab/docker-run-action@v3 + with: + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian + options: --user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build -e NX_CLOUD_ACCESS_TOKEN=${{ inputs.nx_token }} + run: | + export CC=x86_64-unknown-linux-gnu-gcc + export CC_x86_64_unknown_linux_gnu=x86_64-unknown-linux-gnu-gcc + yarn nx build @affine/native --target ${{ inputs.target }} + chmod -R 777 node_modules/.cache + chmod -R 777 target + + - name: Build + if: ${{ inputs.target == 'aarch64-unknown-linux-gnu' }} + uses: addnab/docker-run-action@v3 + with: + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 + options: --user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build -e NX_CLOUD_ACCESS_TOKEN=${{ inputs.nx_token }} + run: | + yarn nx build @affine/native --target ${{ inputs.target }} + chmod -R 777 node_modules/.cache + chmod -R 777 target From d93a7d18f39da5333d61b5a04dd9a18b87ae3f3d Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 20:36:17 +0800 Subject: [PATCH 13/14] feat: add rust test for node binding --- .github/workflows/y-octo-node.yml | 29 ++++++++++++++++++++++++++++- y-octo-node/src/doc.rs | 12 ++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/workflows/y-octo-node.yml b/.github/workflows/y-octo-node.yml index 73ffb03..d778ac2 100644 --- a/.github/workflows/y-octo-node.yml +++ b/.github/workflows/y-octo-node.yml @@ -1,4 +1,4 @@ -name: Build & Test +name: Y-Octo Node Binding Build & Test on: workflow_dispatch: @@ -36,6 +36,33 @@ jobs: path: ./y-octo-node/y-octo.linux-x64-gnu.node if-no-files-found: error + test-node: + name: Test & Collect Coverage + runs-on: ubuntu-latest + continue-on-error: true + env: + RUSTFLAGS: -D warnings + CARGO_TERM_COLOR: always + steps: + - uses: actions/checkout@v3 + + - name: Setup Rust + uses: ./.github/actions/setup-rust + with: + components: llvm-tools-preview + - name: Install latest nextest release + uses: taiki-e/install-action@nextest + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + + - name: Collect coverage data + run: cargo llvm-cov nextest --lcov --output-path lcov.info + - name: Upload coverage data to codecov + uses: codecov/codecov-action@v3 + with: + name: tests + files: lcov.info + node-binding-test: name: Node Binding Test runs-on: ubuntu-latest diff --git a/y-octo-node/src/doc.rs b/y-octo-node/src/doc.rs index 54bf740..8143618 100644 --- a/y-octo-node/src/doc.rs +++ b/y-octo-node/src/doc.rs @@ -25,3 +25,15 @@ impl Doc { self.doc.client() as i64 } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_doc_client() { + let client_id = 1; + let doc = Doc::new(Some(client_id)); + assert_eq!(doc.client_id(), 1); + } +} From e45e0a7e769b58f07fbac15dcc4f510cdb6cf6f9 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 20 Aug 2023 20:38:14 +0800 Subject: [PATCH 14/14] chore: cleanup --- .github/actions/build-rust/action.yml | 60 --------------------------- 1 file changed, 60 deletions(-) delete mode 100644 .github/actions/build-rust/action.yml diff --git a/.github/actions/build-rust/action.yml b/.github/actions/build-rust/action.yml deleted file mode 100644 index c043aa2..0000000 --- a/.github/actions/build-rust/action.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: "AFFiNE Rust build" -description: "Rust build setup, including cache configuration" -inputs: - target: - description: "Cargo target" - required: true - nx_token: - description: "Nx Cloud access token" - required: false - -runs: - using: "composite" - steps: - - name: Setup Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - targets: ${{ inputs.target }} - - - name: Cache cargo - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - .cargo-cache - target/${{ inputs.target }} - key: stable-${{ inputs.target }}-cargo-cache - - name: Build - if: ${{ inputs.target != 'x86_64-unknown-linux-gnu' && inputs.target != 'aarch64-unknown-linux-gnu' }} - shell: bash - run: | - yarn nx build @affine/native --target ${{ inputs.target }} - env: - NX_CLOUD_ACCESS_TOKEN: ${{ inputs.nx_token }} - - - name: Build - if: ${{ inputs.target == 'x86_64-unknown-linux-gnu' }} - uses: addnab/docker-run-action@v3 - with: - image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian - options: --user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build -e NX_CLOUD_ACCESS_TOKEN=${{ inputs.nx_token }} - run: | - export CC=x86_64-unknown-linux-gnu-gcc - export CC_x86_64_unknown_linux_gnu=x86_64-unknown-linux-gnu-gcc - yarn nx build @affine/native --target ${{ inputs.target }} - chmod -R 777 node_modules/.cache - chmod -R 777 target - - - name: Build - if: ${{ inputs.target == 'aarch64-unknown-linux-gnu' }} - uses: addnab/docker-run-action@v3 - with: - image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 - options: --user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build -e NX_CLOUD_ACCESS_TOKEN=${{ inputs.nx_token }} - run: | - yarn nx build @affine/native --target ${{ inputs.target }} - chmod -R 777 node_modules/.cache - chmod -R 777 target