Skip to content
Merged
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
14 changes: 10 additions & 4 deletions .github/workflows/publish_candidates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,12 @@ jobs:
- name: Publish JS RC
if: ${{ inputs.js-sdk }}
working-directory: packages/js-sdk
env:
RC_PREID: ${{ inputs.preid }}
RC_TAG: ${{ inputs.tag }}
run: |
npm version prerelease --preid=${{ inputs.preid }}.${{ github.run_number }} --no-git-tag-version
npm publish --tag ${{ inputs.tag }} --provenance
npm version prerelease --preid="${RC_PREID}.${{ github.run_number }}" --no-git-tag-version
npm publish --tag "$RC_TAG" --provenance

- name: Reinstall dependencies
if: ${{ inputs.js-sdk || inputs.cli }}
Expand All @@ -110,6 +113,9 @@ jobs:
- name: Publish CLI RC
if: ${{ inputs.cli }}
working-directory: packages/cli
env:
RC_PREID: ${{ inputs.preid }}
RC_TAG: ${{ inputs.tag }}
run: |
npm version prerelease --preid=${{ inputs.preid }}.${{ github.run_number }} --no-git-tag-version
npm publish --tag ${{ inputs.tag }} --provenance
npm version prerelease --preid="${RC_PREID}.${{ github.run_number }}" --no-git-tag-version
npm publish --tag "$RC_TAG" --provenance
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ jobs:
steps:
- name: Sanitize tag
id: tag
env:
RAW_TAG: ${{ github.event.inputs.tag }}
run: |
RAW_TAG="${{ github.event.inputs.tag }}"
SAFE_TAG="$(echo "$RAW_TAG" | sed 's/[^0-9A-Za-z-]/-/g')"
echo "tag=$SAFE_TAG" >> "$GITHUB_OUTPUT"

Expand All @@ -186,8 +187,9 @@ jobs:

- name: Sanitize preid
id: preid
env:
RAW_PREID: ${{ github.event.inputs.preid || github.ref_name }}
run: |
RAW_PREID="${{ github.event.inputs.preid || github.ref_name }}"
echo "preid=$(echo "$RAW_PREID" | sed 's/[^0-9A-Za-z-]/-/g')" >> "$GITHUB_OUTPUT"

