Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c8e2a59
added GitHub workflows
mishushakov Jun 4, 2025
9841d00
added test toml template
mishushakov Jun 4, 2025
432cfd9
changed tests to use test template in CI
mishushakov Jun 4, 2025
251ed0f
js sdk and python sdk to wait on template
mishushakov Jun 4, 2025
7f9394a
ensured some env variables in yaml
mishushakov Jun 4, 2025
c0a626d
added ifs to JS/Python test jobs
mishushakov Jun 4, 2025
9266341
split secrets and envs
mishushakov Jun 4, 2025
efba8aa
updated checkout github action
mishushakov Jun 4, 2025
ea59c6a
removed fetch-depth as this is default
mishushakov Jun 4, 2025
2acdbe3
changed inputs > with
mishushakov Jun 4, 2025
5622371
fixed unrecognized named value secrets
mishushakov Jun 4, 2025
786b17f
removed unused E2B_CI_TEMPLATE from build_template.yml workflow
mishushakov Jun 4, 2025
31669b0
added inputs types
mishushakov Jun 4, 2025
aef65ab
updated build-template workflow
mishushakov Jun 4, 2025
2d5555f
added E2B_ACCESS_TOKEN to pull_request.yml
mishushakov Jun 4, 2025
9143977
fixes option '--config <e2b-toml>' argument missing on CI
mishushakov Jun 4, 2025
e229b07
combine CI build tasks into separate steps
mishushakov Jun 4, 2025
6f72501
vars > inputs in CI workflows
mishushakov Jun 4, 2025
4442288
changed default test tempate name
mishushakov Jun 4, 2025
58c3520
dynamic template id for each build
mishushakov Jun 4, 2025
3156d90
fixes syntax error in build_template.yml
mishushakov Jun 4, 2025
ed6485e
remove e2b.toml on CI to be able to override the template
mishushakov Jun 4, 2025
407d2f4
changed working dir for removing e2b template
mishushakov Jun 4, 2025
138a6ab
redirect stderr in e2b template build ci correctly
mishushakov Jun 4, 2025
bf5f38e
removed unnecessary std redirect in build
mishushakov Jun 4, 2025
a604958
changed template id extraction logic
mishushakov Jun 4, 2025
9361d51
removed unnecessary line
mishushakov Jun 4, 2025
e11858d
removed E2B_TEMPLATE_CONFIG
mishushakov Jun 4, 2025
0bbe315
removed unused inputs, added cleanup job
mishushakov Jun 4, 2025
6df9f06
unexpected value inputs
mishushakov Jun 4, 2025
f1ebc55
remove DOCKERHUB_USERNAME not required
mishushakov Jun 4, 2025
fe0fbff
removed hardcoded team id in CI
mishushakov Jun 4, 2025
7f84ecf
fixed GitHub Actions syntax in cleanup
mishushakov Jun 4, 2025
f4bb60f
set outputs correctly in build job
mishushakov Jun 4, 2025
fb40236
added gha cache for CI/CD template build
mishushakov Jun 4, 2025
7129f9d
debug cleanup CI
mishushakov Jun 4, 2025
72bd91e
removed unexpected value env
mishushakov Jun 4, 2025
330d2dc
rewired outputs in build
mishushakov Jun 4, 2025
18c30ba
outputs in build_template.yml
mishushakov Jun 4, 2025
38d6d48
Rename to test template
jakubno Jun 5, 2025
e5aca25
Fix secrets
jakubno Jun 5, 2025
7ce915f
Fix bun version
jakubno Jun 5, 2025
44c2926
Change to _TESTS_
jakubno Jun 5, 2025
c1c6e1e
Confirm template delete
jakubno Jun 5, 2025
54f3a42
pass image id from docker-build step to build-template
mishushakov Jun 5, 2025
a0705d2
tagged test docker imag
mishushakov Jun 5, 2025
adc9678
grep template from e2b.toml after the build has been completed
mishushakov Jun 5, 2025
fa779de
changed tag and added load: true to make the image visible locally
mishushakov Jun 5, 2025
5b22e57
removed the docker image as the CLI is always trying to pull
mishushakov Jun 5, 2025
0b71807
renamed build job
mishushakov Jun 5, 2025
3fbad08
changed pr workflow checks
mishushakov Jun 5, 2025
a5a29ca
cleanup wait for js sdk, python sdk
mishushakov Jun 5, 2025
09abade
Kuba's suggestion
mishushakov Jun 5, 2025
f35487b
changed condition
mishushakov Jun 5, 2025
a37d1f5
Merge branch 'main' into code-interpreter-cicd-for-templates-e2b-2391
mishushakov Jun 5, 2025
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
55 changes: 55 additions & 0 deletions .github/workflows/build_test_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build Template

