Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 13:15 UTC
feat(ts/e2e): improve performance on CI via skippable matrix
jkomyno committed
Jan 27, 2026 at 03:50 UTC
118431eca875817c57b84f9cffd7b212a54bfe7e
5 files changed
+145
-32
.github/workflows/ts.test-e2e.yml
+9
-2
@@ -12,13 +12,20 @@ on:
12
13
jobs:
14
# Node.js E2E tests, running in Docker to isolate environment
15
- # Each test suite defines its own nodeVersions in config.ts
15
+ # Each test suite defines its own nodeVersions in e2e.test.ts
16
+ # Tests that don't support the matrix version are automatically skipped
17
test-e2e-node-docker:
17
- name: E2E Test Node.js
18
+ name: E2E Test Node.js ${{ matrix.node-version }}
19
runs-on: ubuntu-24.04
20
permissions: read-all
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ node-version: ['20.18.0', '20.19.0', '22.12.0']
25
env:
26
+ CI: 1
27
COMPOSIO_API_KEY: ${{ secrets.COMPOSIO_API_KEY }}
28
+ COMPOSIO_E2E_NODE_VERSION: ${{ matrix.node-version }}
29
30
steps:
31
- name: Checkout Code
ts/e2e-tests/_utils/src/config.ts
+105
-24
@@ -1,7 +1,24 @@
1
import { dirname, resolve } from 'node:path';
2
import { fileURLToPath } from 'node:url';
3
+import { readFileSync } from 'node:fs';
4
import process from 'node:process';
4
-import type { NodeVersionMeta, NodeVersionFromUser } from './types';
5
+import type { NodeVersionMeta, NodeVersionFromUser, SkipInCI } from './types';
6
+
7
+declare module 'bun' {
8
+ interface Env {
9
+ CI?: string;
10
+ COMPOSIO_E2E_NODE_VERSION?: string;
11
+ }
12
+}
13
+
14
+type NonEmptyArray<T> = [T, ...T[]];
15
+
16
+/**
17
+ * Determine if we're running in a Continuous Integration suite.
18
+ */
19
+export function isCI(): boolean {
20
+ return Boolean(Bun.env.CI);
21
+}
22
23
/**
24
* Get the repository root path.
@@ -14,36 +31,100 @@ export function getRepoRoot(): string {
31
}
32
33
/**
17
- * Resolve the Node.js versions to test against.
34
+ * Resolve the Node.js versions to test against, with CI skip state.
35
*
19
- * Resolution order:
20
- * 1. COMPOSIO_E2E_NODE_VERSION env var (overrides everything)
21
- * 2. Provided nodeVersions from config
22
- * 3. Current Node.js runtime version
36
+ * In CI mode (CI env var set + COMPOSIO_E2E_NODE_VERSION set):
37
+ * - Returns all configured versions, each with skipInCI computed
38
+ * - Versions not matching COMPOSIO_E2E_NODE_VERSION are marked to skip
39
+ * - 'current' versions only run when COMPOSIO_E2E_NODE_VERSION matches .nvmrc
40
+ *
41
+ * In local mode:
42
+ * - COMPOSIO_E2E_NODE_VERSION overrides everything (single version, no skip)
43
+ * - Otherwise returns all configured versions (no skip)
44
*/
45
export function resolveNodeVersionMetaList(
46
configNodeVersions?: readonly NodeVersionFromUser[]
26
-): readonly NodeVersionMeta[] {
27
- const envVersion = process.env.COMPOSIO_E2E_NODE_VERSION;
28
- if (envVersion) {
29
- return [{ kind: 'overridden', value: envVersion }];
47
+): NonEmptyArray<NodeVersionMeta> {
48
+ const envVersion = Bun.env.COMPOSIO_E2E_NODE_VERSION;
49
+ const currentNodeVersion = process.versions.node;
50
+
51
+ // Local mode with env override: single version, no skip
52
+ if (!isCI() && envVersion) {
53
+ return [{ kind: 'overridden', value: envVersion, skip: { value: false } }];
54
}
55
32
- const currentNodeVersion = process.versions.node;
56
+ // No config provided: use current Node version
57
+ if (configNodeVersions === undefined || configNodeVersions.length === 0) {
58
+ return [{ kind: 'current', value: currentNodeVersion, skip: { value: false } }];
59
+ }
60
+
61
+ // Resolve versions with skip state
62
+ const nvmrcVersion = getNvmrcVersion();
63
+
64
+ const resolvedVersions = configNodeVersions.map((v): NodeVersionMeta => {
65
+ const isCurrent = v === 'current';
66
+ if (isCurrent) {
67
+ const skip = computeSkipForVersion(envVersion, currentNodeVersion, isCurrent, nvmrcVersion);
68
+ return { kind: 'current', value: currentNodeVersion, skip };
69
+ } else {
70
+ const skip = computeSkipForVersion(envVersion, v, isCurrent, nvmrcVersion);
71
+ return { kind: 'static', value: v, skip };
72
+ }
73
+ });
74
34
- if (configNodeVersions === undefined) {
35
- return [{ kind: 'current', value: currentNodeVersion }];
75
+ return resolvedVersions as NonEmptyArray<NodeVersionMeta>;
76
+}
77
+
78
+/**
79
+ * Compute skip state for a single version in CI mode.
80
+ */
81
+function computeSkipForVersion(
82
+ envVersion: string | undefined,
83
+ versionValue: string,
84
+ isCurrent: boolean,
85
+ nvmrcVersion: string
86
+): SkipInCI {
87
+ // Not in CI or no env version: don't skip
88
+ if (!isCI() || !envVersion) {
89
+ return { value: false };
90
+ }
91
+
92
+ // 'current' in CI means "run only on .nvmrc version"
93
+ if (isCurrent) {
94
+ if (envVersion !== nvmrcVersion) {
95
+ return {
96
+ value: true,
97
+ reason: `'current' runs only on .nvmrc version ${nvmrcVersion}`,
98
+ };
99
+ }
100
+ return { value: false };
101
+ }
102
+
103
+ // Static version: skip if doesn't match env version
104
+ if (versionValue !== envVersion) {
105
+ return {
106
+ value: true,
107
+ reason: `Node ${versionValue} not selected (running ${envVersion})`,
108
+ };
109
}
110
38
- const distinctNodeVersions = Array.from(
39
- new Set(
40
- configNodeVersions
41
- .map((v => v === 'current'
42
- ? { kind: 'current', value: currentNodeVersion } as const
43
- : { kind: 'static', value: v } as const)
44
- )
45
- )
46
- );
47
-
48
- return distinctNodeVersions;
111
+ return { value: false };
112
}
113
+
114
+/**
115
+ * Read the Node.js version from .nvmrc file.
116
+ * Used in CI to determine which version 'current' tests should run on.
117
+ */
118
+export function getNvmrcVersion(): string {
119
+ try {
120
+ const nvmrc = readFileSync(resolve(getRepoRoot(), '.nvmrc'), 'utf-8');
121
+ return nvmrc.trim();
122
+ } catch {
123
+ console.warn(
124
+ 'Failed to read .nvmrc, falling back to current Node version',
125
+ process.versions.node
126
+ );
127
+ return process.versions.node;
128
+ }
129
+}
130
+
ts/e2e-tests/_utils/src/index.ts
+1
-1
@@ -1,3 +1,3 @@
1
-export type { E2EConfig, E2ETestResult, DefineTestsContext, NodeVersionMeta as NodeVersion } from './types';
1
+export type { E2EConfig, E2ETestResult, DefineTestsContext, NodeVersionMeta as NodeVersion, SkipInCI } from './types';
2
export { e2e } from './e2e';
3
export { sanitizeOutput } from './sanitize';
ts/e2e-tests/_utils/src/runner.ts
+15
-2
@@ -1,4 +1,4 @@
1
-import { describe, beforeAll } from 'bun:test';
1
+import { describe, beforeAll, it } from 'bun:test';
2
import type { E2EConfig, E2ETestResult, NodeVersionMeta } from './types';
3
import { getRepoRoot, resolveNodeVersionMetaList } from './config';
4
import { ensureNodeImage, runNodeContainer } from './image-lifecycle';
@@ -70,6 +70,9 @@ function createDockerExecutors(
70
/**
71
* Runs e2e tests using bun:test.
72
* Creates a describe block per Node version and passes test utilities to defineTests.
73
+ *
74
+ * In CI mode, versions not matching COMPOSIO_E2E_NODE_VERSION are skipped.
75
+ * Each version's skipInCI state is computed by resolveNodeVersionMetaList().
76
*/
77
export function runE2E(config: RunE2EInternalConfig): void {
78
const { suiteName, defineTests } = config;
@@ -88,7 +91,17 @@ export function runE2E(config: RunE2EInternalConfig): void {
91
}
92
93
for (const nodeVersionMeta of nodeVersionMetaList) {
91
- describe(`${suiteName} (Node ${renderNodeVersionMeta(nodeVersionMeta)})`, () => {
94
+ const testName = `${suiteName} (${renderNodeVersionMeta(nodeVersionMeta)})`;
95
+
96
+ // Skip this version in CI if not selected
97
+ if (nodeVersionMeta.skip.value) {
98
+ describe.skip(`${testName} - skipped: ${nodeVersionMeta.skip.reason}`, () => {
99
+ it('this version should not run in this CI matrix job', () => {});
100
+ });
101
+ continue;
102
+ }
103
+
104
+ describe(testName, () => {
105
let executors: ReturnType<typeof createDockerExecutors>;
106
107
// Ensure Docker image exists before tests run
ts/e2e-tests/_utils/src/types.ts
+15
-3
@@ -2,10 +2,22 @@ import { WELL_KNOWN_NODE_VERSIONS } from './const';
2
3
export type NodeVersionFromUser = typeof WELL_KNOWN_NODE_VERSIONS[number];
4
5
+/**
6
+ * Result of CI skip check for a specific Node version.
7
+ */
8
+export interface SkipInCI {
9
+ value: boolean;
10
+ reason?: string;
11
+}
12
+
13
+/**
14
+ * Metadata for a resolved Node.js version to test against.
15
+ * Includes skip state for CI mode.
16
+ */
17
export type NodeVersionMeta =
6
- | { kind: 'static', value: Exclude<typeof WELL_KNOWN_NODE_VERSIONS[number], 'current'> }
7
- | { kind: 'overridden', value: string }
8
- | { kind: 'current', value: string };
18
+ | { kind: 'static'; value: Exclude<typeof WELL_KNOWN_NODE_VERSIONS[number], 'current'>; skip: SkipInCI }
19
+ | { kind: 'overridden'; value: string; skip: SkipInCI }
20
+ | { kind: 'current'; value: string; skip: SkipInCI };
21
22
/**
23
* Result of executing a command in a Docker container.