-
Notifications
You must be signed in to change notification settings - Fork 1k
test: add opt-in e2e tier scaffolding for the SDK test suites (1/4) #1742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@e2b/python-sdk': patch | ||
| '@e2b/cli': patch | ||
| 'e2b': patch | ||
| --- | ||
|
|
||
| Split the test suites into a fully mocked default tier and an opt-in `E2B_E2E=1` end-to-end tier (tests only, no runtime changes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| name: SDK E2E Tests | ||
|
|
||
| # The opt-in tier. These jobs provision sandboxes, talk to envd and build | ||
| # templates against live infrastructure, so they are not part of the required | ||
| # PR checks (see sdk_tests.yml, which runs the fully mocked default tier). | ||
| # | ||
| # Run them manually from the Actions tab, or by adding the `e2e` label to a PR. | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| staging: | ||
| description: 'Run against staging instead of production' | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| types: [opened, synchronize, reopened, labeled] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| js-e2e: | ||
| name: E2E / JS SDK | ||
| if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'e2e') }} | ||
| uses: ./.github/workflows/js_sdk_tests.yml | ||
| with: | ||
| e2e: true | ||
| # The e2e tier only runs under Node — the Bun/Deno/Cloudflare legs cover | ||
| # the mocked tier in the default workflow. | ||
| node-only: true | ||
| E2B_DOMAIN: ${{ inputs.staging && vars.E2B_DOMAIN_STAGING || '' }} | ||
| secrets: | ||
| E2B_API_KEY: ${{ inputs.staging && secrets.E2B_API_KEY_STAGING || secrets.E2B_API_KEY }} | ||
|
|
||
| python-e2e: | ||
| name: E2E / Python SDK | ||
| if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'e2e') }} | ||
| uses: ./.github/workflows/python_sdk_tests.yml | ||
| with: | ||
| e2e: true | ||
| E2B_DOMAIN: ${{ inputs.staging && vars.E2B_DOMAIN_STAGING || '' }} | ||
| secrets: | ||
| E2B_API_KEY: ${{ inputs.staging && secrets.E2B_API_KEY_STAGING || secrets.E2B_API_KEY }} | ||
|
|
||
| cli-e2e: | ||
| name: E2E / CLI | ||
| if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'e2e') }} | ||
| uses: ./.github/workflows/cli_tests.yml | ||
| with: | ||
| e2e: true | ||
| E2B_DOMAIN: ${{ inputs.staging && vars.E2B_DOMAIN_STAGING || '' }} | ||
| secrets: | ||
| E2B_API_KEY: ${{ inputs.staging && secrets.E2B_API_KEY_STAGING || secrets.E2B_API_KEY }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,22 @@ | ||
| # Contributing | ||
| If you want to contribute, open a PR, issue, or start a discussion on our [Discord](https://discord.gg/dSBY3ms2Qr). | ||
|
|
||
| ## Tests | ||
|
|
||
| Every package splits its tests into two tiers: | ||
|
|
||
| - **unit (default)** — fully mocked, deterministic, no sandboxes and no | ||
| credentials. | ||
| - **e2e (opt-in)** — real sandboxes, envd round-trips and template builds; | ||
| requires `E2B_E2E=1` and an API key. | ||
|
|
||
| | Package | Unit | E2E | | ||
| | --- | --- | --- | | ||
| | `packages/js-sdk` | `pnpm test` | `pnpm test:e2e`, `pnpm test:browser` | | ||
| | `packages/python-sdk` | `uv run pytest` | `uv run pytest -m e2e` | | ||
| | `packages/cli` | `pnpm test` | `pnpm test:e2e` | | ||
|
|
||
| Details, and where a new test belongs, are in each package's | ||
| `tests/README.md`. On CI the `SDK Tests` workflow runs the unit tier for every | ||
| PR; the e2e tier runs in the opt-in `SDK E2E Tests` workflow (add the `e2e` | ||
| label to a PR or dispatch it manually). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # CLI tests | ||
|
|
||
| The suite has two tiers. | ||
|
|
||
| ## Unit tier (default) | ||
|
|
||
| ```bash | ||
| pnpm test | ||
| ``` | ||
|
|
||
| Fully mocked (`vi.mock` over `e2b` and the CLI's API modules) or driving the | ||
| built CLI against local input only — deterministic, no sandboxes, no | ||
| credentials. It asserts on argument parsing, validation, output formatting and | ||
| the calls the CLI makes into the SDK. | ||
|
|
||
| ## E2E tier (opt-in) | ||
|
|
||
| ```bash | ||
| E2B_API_KEY=e2b_... pnpm test:e2e | ||
| ``` | ||
|
|
||
| Tests that drive the built CLI against a real sandbox (`exec` piping, | ||
| `backend_integration`). They need `E2B_E2E=1` (set by the script above) plus | ||
| credentials, from `E2B_API_KEY` or `~/.e2b/config.json`; without both they are | ||
| skipped. | ||
|
|
||
| Use `e2eTest` (or `skipE2E` in a `beforeAll`) from [`setup.ts`](./setup.ts), | ||
| which also resolves the shared `e2eApiKey`/`e2eDomain`. `E2B_DEBUG` is a | ||
| separate axis and disables the e2e tier because it points the CLI at a local | ||
| stack. | ||
|
|
||
| ## CI | ||
|
|
||
| `SDK Tests` runs the unit tier on every PR. The e2e tier runs in the opt-in | ||
| `SDK E2E Tests` workflow — add the `e2e` label to a PR or dispatch it manually. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T-1 (the surfaces mirror each other, differing only by language idiom) plus doc accuracy:
E2B_E2E=1is not how the Python tier is selected. Nothing inpackages/python-sdkreadsE2B_E2E—pytest.ini'saddopts = -m "not e2e"plus-m e2eis the whole switch, so following this line verbatim in Python runs the mocked tier and reports success without touching a sandbox.