on:
workflow_call:
secrets:
E2B_TESTS_ACCESS_TOKEN:
required: true
inputs:
E2B_DOMAIN:
required: false
type: string
outputs:
template_id:
description: "The ID of the built template"
value: ${{ jobs.build.outputs.template_id }}

permissions:
contents: read

jobs:
build:
name: Build E2B Template
runs-on: ubuntu-latest
outputs:
template_id: ${{ steps.build-template.outputs.template_id }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set package version
working-directory: ./template
run: |
VERSION=$(cat ../chart_data_extractor/pyproject.toml | grep version | cut -d '"' -f 2)
echo "Version: $VERSION"
sed -i "s/e2b_charts/e2b_charts==${VERSION}/g" requirements.txt

- name: Install E2B CLI
run: npm install -g @e2b/cli

- name: Build E2B template
id: build-template
run: |
rm -f e2b.toml
e2b template build --memory-mb 1024 -c "/root/.jupyter/start-up.sh" -d "Dockerfile"
TEMPLATE_ID=$(grep "template_id" e2b.toml | cut -d '"' -f 2)
echo "Captured Template ID: $TEMPLATE_ID"
echo "template_id=$TEMPLATE_ID" >> $GITHUB_OUTPUT
working-directory: ./template
env:
E2B_ACCESS_TOKEN: ${{ secrets.E2B_TESTS_ACCESS_TOKEN }}
E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }}

- name: Output template ID
run: |
echo "Template ID from step output: ${{ steps.build-template.outputs.template_id }}"
2 changes: 1 addition & 1 deletion .github/workflows/charts_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/cleanup_build_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Cleanup Build Template

on:
workflow_call:
secrets:
E2B_TESTS_ACCESS_TOKEN:
required: true
inputs:
E2B_DOMAIN:
required: false
type: string
E2B_TESTS_TEMPLATE:
required: true
type: string

permissions:
contents: read

jobs:
cleanup:
name: Cleanup Build Template
runs-on: ubuntu-latest
steps:
- name: Install E2B CLI
run: npm install -g @e2b/cli

- name: Cleanup E2B template
id: cleanup-template
run: |
e2b template delete -y "${{ inputs.E2B_TESTS_TEMPLATE }}"
env:
E2B_ACCESS_TOKEN: ${{ secrets.E2B_TESTS_ACCESS_TOKEN }}
E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }}
17 changes: 15 additions & 2 deletions .github/workflows/js_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ on:
secrets:
E2B_API_KEY:
required: true
inputs:
E2B_DOMAIN:
required: false
type: string
E2B_TESTS_TEMPLATE:
required: false
type: string

permissions:
contents: read
Expand All @@ -18,7 +25,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v3
Expand Down Expand Up @@ -49,16 +56,20 @@ jobs:
run: pnpm test
env:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
E2B_TESTS_TEMPLATE: ${{ inputs.E2B_TESTS_TEMPLATE }}

- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
version: 1.1.x
bun-version: 1.2.15

- name: Run Bun tests
run: pnpm test:bun
env:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
E2B_TESTS_TEMPLATE: ${{ inputs.E2B_TESTS_TEMPLATE }}

- name: Install Deno
uses: denoland/setup-deno@v1
Expand All @@ -69,3 +80,5 @@ jobs:
run: pnpm test:deno
env:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
E2B_TESTS_TEMPLATE: ${{ inputs.E2B_TESTS_TEMPLATE }}
23 changes: 23 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,36 @@ on:
- main

