diff --git a/jest.config.ts b/jest.config.ts index 9c1411e07bfd74539963d92294147d8575c889fe..76464c3ef7d7afa9d1ace238a1e5819ca95841c5 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,4 +1,5 @@ import os from 'os'; +import v8 from 'v8'; import type { InitialOptionsTsJest } from 'ts-jest/dist/types'; const ci = !!process.env.CI; @@ -8,21 +9,31 @@ type JestConfig = InitialOptionsTsJest & { workerIdleMemoryLimit?: string; }; +const cpus = os.cpus(); +const mem = os.totalmem(); +const stats = v8.getHeapStatistics(); + +process.stderr.write(`Host stats: + Cpus: ${cpus.length} + Memory: ${(mem / 1024 / 1024 / 1024).toFixed(2)} GB + HeapLimit: ${(stats.heap_size_limit / 1024 / 1024 / 1024).toFixed(2)} GB +`); + /** * https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources + * Currently it seems the runner only have 4GB */ function jestGithubRunnerSpecs(): JestConfig { - if (os.platform() === 'darwin') { - // - return { - maxWorkers: 2, - workerIdleMemoryLimit: '4GB', - }; - } + // if (os.platform() === 'darwin') { + // return { + // maxWorkers: 2, + // workerIdleMemoryLimit: '4GB', + // }; + // } return { maxWorkers: 2, - workerIdleMemoryLimit: '2GB', + workerIdleMemoryLimit: '1500MB', // '2GB', }; }