Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

feat(ts/e2e): improve performance on CI via skippable matrix

jkomyno118431eca875
diff --git a/.github/workflows/ts.test-e2e.yml b/.github/workflows/ts.test-e2e.yml
index 24b4fb6cd..5743886d1 100644
--- a/.github/workflows/ts.test-e2e.yml
+++ b/.github/workflows/ts.test-e2e.yml
@@ -12,13 +12,20 @@ on:
jobs:
# Node.js E2E tests, running in Docker to isolate environment
- # Each test suite defines its own nodeVersions in config.ts
+ # Each test suite defines its own nodeVersions in e2e.test.ts
+ # Tests that don't support the matrix version are automatically skipped
test-e2e-node-docker:
- name: E2E Test Node.js
+ name: E2E Test Node.js ${{ matrix.node-version }}
runs-on: ubuntu-24.04
permissions: read-all
+ strategy:
+ fail-fast: false
+ matrix:
+ node-version: ['20.18.0', '20.19.0', '22.12.0']
env:
+ CI: 1
COMPOSIO_API_KEY: ${{ secrets.COMPOSIO_API_KEY }}
+ COMPOSIO_E2E_NODE_VERSION: ${{ matrix.node-version }}
steps:
- name: Checkout Code
diff --git a/ts/e2e-tests/_utils/src/config.ts b/ts/e2e-tests/_utils/src/config.ts
index 11992dd9f..ee9dab2b8 100644
--- a/ts/e2e-tests/_utils/src/config.ts
+++ b/ts/e2e-tests/_utils/src/config.ts
@@ -1,7 +1,24 @@
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
+import { readFileSync } from 'node:fs';
import process from 'node:process';
-import type { NodeVersionMeta, NodeVersionFromUser } from './types';
+import type { NodeVersionMeta, NodeVersionFromUser, SkipInCI } from './types';
+
+declare module 'bun' {
+ interface Env {
+ CI?: string;
+ COMPOSIO_E2E_NODE_VERSION?: string;
+ }
+}
+
+type NonEmptyArray<T> = [T, ...T[]];
+
+/**
+ * Determine if we're running in a Continuous Integration suite.
+ */
+export function isCI(): boolean {
+ return Boolean(Bun.env.CI);
+}
/**
* Get the repository root path.
@@ -14,36 +31,100 @@ export function getRepoRoot(): string {
}
/**
- * Resolve the Node.js versions to test against.
+ * Resolve the Node.js versions to test against, with CI skip state.
*
- * Resolution order:
- * 1. COMPOSIO_E2E_NODE_VERSION env var (overrides everything)
- * 2. Provided nodeVersions from config
- * 3. Current Node.js runtime version
+ * In CI mode (CI env var set + COMPOSIO_E2E_NODE_VERSION set):
+ * - Returns all configured versions, each with skipInCI computed
+ * - Versions not matching COMPOSIO_E2E_NODE_VERSION are marked to skip
+ * - 'current' versions only run when COMPOSIO_E2E_NODE_VERSION matches .nvmrc
+ *
+ * In local mode:
+ * - COMPOSIO_E2E_NODE_VERSION overrides everything (single version, no skip)
+ * - Otherwise returns all configured versions (no skip)
*/
export function resolveNodeVersionMetaList(
configNodeVersions?: readonly NodeVersionFromUser[]
-): readonly NodeVersionMeta[] {
- const envVersion = process.env.COMPOSIO_E2E_NODE_VERSION;
- if (envVersion) {
- return [{ kind: 'overridden', value: envVersion }];
+): NonEmptyArray<NodeVersionMeta> {
+ const envVersion = Bun.env.COMPOSIO_E2E_NODE_VERSION;
+ const currentNodeVersion = process.versions.node;
+
+ // Local mode with env override: single version, no skip
+ if (!isCI() && envVersion) {
+ return [{ kind: 'overridden', value: envVersion, skip: { value: false } }];
}
- const currentNodeVersion = process.versions.node;
+ // No config provided: use current Node version
+ if (configNodeVersions === undefined || configNodeVersions.length === 0) {
+ return [{ kind: 'current', value: currentNodeVersion, skip: { value: false } }];
+ }
+
+ // Resolve versions with skip state
+ const nvmrcVersion = getNvmrcVersion();
+
+ const resolvedVersions = configNodeVersions.map((v): NodeVersionMeta => {
+ const isCurrent = v === 'current';
+ if (isCurrent) {
+ const skip = computeSkipForVersion(envVersion, currentNodeVersion, isCurrent, nvmrcVersion);
+ return { kind: 'current', value: currentNodeVersion, skip };
+ } else {
+ const skip = computeSkipForVersion(envVersion, v, isCurrent, nvmrcVersion);
+ return { kind: 'static', value: v, skip };
+ }
+ });
- if (configNodeVersions === undefined) {
- return [{ kind: 'current', value: currentNodeVersion }];
+ return resolvedVersions as NonEmptyArray<NodeVersionMeta>;
+}
+
+/**
+ * Compute skip state for a single version in CI mode.
+ */
+function computeSkipForVersion(
+ envVersion: string | undefined,
+ versionValue: string,
+ isCurrent: boolean,
+ nvmrcVersion: string
+): SkipInCI {
+ // Not in CI or no env version: don't skip
+ if (!isCI() || !envVersion) {
+ return { value: false };
+ }
+
+ // 'current' in CI means "run only on .nvmrc version"
+ if (isCurrent) {
+ if (envVersion !== nvmrcVersion) {
+ return {
+ value: true,
+ reason: `'current' runs only on .nvmrc version ${nvmrcVersion}`,
+ };
+ }
+ return { value: false };
+ }
+
+ // Static version: skip if doesn't match env version
+ if (versionValue !== envVersion) {
+ return {
+ value: true,
+ reason: `Node ${versionValue} not selected (running ${envVersion})`,
+ };
}
- const distinctNodeVersions = Array.from(
- new Set(
- configNodeVersions
- .map((v => v === 'current'
- ? { kind: 'current', value: currentNodeVersion } as const
- : { kind: 'static', value: v } as const)
- )
- )
- );
-
- return distinctNodeVersions;
+ return { value: false };
}
+
+/**
+ * Read the Node.js version from .nvmrc file.
+ * Used in CI to determine which version 'current' tests should run on.
+ */
+export function getNvmrcVersion(): string {
+ try {
+ const nvmrc = readFileSync(resolve(getRepoRoot(), '.nvmrc'), 'utf-8');
+ return nvmrc.trim();
+ } catch {
+ console.warn(
+ 'Failed to read .nvmrc, falling back to current Node version',
+ process.versions.node
+ );
+ return process.versions.node;
+ }
+}
+
diff --git a/ts/e2e-tests/_utils/src/index.ts b/ts/e2e-tests/_utils/src/index.ts
index 028904a86..4e0c86c7d 100644
--- a/ts/e2e-tests/_utils/src/index.ts
+++ b/ts/e2e-tests/_utils/src/index.ts
@@ -1,3 +1,3 @@
-export type { E2EConfig, E2ETestResult, DefineTestsContext, NodeVersionMeta as NodeVersion } from './types';
+export type { E2EConfig, E2ETestResult, DefineTestsContext, NodeVersionMeta as NodeVersion, SkipInCI } from './types';
export { e2e } from './e2e';
export { sanitizeOutput } from './sanitize';
diff --git a/ts/e2e-tests/_utils/src/runner.ts b/ts/e2e-tests/_utils/src/runner.ts
index e703ef314..397ccdb62 100644
--- a/ts/e2e-tests/_utils/src/runner.ts
+++ b/ts/e2e-tests/_utils/src/runner.ts
@@ -1,4 +1,4 @@
-import { describe, beforeAll } from 'bun:test';
+import { describe, beforeAll, it } from 'bun:test';
import type { E2EConfig, E2ETestResult, NodeVersionMeta } from './types';
import { getRepoRoot, resolveNodeVersionMetaList } from './config';
import { ensureNodeImage, runNodeContainer } from './image-lifecycle';
@@ -70,6 +70,9 @@ function createDockerExecutors(
/**
* Runs e2e tests using bun:test.
* Creates a describe block per Node version and passes test utilities to defineTests.
+ *
+ * In CI mode, versions not matching COMPOSIO_E2E_NODE_VERSION are skipped.
+ * Each version's skipInCI state is computed by resolveNodeVersionMetaList().
*/
export function runE2E(config: RunE2EInternalConfig): void {
const { suiteName, defineTests } = config;
@@ -88,7 +91,17 @@ export function runE2E(config: RunE2EInternalConfig): void {
}
for (const nodeVersionMeta of nodeVersionMetaList) {
- describe(`${suiteName} (Node ${renderNodeVersionMeta(nodeVersionMeta)})`, () => {
+ const testName = `${suiteName} (${renderNodeVersionMeta(nodeVersionMeta)})`;
+
+ // Skip this version in CI if not selected
+ if (nodeVersionMeta.skip.value) {
+ describe.skip(`${testName} - skipped: ${nodeVersionMeta.skip.reason}`, () => {
+ it('this version should not run in this CI matrix job', () => {});
+ });
+ continue;
+ }
+
+ describe(testName, () => {
let executors: ReturnType<typeof createDockerExecutors>;
// Ensure Docker image exists before tests run
diff --git a/ts/e2e-tests/_utils/src/types.ts b/ts/e2e-tests/_utils/src/types.ts
index 2fd09ee8c..dc9072826 100644
--- a/ts/e2e-tests/_utils/src/types.ts
+++ b/ts/e2e-tests/_utils/src/types.ts
@@ -2,10 +2,22 @@ import { WELL_KNOWN_NODE_VERSIONS } from './const';
export type NodeVersionFromUser = typeof WELL_KNOWN_NODE_VERSIONS[number];
+/**
+ * Result of CI skip check for a specific Node version.
+ */
+export interface SkipInCI {
+ value: boolean;
+ reason?: string;
+}
+
+/**
+ * Metadata for a resolved Node.js version to test against.
+ * Includes skip state for CI mode.
+ */
export type NodeVersionMeta =
- | { kind: 'static', value: Exclude<typeof WELL_KNOWN_NODE_VERSIONS[number], 'current'> }
- | { kind: 'overridden', value: string }
- | { kind: 'current', value: string };
+ | { kind: 'static'; value: Exclude<typeof WELL_KNOWN_NODE_VERSIONS[number], 'current'>; skip: SkipInCI }
+ | { kind: 'overridden'; value: string; skip: SkipInCI }
+ | { kind: 'current'; value: string; skip: SkipInCI };
/**
* Result of executing a command in a Docker container.