Skip to content

Commit 67e6ecf

Browse files
authored
Add files via upload
1 parent 8271d77 commit 67e6ecf

File tree

11 files changed

+808
-0
lines changed

11 files changed

+808
-0
lines changed

.github/scripts/is_new_sdk_ref.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# This script checks for diffs in the js/ and python/ directory.
6+
# If there are diffs, it means we need to generate new SDK references.
7+
if git diff --name-only HEAD^ | grep -q '^js/\|^python/'; then
8+
echo "true"
9+
else
10+
echo "false"
11+
fi

.github/scripts/is_release.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
# This script checks if the current commit contains changesets.
4+
5+
set -eu
6+
7+
CHANGES=$(node -e "require('@changesets/read').default(process.cwd()).then(result => console.log(!!result.length))")
8+
9+
echo "${CHANGES}"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
# This script checks if the specified package has changesets in the current commit.
4+
5+
set -eu
6+
7+
if [ $# -lt 1 ]; then
8+
echo "Error: Package name is required as the first argument." >&2
9+
exit 1
10+
fi
11+
12+
PACKAGE_NAME=$1
13+
PACKAGE_CHANGES=$(node -e "require('@changesets/read').default(process.cwd()).then(result => console.log(result.flatMap(changeset => changeset.releases.flatMap(release => release.name)).includes('${PACKAGE_NAME}')))")
14+
15+
echo "${PACKAGE_CHANGES}"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build Template
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
E2B_TESTS_ACCESS_TOKEN:
7+
required: true
8+
inputs:
9+
E2B_DOMAIN:
10+
required: false
11+
type: string
12+
outputs:
13+
template_id:
14+
description: "The ID of the built template"
15+
value: ${{ jobs.build.outputs.template_id }}
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
build:
22+
name: Build E2B Template
23+
runs-on: ubuntu-latest
24+
outputs:
25+
template_id: ${{ steps.build-template.outputs.template_id }}
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set package version
31+
working-directory: ./template
32+
run: |
33+
VERSION=$(cat ../chart_data_extractor/pyproject.toml | grep version | cut -d '"' -f 2)
34+
echo "Version: $VERSION"
35+
sed -i "s/e2b_charts/e2b_charts==${VERSION}/g" requirements.txt
36+
37+
- name: Install E2B CLI
38+
run: npm install -g @e2b/cli
39+
40+
- name: Build E2B template
41+
id: build-template
42+
run: |
43+
rm -f e2b.toml
44+
e2b template build --memory-mb 1024 -c "/root/.jupyter/start-up.sh" -d "Dockerfile"
45+
TEMPLATE_ID=$(grep "template_id" e2b.toml | cut -d '"' -f 2)
46+
echo "Captured Template ID: $TEMPLATE_ID"
47+
echo "template_id=$TEMPLATE_ID" >> $GITHUB_OUTPUT
48+
working-directory: ./template
49+
env:
50+
E2B_ACCESS_TOKEN: ${{ secrets.E2B_TESTS_ACCESS_TOKEN }}
51+
E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }}
52+
53+
- name: Output template ID
54+
run: |
55+
echo "Template ID from step output: ${{ steps.build-template.outputs.template_id }}"

.github/workflows/charts_tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Test Python SDK
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
publish:
11+
defaults:
12+
run:
13+
working-directory: ./chart_data_extractor
14+
name: Chart Data Extractor - Build and test
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.10'
24+
25+
- name: Install and configure Poetry
26+
uses: snok/install-poetry@v1
27+
with:
28+
version: 1.5.1
29+
virtualenvs-create: true
30+
virtualenvs-in-project: true
31+
installer-parallel: true
32+
33+
- name: Install dependencies
34+
run: poetry install
35+
36+
- name: Test build
37+
run: poetry build
38+
39+
- name: Run tests
40+
run: poetry run pytest --verbose -x
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Cleanup Build Template
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
E2B_TESTS_ACCESS_TOKEN:
7+
required: true
8+
inputs:
9+
E2B_DOMAIN:
10+
required: false
11+
type: string
12+
E2B_TESTS_TEMPLATE:
13+
required: true
14+
type: string
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
cleanup:
21+
name: Cleanup Build Template
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Install E2B CLI
25+
run: npm install -g @e2b/cli
26+
27+
- name: Cleanup E2B template
28+
id: cleanup-template
29+
run: |
30+
e2b template delete -y "${{ inputs.E2B_TESTS_TEMPLATE }}"
31+
env:
32+
E2B_ACCESS_TOKEN: ${{ secrets.E2B_TESTS_ACCESS_TOKEN }}
33+
E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }}

