ci: refactor workflow (#5139)

Merge tests job into single one, reuse job as much as possible
This commit is contained in:
LongYinan
2023-12-06 08:03:05 +00:00
parent 48f4d6a06c
commit e5f8a58330
20 changed files with 1837 additions and 1361 deletions

View File

@@ -1,21 +1,6 @@
/* tslint:disable */
/* auto-generated by NAPI-RS */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export function verifyChallengeResponse(response: string, bits: number, resource: string): Promise<boolean>
export function mintChallengeResponse(resource: string, bits?: number | undefined | null): Promise<string>
export interface Blob {
contentType: string
lastModified: string
size: number
data: Buffer
}
/**
* Merge updates in form like `Y.applyUpdate(doc, update)` way and return the
* result binary.
*/
export function mergeUpdatesInApplyWay(updates: Array<Buffer>): Buffer
export class Storage {
/** Create a storage instance and establish connection to persist store. */
static connect(database: string, debugOnlyAutoMigrate?: boolean | undefined | null): Promise<Storage>
@@ -30,3 +15,21 @@ export class Storage {
/** Workspace size taken by blobs. */
blobsSize(workspaces: Array<string>): Promise<number>
}
export interface Blob {
contentType: string
lastModified: string
size: number
data: Buffer
}
/**
* Merge updates in form like `Y.applyUpdate(doc, update)` way and return the
* result binary.
*/
export function mergeUpdatesInApplyWay(updates: Array<Buffer>): Buffer
export function mintChallengeResponse(resource: string, bits?: number | undefined | null): Promise<string>
export function verifyChallengeResponse(response: string, bits: number, resource: string): Promise<boolean>

View File

@@ -16,27 +16,26 @@
}
},
"napi": {
"name": "storage",
"binaryName": "storage",
"targets": [
"aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"aarch64-pc-windows-msvc",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"universal-apple-darwin"
"x86_64-unknown-linux-gnu"
]
},
"scripts": {
"test": "node --test ./__tests__/**/*.spec.js",
"build": "napi build --release --strip",
"build": "napi build --release --strip --no-const-enum",
"build:debug": "napi build",
"prepublishOnly": "napi prepublish -t npm",
"artifacts": "napi artifacts",
"version": "napi version"
},
"devDependencies": {
"@napi-rs/cli": "^2.16.5",
"@napi-rs/cli": "3.0.0-alpha.12",
"lib0": "^0.2.87",
"nx": "^17.1.3",
"nx-cloud": "^16.5.2",

View File

@@ -1,32 +1,6 @@
/* tslint:disable */
/* auto-generated by NAPI-RS */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export interface BlobRow {
key: string
data: Buffer
timestamp: Date
}
export interface UpdateRow {
id: number
timestamp: Date
data: Buffer
docId?: string
}
export interface InsertRow {
docId?: string
data: Uint8Array
}
export enum ValidationResult {
MissingTables = 0,
MissingDocIdColumn = 1,
MissingVersionColumn = 2,
GeneralError = 3,
Valid = 4
}
export function verifyChallengeResponse(response: string, bits: number, resource: string): Promise<boolean>
export function mintChallengeResponse(resource: string, bits?: number | undefined | null): Promise<string>
export class SqliteConnection {
constructor(path: string)
connect(): Promise<void>
@@ -47,3 +21,34 @@ export class SqliteConnection {
static validate(path: string): Promise<ValidationResult>
migrateAddDocId(): Promise<void>
}
export interface BlobRow {
key: string
data: Buffer
timestamp: Date
}
export interface InsertRow {
docId?: string
data: Uint8Array
}
export function mintChallengeResponse(resource: string, bits?: number | undefined | null): Promise<string>
export interface UpdateRow {
id: number
timestamp: Date
data: Buffer
docId?: string
}
export enum ValidationResult {
MissingTables = 0,
MissingDocIdColumn = 1,
MissingVersionColumn = 2,
GeneralError = 3,
Valid = 4
}
export function verifyChallengeResponse(response: string, bits: number, resource: string): Promise<boolean>

View File

@@ -1,7 +1,5 @@
/* tslint:disable */
// prettier-ignore
/* eslint-disable */
/* prettier-ignore */
/* auto-generated by NAPI-RS */
const { existsSync, readFileSync } = require('fs')
@@ -13,18 +11,52 @@ 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) {
const isMusl = () => {
let musl = false
if (process.platform === 'linux') {
musl = isMuslFromFilesystem()
if (musl === null) {
musl = isMuslFromReport()
}
if (musl === null) {
musl = isMuslFromChildProcess()
}
}
return musl
}
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
const isMuslFromFilesystem = () => {
try {
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
} catch {
return null
}
}
const isMuslFromReport = () => {
const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
if (!report) {
return null
}
if (report.header && report.header.glibcVersionRuntime) {
return false
}
if (Array.isArray(report.sharedObjects)) {
if (report.sharedObjects.some(isFileMusl)) {
return true
}
} else {
const { glibcVersionRuntime } = process.report.getReport().header
return !glibcVersionRuntime
}
return false
}
const isMuslFromChildProcess = () => {
try {
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
} catch (e) {
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
return false
}
}
@@ -252,9 +284,7 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}
const { SqliteConnection, ValidationResult, verifyChallengeResponse, mintChallengeResponse } = nativeBinding
module.exports.SqliteConnection = SqliteConnection
module.exports.ValidationResult = ValidationResult
module.exports.verifyChallengeResponse = verifyChallengeResponse
module.exports.mintChallengeResponse = mintChallengeResponse
module.exports.SqliteConnection = nativeBinding.SqliteConnection
module.exports.mintChallengeResponse = nativeBinding.mintChallengeResponse
module.exports.ValidationResult = nativeBinding.ValidationResult
module.exports.verifyChallengeResponse = nativeBinding.verifyChallengeResponse

View File

@@ -4,7 +4,7 @@
"main": "index.js",
"types": "index.d.ts",
"napi": {
"name": "affine",
"binaryName": "affine",
"triples": {
"additional": [
"aarch64-apple-darwin",
@@ -35,7 +35,7 @@
}
},
"devDependencies": {
"@napi-rs/cli": "^2.16.5",
"@napi-rs/cli": "3.0.0-alpha.12",
"@types/node": "^20.9.3",
"@types/uuid": "^9.0.7",
"ava": "^6.0.0",
@@ -53,7 +53,7 @@
"scripts": {
"artifacts": "napi artifacts",
"build": "napi build --platform --release --no-const-enum",
"build:debug": "napi build --platform --no-const-enum",
"build:debug": "napi build --platform",
"universal": "napi universal",
"test": "ava",
"version": "napi version"