diff --git a/.github/workflows/lint-ts.yml b/.github/workflows/lint-ts.yml index f1be0f5e8e..3b07f54ea1 100644 --- a/.github/workflows/lint-ts.yml +++ b/.github/workflows/lint-ts.yml @@ -1,45 +1,39 @@ name: lint-ts + on: - push: - branches: ["main"] - paths: - - benchmarks/node/** - - node/** - - benchmarks/utilities/* - - .github/workflows/lint-ts.yml - pull_request: - paths: - - benchmarks/node/** - - node/** - - benchmarks/utilities/* - - .github/workflows/lint-ts.yml + push: + branches: ["main"] + paths: + - benchmarks/node/** + - node/** + - benchmarks/utilities/* + - .github/workflows/lint-ts.yml + pull_request: + paths: + - benchmarks/node/** + - node/** + - benchmarks/utilities/* + - .github/workflows/lint-ts.yml env: - CARGO_TERM_COLOR: always -jobs: - job: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 + CARGO_TERM_COLOR: always - - uses: ./.github/workflows/lint-ts - with: - package-folder: ./node - name: lint node +jobs: + lint: + runs-on: ubuntu-latest + timeout-minutes: 10 - - uses: ./.github/workflows/lint-ts - with: - package-folder: ./benchmarks/node - name: lint benchmark + steps: + - name: Checkout code + uses: actions/checkout@v4 - - uses: ./.github/workflows/lint-ts - with: - package-folder: ./benchmarks/utilities - name: lint benchmark utilities + - name: Install dependencies + run: | + npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tsdoc eslint typescript eslint-plugin-import@latest eslint-config-prettier prettier - - name: lint ts - run: | - npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tsdoc eslint typescript eslint-plugin-import@latest eslint-config-prettier prettier - npx eslint . - npx prettier --check . + - name: Run linting and prettier + run: | + for folder in node benchmarks/node benchmarks/utilities; do + npx eslint ${{ github.workspace }}/$folder + npx prettier --check ${{ github.workspace }}/$folder + done diff --git a/benchmarks/node/node_benchmark.ts b/benchmarks/node/node_benchmark.ts index 9450bdee1c..ce044cb770 100644 --- a/benchmarks/node/node_benchmark.ts +++ b/benchmarks/node/node_benchmark.ts @@ -66,7 +66,7 @@ async function redisBenchmark( clients: IAsyncClient[], totalCommands: number, data: string, - actionLatencies: Record + actionLatencies: Record, ) { while (startedTasksCounter < totalCommands) { startedTasksCounter += 1; @@ -97,14 +97,14 @@ async function createBenchTasks( totalCommands: number, numOfConcurrentTasks: number, data: string, - actionLatencies: Record + actionLatencies: Record, ) { startedTasksCounter = 0; const tic = process.hrtime(); for (let i = 0; i < numOfConcurrentTasks; i++) { runningTasks.push( - redisBenchmark(clients, totalCommands, data, actionLatencies) + redisBenchmark(clients, totalCommands, data, actionLatencies), ); } @@ -115,7 +115,7 @@ async function createBenchTasks( function latencyResults( prefix: string, - latencies: number[] + latencies: number[], ): Record { const result: Record = {}; result[prefix + "_p50_latency"] = calculateLatency(latencies, 50); @@ -136,13 +136,13 @@ async function runClients( dataSize: number, data: string, clientDisposal: (client: IAsyncClient) => void, - isCluster: boolean + isCluster: boolean, ) { const now = new Date(); console.log( `Starting ${clientName} data size: ${dataSize} concurrency: ${numOfConcurrentTasks} client count: ${ clients.length - } isCluster: ${isCluster} ${now.toLocaleTimeString()}` + } isCluster: ${isCluster} ${now.toLocaleTimeString()}`, ); const actionLatencies = { [ChosenAction.SET]: [], @@ -155,7 +155,7 @@ async function runClients( totalCommands, numOfConcurrentTasks, data, - actionLatencies + actionLatencies, ); const tps = Math.round(startedTasksCounter / time); @@ -163,13 +163,13 @@ async function runClients( actionLatencies[ChosenAction.GET_NON_EXISTING]; const getNonExistingLatencyResults = latencyResults( "get_non_existing", - getNonExistingLatencies + getNonExistingLatencies, ); const getExistingLatencies = actionLatencies[ChosenAction.GET_EXISTING]; const getExistingLatencyResults = latencyResults( "get_existing", - getExistingLatencies + getExistingLatencies, ); const setLatencies = actionLatencies[ChosenAction.SET]; @@ -193,10 +193,10 @@ async function runClients( function createClients( clientCount: number, - createAction: () => Promise + createAction: () => Promise, ): Promise { const creationActions = Array.from({ length: clientCount }, () => - createAction() + createAction(), ); return Promise.all(creationActions); } @@ -210,7 +210,7 @@ async function main( clientCount: number, useTLS: boolean, clusterModeEnabled: boolean, - port: number + port: number, ) { const data = generateValue(dataSize); @@ -222,7 +222,7 @@ async function main( clientClass.createClient({ addresses: [{ host, port }], useTLS, - }) + }), ); await runClients( clients, @@ -234,7 +234,7 @@ async function main( (client) => { (client as RedisClient).close(); }, - clusterModeEnabled + clusterModeEnabled, ); await new Promise((resolve) => setTimeout(resolve, 100)); } @@ -268,7 +268,7 @@ async function main( (client) => { (client as RedisClientType).disconnect(); }, - clusterModeEnabled + clusterModeEnabled, ); await new Promise((resolve) => setTimeout(resolve, 100)); @@ -297,7 +297,7 @@ async function main( (client) => { (client as RedisClientType).disconnect(); }, - clusterModeEnabled + clusterModeEnabled, ); } } @@ -313,20 +313,20 @@ Promise.resolve() // just added to clean the indentation of the rest of the call const clientCount: string[] = receivedOptions.clientCount; const lambda: ( numOfClients: string, - concurrentTasks: string + concurrentTasks: string, ) => [number, number, number] = ( numOfClients: string, - concurrentTasks: string + concurrentTasks: string, ) => [parseInt(concurrentTasks), dataSize, parseInt(numOfClients)]; const product: [number, number, number][] = concurrentTasks .flatMap((concurrentTasks: string) => clientCount.map((clientCount) => - lambda(clientCount, concurrentTasks) - ) + lambda(clientCount, concurrentTasks), + ), ) .filter( ([concurrentTasks, , clientCount]) => - clientCount <= concurrentTasks + clientCount <= concurrentTasks, ); for (const [concurrentTasks, dataSize, clientCount] of product) { @@ -342,7 +342,7 @@ Promise.resolve() // just added to clean the indentation of the rest of the call clientCount, receivedOptions.tls, receivedOptions.clusterModeEnabled, - receivedOptions.port + receivedOptions.port, ); } diff --git a/node/DEVELOPER.md b/node/DEVELOPER.md index da0ff8522f..1e083e090f 100644 --- a/node/DEVELOPER.md +++ b/node/DEVELOPER.md @@ -153,7 +153,7 @@ Development on the Node wrapper may involve changes in either the TypeScript or npm install eslint-plugin-import@latest @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tsdoc eslint typescript eslint-plugin-import@latest eslint-config-prettier prettier npm i npx eslint . --max-warnings=0 - npm run prettier:check:ci + npx run prettier:check:ci ``` 2. Rust ```bash