diff --git a/.github/workflows/publish_candidates.yml b/.github/workflows/publish_candidates.yml index dc6425379d..1c48d632b7 100644 --- a/.github/workflows/publish_candidates.yml +++ b/.github/workflows/publish_candidates.yml @@ -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 }} @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ad5cc31d22..269b6928b0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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" @@ -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: diff --git a/packages/cli/src/commands/sandbox/utils.ts b/packages/cli/src/commands/sandbox/utils.ts index 11070c8006..063e60ba6e 100644 --- a/packages/cli/src/commands/sandbox/utils.ts +++ b/packages/cli/src/commands/sandbox/utils.ts @@ -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 } } diff --git a/packages/js-sdk/tests/sandbox/internetAccess.test.ts b/packages/js-sdk/tests/sandbox/internetAccess.test.ts index c67cd996b3..498d3e4fc3 100644 --- a/packages/js-sdk/tests/sandbox/internetAccess.test.ts +++ b/packages/js-sdk/tests/sandbox/internetAccess.test.ts @@ -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') } ) }) @@ -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') @@ -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') } ) }) diff --git a/packages/python-sdk/pytest.ini b/packages/python-sdk/pytest.ini index b3593565b0..a4ef0d93d3 100644 --- a/packages/python-sdk/pytest.ini +++ b/packages/python-sdk/pytest.ini @@ -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 diff --git a/packages/python-sdk/tests/async/sandbox_async/test_internet_access.py b/packages/python-sdk/tests/async/sandbox_async/test_internet_access.py index 3a48249aba..4eb6e2f071 100644 --- a/packages/python-sdk/tests/async/sandbox_async/test_internet_access.py +++ b/packages/python-sdk/tests/async/sandbox_async/test_internet_access.py @@ -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() @@ -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 @@ -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" diff --git a/packages/python-sdk/tests/async/template_async/conftest.py b/packages/python-sdk/tests/async/template_async/conftest.py new file mode 100644 index 0000000000..520f64f208 --- /dev/null +++ b/packages/python-sdk/tests/async/template_async/conftest.py @@ -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)) diff --git a/packages/python-sdk/tests/conftest.py b/packages/python-sdk/tests/conftest.py index 6b2ad92e78..0ac8c938b1 100644 --- a/packages/python-sdk/tests/conftest.py +++ b/packages/python-sdk/tests/conftest.py @@ -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) @@ -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) diff --git a/packages/python-sdk/tests/sync/sandbox_sync/test_internet_access.py b/packages/python-sdk/tests/sync/sandbox_sync/test_internet_access.py index fecb2f9ba9..d35216c016 100644 --- a/packages/python-sdk/tests/sync/sandbox_sync/test_internet_access.py +++ b/packages/python-sdk/tests/sync/sandbox_sync/test_internet_access.py @@ -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() @@ -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 @@ -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" diff --git a/packages/python-sdk/tests/sync/template_sync/conftest.py b/packages/python-sdk/tests/sync/template_sync/conftest.py new file mode 100644 index 0000000000..520f64f208 --- /dev/null +++ b/packages/python-sdk/tests/sync/template_sync/conftest.py @@ -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))