.github/workflows/js_tests.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Test JS SDK
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
E2B_API_KEY:
7+
required: true
8+
inputs:
9+
E2B_DOMAIN:
10+
required: false
11+
type: string
12+
E2B_TESTS_TEMPLATE:
13+
required: false
14+
type: string
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
test:
21+
defaults:
22+
run:
23+
working-directory: ./js
24+
name: JS SDK - Build and test
25+
runs-on: ubuntu-22.04
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Install pnpm
31+
uses: pnpm/action-setup@v3
32+
id: pnpm-install
33+
with:
34+
version: 9.5
35+
36+
- name: Setup Node
37+
uses: actions/setup-node@v3
38+
with:
39+
node-version: '18.x'
40+
registry-url: 'https://registry.npmjs.org'
41+
cache: pnpm
42+
cache-dependency-path: pnpm-lock.yaml
43+
44+
- name: Configure pnpm
45+
run: |
46+
pnpm config set auto-install-peers true
47+
pnpm config set exclude-links-from-lockfile true
48+
49+
- name: Install dependencies
50+
run: pnpm install --frozen-lockfile
51+
52+
- name: Test build
53+
run: pnpm build
54+
55+
- name: Run Node tests
56+
run: pnpm test
57+
env:
58+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
59+
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
60+
E2B_TESTS_TEMPLATE: ${{ inputs.E2B_TESTS_TEMPLATE }}
61+
62+
- name: Install Bun
63+
uses: oven-sh/setup-bun@v2
64+
with:
65+
bun-version: 1.2.15
66+
67+
- name: Run Bun tests
68+
run: pnpm test:bun
69+
env:
70+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
71+
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
72+
E2B_TESTS_TEMPLATE: ${{ inputs.E2B_TESTS_TEMPLATE }}
73+
74+
- name: Install Deno
75+
uses: denoland/setup-deno@v1
76+
with:
77+
deno-version: v1.x
78+
79+
- name: Run Deno tests
80+
run: pnpm test:deno
81+
env:
82+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
83+
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
84+
E2B_TESTS_TEMPLATE: ${{ inputs.E2B_TESTS_TEMPLATE }}

.github/workflows/pull_request.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Pull Request
2+
3+
permissions:
4+
contents: read
5+
id-token: write
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
on:
12+
pull_request:
13+
branches:
14+
- main
15+
16+
jobs:
17+
build-template:
18+
uses: ./.github/workflows/build_test_template.yml
19+
secrets:
20+
E2B_TESTS_ACCESS_TOKEN: ${{ secrets.E2B_TESTS_ACCESS_TOKEN }}
21+
with:
22+
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
23+
js-sdk:
24+
uses: ./.github/workflows/js_tests.yml
25+
needs: build-template
26+
secrets:
27+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
28+
with:
29+
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
30+
E2B_TESTS_TEMPLATE: ${{ needs.build-template.outputs.template_id }}
31+
python-sdk:
32+
uses: ./.github/workflows/python_tests.yml
33+
needs: build-template
34+
secrets:
35+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
36+
with:
37+
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
38+
E2B_TESTS_TEMPLATE: ${{ needs.build-template.outputs.template_id }}
39+
cleanup-build-template:
40+
uses: ./.github/workflows/cleanup_build_template.yml
41+
needs: [build-template, js-sdk, python-sdk]
42+
if: always() && !contains(needs.build-template.result, 'failure') && !contains(needs.build-template.result, 'cancelled')
43+
secrets:
44+
E2B_TESTS_ACCESS_TOKEN: ${{ secrets.E2B_TESTS_ACCESS_TOKEN }}
45+
with:
46+
E2B_DOMAIN: ${{ vars.E2B_DOMAIN }}
47+
E2B_TESTS_TEMPLATE: ${{ needs.build-template.outputs.template_id }}
48+
charts-tests:
49+
uses: ./.github/workflows/charts_tests.yml

.github/workflows/python_tests.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Test Python SDK
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
E2B_API_KEY:
7+
required: true
8+
inputs:
9+
E2B_DOMAIN:
10+
required: false
11+
type: string
12+
E2B_TESTS_TEMPLATE:
13+
required: false
14+
type: string
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
publish:
21+
defaults:
22+
run:
23+
working-directory: ./python
24+
name: Python SDK - Build and test
25+
runs-on: ubuntu-22.04
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: '3.9'
34+
35+
- name: Install and configure Poetry
36+
uses: snok/install-poetry@v1
37+
with:
38+
version: 1.5.1
39+
virtualenvs-create: true
40+
virtualenvs-in-project: true
41+
installer-parallel: true
42+
43+
- name: Install dependencies
44+
run: poetry install
45+
46+
- name: Test build
47+
run: poetry build
48+
49+
- name: Run tests
50+
run: poetry run pytest --verbose -x
51+
env:
52+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
53+
E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }}
54+
E2B_TESTS_TEMPLATE: ${{ inputs.E2B_TESTS_TEMPLATE }}

0 commit comments

Comments
 (0)