rc-python-tests:
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/commands/sandbox/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export async function isRunning(sandboxID: string) {
apiKey,
})
return info.state === 'running'
} catch {
} catch (err) {
console.error(`Failed to check sandbox status: ${err}`)
return false
}
}
Expand Down
10 changes: 5 additions & 5 deletions packages/js-sdk/tests/sandbox/internetAccess.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ describe('internet access enabled', () => {
async ({ sandbox }) => {
// Test internet connectivity by making a curl request to a reliable external site
const result = await sandbox.commands.run(
"curl -s -o /dev/null -w '%{http_code}' https://e2b.dev"
"curl -s -o /dev/null -w '%{http_code}' https://connectivitycheck.gstatic.com/generate_204"
)
assert.equal(result.exitCode, 0)
assert.equal(result.stdout.trim(), '200')
assert.equal(result.stdout.trim(), '204')
}
)
})
Expand All @@ -36,7 +36,7 @@ describe('internet access disabled', () => {
// Test that internet connectivity is blocked by making a curl request
try {
await sandbox.commands.run(
'curl --connect-timeout 3 --max-time 5 -Is https://e2b.dev'
'curl --connect-timeout 3 --max-time 5 -Is https://connectivitycheck.gstatic.com/generate_204'
)
// If we reach here, the command succeeded, which means internet access is not properly disabled
assert.fail('Expected command to fail when internet access is disabled')
Expand All @@ -55,10 +55,10 @@ describe('internet access default', () => {
async ({ sandbox }) => {
// Test internet connectivity by making a curl request to a reliable external site
const result = await sandbox.commands.run(
"curl -s -o /dev/null -w '%{http_code}' https://e2b.dev"
"curl -s -o /dev/null -w '%{http_code}' https://connectivitycheck.gstatic.com/generate_204"
)
assert.equal(result.exitCode, 0)
assert.equal(result.stdout.trim(), '200')
assert.equal(result.stdout.trim(), '204')
}
)
})
2 changes: 1 addition & 1 deletion packages/python-sdk/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ markers =

asyncio_mode=auto
addopts = "--import-mode=importlib"
timeout = 300
timeout = 30
filterwarnings =
ignore:'asyncio\.iscoroutinefunction' is deprecated.*:DeprecationWarning:pytest_asyncio\.plugin
ignore:'asyncio\.get_event_loop_policy' is deprecated.*:DeprecationWarning:pytest_asyncio\.plugin
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ async def test_internet_access_enabled(async_sandbox_factory):

# Test internet connectivity by making a curl request to a reliable external site
result = await sbx.commands.run(
"curl -s -o /dev/null -w '%{http_code}' https://e2b.dev"
"curl -s -o /dev/null -w '%{http_code}' https://connectivitycheck.gstatic.com/generate_204"
)
assert result.exit_code == 0
assert result.stdout.strip() == "200"
assert result.stdout.strip() == "204"


@pytest.mark.skip_debug()
Expand All @@ -24,7 +24,7 @@ async def test_internet_access_disabled(async_sandbox_factory):
# Test that internet connectivity is blocked by making a curl request
with pytest.raises(CommandExitException) as exc_info:
await sbx.commands.run(
"curl --connect-timeout 3 --max-time 5 -Is https://e2b.dev"
"curl --connect-timeout 3 --max-time 5 -Is https://connectivitycheck.gstatic.com/generate_204"
)
# The command should fail or timeout when internet access is disabled
assert exc_info.value.exit_code != 0
Expand All @@ -36,7 +36,7 @@ async def test_internet_access_default(async_sandbox):
# Test internet connectivity by making a curl request to a reliable external site

result = await async_sandbox.commands.run(
"curl -s -o /dev/null -w '%{http_code}' https://e2b.dev"
"curl -s -o /dev/null -w '%{http_code}' https://connectivitycheck.gstatic.com/generate_204"
)
assert result.exit_code == 0
assert result.stdout.strip() == "200"
assert result.stdout.strip() == "204"
11 changes: 11 additions & 0 deletions packages/python-sdk/tests/async/template_async/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os

import pytest

_DIR = os.path.dirname(os.path.abspath(__file__))


def pytest_collection_modifyitems(items):
for item in items:
if str(item.fspath).startswith(_DIR):
item.add_marker(pytest.mark.timeout(180))
5 changes: 0 additions & 5 deletions packages/python-sdk/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ def template():
@pytest.fixture()
def sandbox_factory(request, template, sandbox_test_id):
def factory(*, template_name: str = template, **kwargs):
kwargs.setdefault("secure", False)
kwargs.setdefault("timeout", 5)

metadata = kwargs.setdefault("metadata", dict())
metadata.setdefault("sandbox_test_id", sandbox_test_id)

Expand Down Expand Up @@ -81,8 +78,6 @@ def event_loop():
@pytest.fixture
def async_sandbox_factory(request, template, sandbox_test_id, event_loop):
async def factory(*, template_name: str = template, **kwargs):
kwargs.setdefault("timeout", 5)

metadata = kwargs.setdefault("metadata", dict())
metadata.setdefault("sandbox_test_id", sandbox_test_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ def test_internet_access_enabled(sandbox_factory):
sbx = sandbox_factory(allow_internet_access=True)

# Test internet connectivity by making a curl request to a reliable external site
result = sbx.commands.run("curl -s -o /dev/null -w '%{http_code}' https://e2b.dev")
result = sbx.commands.run(
"curl -s -o /dev/null -w '%{http_code}' https://connectivitycheck.gstatic.com/generate_204"
)
assert result.exit_code == 0
assert result.stdout.strip() == "200"
assert result.stdout.strip() == "204"


@pytest.mark.skip_debug()
Expand All @@ -21,7 +23,9 @@ def test_internet_access_disabled(sandbox_factory):

# Test that internet connectivity is blocked by making a curl request
with pytest.raises(CommandExitException) as exc_info:
sbx.commands.run("curl --connect-timeout 3 --max-time 5 -Is https://e2b.dev")
sbx.commands.run(
"curl --connect-timeout 3 --max-time 5 -Is https://connectivitycheck.gstatic.com/generate_204"
)
# The command should fail or timeout when internet access is disabled
assert exc_info.value.exit_code != 0

Expand All @@ -32,7 +36,7 @@ def test_internet_access_default(sandbox):

# Test internet connectivity by making a curl request to a reliable external site
result = sandbox.commands.run(
"curl -s -o /dev/null -w '%{http_code}' https://e2b.dev"
"curl -s -o /dev/null -w '%{http_code}' https://connectivitycheck.gstatic.com/generate_204"
)
assert result.exit_code == 0
assert result.stdout.strip() == "200"
assert result.stdout.strip() == "204"
11 changes: 11 additions & 0 deletions packages/python-sdk/tests/sync/template_sync/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os

import pytest

_DIR = os.path.dirname(os.path.abspath(__file__))


def pytest_collection_modifyitems(items):
for item in items:
if str(item.fspath).startswith(_DIR):
item.add_marker(pytest.mark.timeout(180))