Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warm-items-dig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'e2b': patch
---

various windows patches
11 changes: 9 additions & 2 deletions .github/workflows/cli_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/js_sdk_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/python_sdk_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
28 changes: 16 additions & 12 deletions packages/js-sdk/src/template/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
{
Expand Down
21 changes: 15 additions & 6 deletions packages/js-sdk/tests/template/stacktrace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,28 @@ 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]
if (!parsedLine) {
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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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'])
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
Loading