Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Add Windows CI to test matrix (#1020)

Mish Ushakov6ff14f8b2ea4
diff --git a/.changeset/warm-items-dig.md b/.changeset/warm-items-dig.md
new file mode 100644
index 000000000..0c7ae7077
--- /dev/null
+++ b/.changeset/warm-items-dig.md
@@ -0,0 +1,5 @@
+---
+'e2b': patch
+---
+
+various windows patches
diff --git a/.github/workflows/cli_tests.yml b/.github/workflows/cli_tests.yml
index fd105a721..7a9f94e3f 100644
--- a/.github/workflows/cli_tests.yml
+++ b/.github/workflows/cli_tests.yml
@@ -14,8 +14,15 @@ permissions:
jobs:
test:
- name: CLI - Build
- runs-on: ubuntu-22.04
+ defaults:
+ run:
+ working-directory: ./packages/cli
+ shell: bash
+ name: CLI - Build (${{ matrix.os }})
+ strategy:
+ matrix:
+ os: [ubuntu-22.04, windows-latest]
+ runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
diff --git a/.github/workflows/js_sdk_tests.yml b/.github/workflows/js_sdk_tests.yml
index 083702a5f..31e58a32f 100644
--- a/.github/workflows/js_sdk_tests.yml
+++ b/.github/workflows/js_sdk_tests.yml
@@ -17,8 +17,13 @@ jobs:
defaults:
run:
working-directory: ./packages/js-sdk
- name: JS SDK - Build and test
- runs-on: ubuntu-22.04
+ shell: bash
+ name: JS SDK - Build and test (${{ matrix.os }})
+ strategy:
+ matrix:
+ os: [ubuntu-22.04, windows-latest]
+ fail-fast: false
+ runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
diff --git a/.github/workflows/python_sdk_tests.yml b/.github/workflows/python_sdk_tests.yml
index 137bc39b3..51075c80f 100644
--- a/.github/workflows/python_sdk_tests.yml
+++ b/.github/workflows/python_sdk_tests.yml
@@ -17,8 +17,13 @@ jobs:
defaults:
run:
working-directory: ./packages/python-sdk
- name: Python SDK -Build and test
- runs-on: ubuntu-22.04
+ shell: bash
+ name: Python SDK - Build and test (${{ matrix.os }})
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ubuntu-22.04, windows-latest]
+ runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -50,6 +55,6 @@ jobs:
run: poetry build
- name: Run tests
- run: make test
+ run: poetry run pytest --verbose --numprocesses=4
env:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
diff --git a/packages/js-sdk/src/template/utils.ts b/packages/js-sdk/src/template/utils.ts
index bc3273c44..204991fde 100644
--- a/packages/js-sdk/src/template/utils.ts
+++ b/packages/js-sdk/src/template/utils.ts
@@ -24,6 +24,15 @@ export function readDockerignore(contextPath: string): string[] {
.filter((line) => line && !line.startsWith('#'))
}
+/**
+ * Normalize path separators to forward slashes for glob patterns (glob expects / even on Windows)
+ * @param path - The path to normalize
+ * @returns The normalized path
+ */
+function normalizePath(path: string): string {
+ return path.replace(/\\/g, '/')
+}
+
/**
* Get all files for a given path and ignore patterns.
*
@@ -54,14 +63,11 @@ export async function getAllFilesInPath(
if (includeDirectories) {
files.set(file.fullpath(), file)
}
- const dirFiles = await glob(
- path.join(path.relative(contextPath, file.fullpath()), '**/*'),
- {
- ignore: ignorePatterns,
- withFileTypes: true,
- cwd: contextPath,
- }
- )
+ const dirFiles = await glob(normalizePath(file.relative()) + '/**/*', {
+ ignore: ignorePatterns,
+ withFileTypes: true,
+ cwd: contextPath,
+ })
dirFiles.forEach((f) => files.set(f.fullpath(), f))
} else {
// For files, just add the file
@@ -120,7 +126,7 @@ export async function calculateFilesHash(
// Process files recursively
for (const file of files) {
// Add a relative path to hash calculation
- const relativePath = path.relative(contextPath, file.fullpath())
+ const relativePath = file.relativePosix()
hash.update(relativePath)
// Add stat information to hash calculation
@@ -255,9 +261,7 @@ export async function tarFileStream(
true
)
- const filePaths = allFiles.map((file) =>
- path.relative(fileContextPath, file.fullpath())
- )
+ const filePaths = allFiles.map((file) => file.relativePosix())
return create(
{
diff --git a/packages/js-sdk/tests/template/stacktrace.test.ts b/packages/js-sdk/tests/template/stacktrace.test.ts
index f70a0ffac..4463620a7 100644
--- a/packages/js-sdk/tests/template/stacktrace.test.ts
+++ b/packages/js-sdk/tests/template/stacktrace.test.ts
@@ -20,9 +20,15 @@ function getStackTraceCallerMethod(
}
const callerTrace = stackTraceLines[0]
- const [, line, column] = callerTrace.split(':')
- const lineNumber = parseInt(line)
- const columnNumber = parseInt(column)
+ // Match line and column numbers at the end of the stack trace line
+ // Format: ...file.ts:123:45) or ...file.ts:123:45
+ // This handles Windows paths (C:\Users\...) and Unix paths
+ const lineColumnMatch = callerTrace.match(/:(\d+):(\d+)\)?$/)
+ if (!lineColumnMatch) {
+ return null
+ }
+ const lineNumber = parseInt(lineColumnMatch[1])
+ const columnNumber = parseInt(lineColumnMatch[2])
const lines = fileContent.split('\n')
const parsedLine = lines[lineNumber - 1]
@@ -30,9 +36,12 @@ function getStackTraceCallerMethod(
return null
}
- const match = parsedLine.slice(columnNumber - 1).match(/^(\w+)\s*\(/)
- if (match) {
- return match[1]
+ // Extract the method name from the line
+ const methodNameMatch = parsedLine
+ .slice(columnNumber - 1)
+ .match(/^(\w+)\s*\(/)
+ if (methodNameMatch) {
+ return methodNameMatch[1]
}
return null
}
diff --git a/packages/js-sdk/tests/template/utils/getAllFilesInPath.test.ts b/packages/js-sdk/tests/template/utils/getAllFilesInPath.test.ts
index 3f14a7239..89b4c6c33 100644
--- a/packages/js-sdk/tests/template/utils/getAllFilesInPath.test.ts
+++ b/packages/js-sdk/tests/template/utils/getAllFilesInPath.test.ts
@@ -1,6 +1,6 @@
import { expect, test, describe, beforeAll, afterAll, beforeEach } from 'vitest'
import { writeFile, mkdir, rm } from 'fs/promises'
-import { join } from 'path'
+import { join, basename } from 'path'
import { getAllFilesInPath } from '../../../src/template/utils'
describe('getAllFilesInPath', () => {
@@ -196,7 +196,7 @@ describe('getAllFilesInPath', () => {
expect(files).toHaveLength(3)
// Files are sorted by full path, not just filename
- const fileNames = files.map((f) => f.fullpath().split('/').pop()).sort()
+ const fileNames = files.map((f) => basename(f.fullpath())).sort()
expect(fileNames).toEqual(['apple.txt', 'banana.txt', 'zebra.txt'])
})
diff --git a/packages/python-sdk/e2b/template/utils.py b/packages/python-sdk/e2b/template/utils.py
index 68c6726b1..413c58a4f 100644
--- a/packages/python-sdk/e2b/template/utils.py
+++ b/packages/python-sdk/e2b/template/utils.py
@@ -35,6 +35,16 @@ def read_dockerignore(context_path: str) -> List[str]:
]
+def normalize_path(path: str) -> str:
+ """
+ Normalize path separators to forward slashes for glob patterns (glob expects / even on Windows).
+
+ :param path: The path to normalize
+ :return: The normalized path
+ """
+ return path.replace(os.sep, "/")
+
+
def get_all_files_in_path(
src: str,
context_path: str,
@@ -70,7 +80,7 @@ def get_all_files_in_path(
if include_directories:
files.add(file_path)
dir_files = glob.glob(
- os.path.join(file, "**/*"),
+ normalize_path(file) + "/**/*",
flags=glob.GLOBSTAR,
root_dir=abs_context_path,
exclude=ignore_patterns,
diff --git a/packages/python-sdk/tests/shared/template/utils/test_tar_file_stream.py b/packages/python-sdk/tests/shared/template/utils/test_tar_file_stream.py
index 63b5cf322..672b937e9 100644
--- a/packages/python-sdk/tests/shared/template/utils/test_tar_file_stream.py
+++ b/packages/python-sdk/tests/shared/template/utils/test_tar_file_stream.py
@@ -10,8 +10,9 @@ class TestTarFileStream:
@pytest.fixture
def test_dir(self):
"""Create a temporary directory for testing."""
- with tempfile.TemporaryDirectory() as tmpdir:
- yield tmpdir
+ tmpdir = tempfile.TemporaryDirectory()
+ yield tmpdir.name
+ tmpdir.cleanup()
def _extract_tar_contents(self, tar_buffer: io.BytesIO) -> dict:
"""Extract tar contents into a dictionary mapping paths to file contents."""