jobs:
build-template:
uses: ./.github/workflows/build_test_template.yml
secrets:
E2B_TESTS_ACCESS_TOKEN: ${{ secrets.E2B_TESTS_ACCESS_TOKEN }}
with:
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
js-sdk:
uses: ./.github/workflows/js_tests.yml
needs: build-template
secrets:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
with:
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
E2B_TESTS_TEMPLATE: ${{ needs.build-template.outputs.template_id }}
python-sdk:
uses: ./.github/workflows/python_tests.yml
needs: build-template
secrets:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
with:
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
E2B_TESTS_TEMPLATE: ${{ needs.build-template.outputs.template_id }}
cleanup-build-template:
uses: ./.github/workflows/cleanup_build_template.yml
needs: [build-template, js-sdk, python-sdk]
if: always() && !contains(needs.build-template.result, 'failure') && !contains(needs.build-template.result, 'cancelled')
secrets:
E2B_TESTS_ACCESS_TOKEN: ${{ secrets.E2B_TESTS_ACCESS_TOKEN }}
with:
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
E2B_TESTS_TEMPLATE: ${{ needs.build-template.outputs.template_id }}
charts-tests:
uses: ./.github/workflows/charts_tests.yml
11 changes: 10 additions & 1 deletion .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ on:
secrets:
E2B_API_KEY:
required: true
inputs:
E2B_DOMAIN:
required: false
type: string
E2B_TESTS_TEMPLATE:
required: false
type: string

permissions:
contents: read
Expand All @@ -18,7 +25,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -43,3 +50,5 @@ jobs:
run: poetry run pytest --verbose -x
env:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }}
E2B_TESTS_TEMPLATE: ${{ inputs.E2B_TESTS_TEMPLATE }}
17 changes: 6 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
release: ${{ steps.version.outputs.release }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v3
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
template: ${{ steps.template.outputs.release }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v3
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
version: ${{ steps.output_version.outputs.version }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v3
Expand Down Expand Up @@ -177,9 +177,7 @@ jobs:
(needs.changes.outputs.template == 'true' || needs.changes.outputs.charts == 'true')
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down Expand Up @@ -220,9 +218,7 @@ jobs:
(needs.changes.outputs.template == 'true' || needs.changes.outputs.charts == 'true')
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
uses: actions/checkout@v4
- name: Install E2B CLI
run: npm install -g @e2b/cli

Expand Down Expand Up @@ -268,9 +264,8 @@ jobs:
private-key: ${{ secrets.VERSION_BUMPER_SECRET }}

- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}


Expand Down
6 changes: 5 additions & 1 deletion js/tests/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ import { test as base } from 'vitest'

const timeoutMs = 60_000

const template = process.env.E2B_TESTS_TEMPLATE || 'code-interpreter-v1'

interface SandboxFixture {
sandbox: Sandbox
}

export const sandboxTest = base.extend<SandboxFixture>({
sandbox: [
async ({}, use) => {
const sandbox = await Sandbox.create({ timeoutMs })
const sandbox = await Sandbox.create(template, {
timeoutMs,
})
try {
await use(sandbox)
} finally {
Expand Down
17 changes: 11 additions & 6 deletions python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@


@pytest.fixture()
def sandbox(debug):
sandbox = Sandbox(timeout=timeout)
def template():
return os.getenv("E2B_TESTS_TEMPLATE", "code-interpreter-v1")


@pytest.fixture()
def sandbox(template, debug):
sandbox = Sandbox(template, timeout=timeout)

try:
yield sandbox
Expand All @@ -27,14 +32,14 @@ def sandbox(debug):


@pytest_asyncio.fixture
async def async_sandbox(debug):
sandbox = await AsyncSandbox.create(timeout=timeout)
async def async_sandbox(template, debug):
async_sandbox = await AsyncSandbox.create(template, timeout=timeout)

try:
yield sandbox
yield async_sandbox
finally:
try:
await sandbox.kill()
await async_sandbox.kill()
except:
if not debug:
warning(
Expand Down