From 7611cbacf0122197f51d4b9172198b7f2352fa0e Mon Sep 17 00:00:00 2001 From: Ben Burns <803016+benjamincburns@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:27:18 +1300 Subject: [PATCH] skip dockerized tests in CI on Windows and M-series mac --- libs/checkpoint-validation/package.json | 1 + .../src/spec/getTuple.ts | 1 - libs/checkpoint-validation/src/spec/index.ts | 1 - libs/checkpoint-validation/src/spec/list.ts | 1 - libs/checkpoint-validation/src/spec/put.ts | 1 - .../src/spec/putWrites.ts | 1 - libs/checkpoint-validation/src/spec/util.ts | 1 - libs/checkpoint-validation/src/testUtils.ts | 6 ++-- .../src/tests/mongodb.spec.ts | 7 +++- .../src/tests/postgres.spec.ts | 7 +++- libs/checkpoint-validation/src/tests/utils.ts | 33 +++++++++++++++++++ libs/checkpoint-validation/tsconfig.json | 1 + yarn.lock | 15 +++++++-- 13 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 libs/checkpoint-validation/src/tests/utils.ts diff --git a/libs/checkpoint-validation/package.json b/libs/checkpoint-validation/package.json index 0aa64ae0..d87e01bd 100644 --- a/libs/checkpoint-validation/package.json +++ b/libs/checkpoint-validation/package.json @@ -55,6 +55,7 @@ "@testcontainers/mongodb": "^10.13.2", "@testcontainers/postgresql": "^10.13.2", "@tsconfig/recommended": "^1.0.3", + "@types/jest": "^29.5.13", "@types/uuid": "^10", "@typescript-eslint/eslint-plugin": "^6.12.0", "@typescript-eslint/parser": "^6.12.0", diff --git a/libs/checkpoint-validation/src/spec/getTuple.ts b/libs/checkpoint-validation/src/spec/getTuple.ts index 2ccd0bb4..a31c1647 100644 --- a/libs/checkpoint-validation/src/spec/getTuple.ts +++ b/libs/checkpoint-validation/src/spec/getTuple.ts @@ -5,7 +5,6 @@ import { uuid6, type BaseCheckpointSaver, } from "@langchain/langgraph-checkpoint"; -import { describe, it, beforeAll, afterAll, expect } from "@jest/globals"; import { mergeConfigs, RunnableConfig } from "@langchain/core/runnables"; import { CheckpointSaverTestInitializer } from "../types.js"; import { parentAndChildCheckpointTuplesWithWrites } from "./data.js"; diff --git a/libs/checkpoint-validation/src/spec/index.ts b/libs/checkpoint-validation/src/spec/index.ts index faa2b03e..ccce443d 100644 --- a/libs/checkpoint-validation/src/spec/index.ts +++ b/libs/checkpoint-validation/src/spec/index.ts @@ -1,5 +1,4 @@ import { type BaseCheckpointSaver } from "@langchain/langgraph-checkpoint"; -import { describe, beforeAll, afterAll } from "@jest/globals"; import { CheckpointSaverTestInitializer, TestTypeFilter } from "../types.js"; import { putTests } from "./put.js"; diff --git a/libs/checkpoint-validation/src/spec/list.ts b/libs/checkpoint-validation/src/spec/list.ts index 79fac0ec..a38992d6 100644 --- a/libs/checkpoint-validation/src/spec/list.ts +++ b/libs/checkpoint-validation/src/spec/list.ts @@ -4,7 +4,6 @@ import { uuid6, type BaseCheckpointSaver, } from "@langchain/langgraph-checkpoint"; -import { describe, it, beforeAll, afterAll, expect } from "@jest/globals"; import { mergeConfigs, RunnableConfig } from "@langchain/core/runnables"; import { CheckpointSaverTestInitializer } from "../types.js"; import { generateTuplePairs } from "./data.js"; diff --git a/libs/checkpoint-validation/src/spec/put.ts b/libs/checkpoint-validation/src/spec/put.ts index 469e557c..d2c16bfd 100644 --- a/libs/checkpoint-validation/src/spec/put.ts +++ b/libs/checkpoint-validation/src/spec/put.ts @@ -5,7 +5,6 @@ import { uuid6, type BaseCheckpointSaver, } from "@langchain/langgraph-checkpoint"; -import { describe, it, afterEach, beforeEach, expect } from "@jest/globals"; import { mergeConfigs, RunnableConfig } from "@langchain/core/runnables"; import { CheckpointSaverTestInitializer } from "../types.js"; import { initialCheckpointTuple } from "./data.js"; diff --git a/libs/checkpoint-validation/src/spec/putWrites.ts b/libs/checkpoint-validation/src/spec/putWrites.ts index 33389d59..43f179d2 100644 --- a/libs/checkpoint-validation/src/spec/putWrites.ts +++ b/libs/checkpoint-validation/src/spec/putWrites.ts @@ -5,7 +5,6 @@ import { uuid6, type BaseCheckpointSaver, } from "@langchain/langgraph-checkpoint"; -import { describe, it, beforeEach, afterEach, expect } from "@jest/globals"; import { mergeConfigs, RunnableConfig } from "@langchain/core/runnables"; import { CheckpointSaverTestInitializer } from "../types.js"; import { initialCheckpointTuple } from "./data.js"; diff --git a/libs/checkpoint-validation/src/spec/util.ts b/libs/checkpoint-validation/src/spec/util.ts index 35c3169e..36f0dab7 100644 --- a/libs/checkpoint-validation/src/spec/util.ts +++ b/libs/checkpoint-validation/src/spec/util.ts @@ -1,4 +1,3 @@ -import { expect } from "@jest/globals"; import { mergeConfigs, RunnableConfig } from "@langchain/core/runnables"; import { BaseCheckpointSaver, diff --git a/libs/checkpoint-validation/src/testUtils.ts b/libs/checkpoint-validation/src/testUtils.ts index 416d3654..af2d661b 100644 --- a/libs/checkpoint-validation/src/testUtils.ts +++ b/libs/checkpoint-validation/src/testUtils.ts @@ -1,5 +1,3 @@ -import { it } from "@jest/globals"; - // to make the type signature of the skipOnModules function a bit more readable export type SaverName = string; export type WhySkipped = string; @@ -21,7 +19,7 @@ export function it_skipForSomeModules( if (skipReason) { const skip = ( name: string, - test: () => void | Promise, + test: jest.ProvidesCallback | undefined, timeout?: number ) => { it.skip(`[because ${skipReason}] ${name}`, test, timeout); @@ -40,7 +38,7 @@ export function it_skipIfNot( if (!savers.includes(saverName)) { const skip = ( name: string, - test: () => void | Promise, + test: jest.ProvidesCallback | undefined, timeout?: number ) => { it.skip( diff --git a/libs/checkpoint-validation/src/tests/mongodb.spec.ts b/libs/checkpoint-validation/src/tests/mongodb.spec.ts index b7256443..e545b2eb 100644 --- a/libs/checkpoint-validation/src/tests/mongodb.spec.ts +++ b/libs/checkpoint-validation/src/tests/mongodb.spec.ts @@ -1,4 +1,9 @@ import { specTest } from "../spec/index.js"; import { initializer } from "./mongoInitializer.js"; +import { isCI, osHasSupportedContainerRuntime } from "./utils.js"; -specTest(initializer); +if (isCI() && osHasSupportedContainerRuntime()) { + specTest(initializer); +} else { + it.skip(`${initializer.saverName} skipped in CI because no container runtime is available`, () => {}); +} diff --git a/libs/checkpoint-validation/src/tests/postgres.spec.ts b/libs/checkpoint-validation/src/tests/postgres.spec.ts index 828b2425..818f37d3 100644 --- a/libs/checkpoint-validation/src/tests/postgres.spec.ts +++ b/libs/checkpoint-validation/src/tests/postgres.spec.ts @@ -1,4 +1,9 @@ import { specTest } from "../spec/index.js"; import { initializer } from "./postgresInitializer.js"; +import { isCI, osHasSupportedContainerRuntime } from "./utils.js"; -specTest(initializer); +if (isCI() && osHasSupportedContainerRuntime()) { + specTest(initializer); +} else { + it.skip(`${initializer.saverName} skipped in CI because no container runtime is available`, () => {}); +} diff --git a/libs/checkpoint-validation/src/tests/utils.ts b/libs/checkpoint-validation/src/tests/utils.ts new file mode 100644 index 00000000..32c8871d --- /dev/null +++ b/libs/checkpoint-validation/src/tests/utils.ts @@ -0,0 +1,33 @@ +import { platform, arch } from "node:os"; + +function isMSeriesMac() { + return platform() === "darwin" && arch() === "arm64"; +} + +function isWindows() { + return platform() === "win32"; +} + +export function isCI() { + // eslint-disable-next-line no-process-env + return (process.env.CI ?? "").toLowerCase() === "true"; +} + +/** + * GitHub Actions doesn't support containers on m-series macOS due to a lack of hypervisor support for nested + * virtualization. + * + * For details, see https://github.com/actions/runner-images/issues/9460#issuecomment-1981203045 + * + * GitHub actions also doesn't support Linux containers on Windows, and may never do so. This is in part due to Docker + * Desktop licensing restrictions, and the complexity of setting up Moby or similar without Docker Desktop. + * Unfortunately, TestContainers doesn't support windows containers, so we can't run the tests on Windows either. + * + * For details, see https://github.com/actions/runner/issues/904 and + * https://java.testcontainers.org/supported_docker_environment/windows/#windows-container-on-windows-wcow + * + * + */ +export function osHasSupportedContainerRuntime() { + return !isWindows() && !isMSeriesMac(); +} diff --git a/libs/checkpoint-validation/tsconfig.json b/libs/checkpoint-validation/tsconfig.json index 78398e4d..60f0e6b9 100644 --- a/libs/checkpoint-validation/tsconfig.json +++ b/libs/checkpoint-validation/tsconfig.json @@ -5,6 +5,7 @@ "rootDir": "./src", "target": "ES2021", "lib": ["ES2021", "ES2022.Object", "DOM"], + "types": ["node", "jest"], "module": "ES2020", "moduleResolution": "NodeNext", "esModuleInterop": true, diff --git a/yarn.lock b/yarn.lock index c211b52f..369c157e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1785,6 +1785,7 @@ __metadata: "@testcontainers/mongodb": ^10.13.2 "@testcontainers/postgresql": ^10.13.2 "@tsconfig/recommended": ^1.0.3 + "@types/jest": ^29.5.13 "@types/uuid": ^10 "@typescript-eslint/eslint-plugin": ^6.12.0 "@typescript-eslint/parser": ^6.12.0 @@ -3494,6 +3495,16 @@ __metadata: languageName: node linkType: hard +"@types/jest@npm:^29.5.13": + version: 29.5.13 + resolution: "@types/jest@npm:29.5.13" + dependencies: + expect: ^29.0.0 + pretty-format: ^29.0.0 + checksum: 875ac23c2398cdcf22aa56c6ba24560f11d2afda226d4fa23936322dde6202f9fdbd2b91602af51c27ecba223d9fc3c1e33c9df7e47b3bf0e2aefc6baf13ce53 + languageName: node + linkType: hard + "@types/json-schema@npm:^7.0.12": version: 7.0.15 resolution: "@types/json-schema@npm:7.0.15" @@ -6871,7 +6882,7 @@ __metadata: languageName: node linkType: hard -"expect@npm:^29.7.0": +"expect@npm:^29.0.0, expect@npm:^29.7.0": version: 29.7.0 resolution: "expect@npm:29.7.0" dependencies: @@ -10764,7 +10775,7 @@ __metadata: languageName: node linkType: hard -"pretty-format@npm:^29.7.0": +"pretty-format@npm:^29.0.0, pretty-format@npm:^29.7.0": version: 29.7.0 resolution: "pretty-format@npm:29.7.0" dependencies: