Skip to content
Open
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
104 changes: 104 additions & 0 deletions .github/workflows/ts-sdk-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,108 @@ jobs:
echo "=== Task started at: $(date '+%Y-%m-%d %H:%M:%S') ==="
pnpm test:unit

integration-test:
runs-on: self-hosted
timeout-minutes: 20
steps:
- uses: actions/checkout@v4

# --- Cleanup & Python Setup (following python-ci.yml pattern) ---
- name: Cleanup old Ray sessions
run: |
target="$(readlink -f /tmp/ray 2>/dev/null || echo /tmp/ray)"
[ -d "$target" ] || exit 0
echo "ray dir: $target"
echo "Before:"
du -sh "$target" 2>/dev/null || true
find "$target" -mindepth 1 -maxdepth 1 -type d -name 'session_*' -mmin +60 -exec rm -rf -- {} + || true
echo "After:"
du -sh "$target" 2>/dev/null || true

- name: Install ROCK Python dependencies
run: |
echo "=== Task started at: $(date '+%Y-%m-%d %H:%M:%S') ==="
uv sync --all-extras --python 3.11

- name: Prepare Docker image
run: |
echo "=== Task started at: $(date '+%Y-%m-%d %H:%M:%S') ==="
docker system prune -f 2>/dev/null || true
if ! docker image inspect python:3.11 > /dev/null 2>&1; then
echo "Pulling python:3.11..."
docker pull python:3.11
else
echo "python:3.11 already exists, skipping pull"
fi

- name: Start ROCK Admin service
run: |
echo "=== Task started at: $(date '+%Y-%m-%d %H:%M:%S') ==="
export ROCK_WORKER_ENV_TYPE=uv
nohup uv run admin --env ci --role admin --port 8080 > /tmp/rock-admin.log 2>&1 &
echo "Waiting for admin service to be ready..."
for i in $(seq 1 60); do
if grep -q "Uvicorn running on" /tmp/rock-admin.log 2>/dev/null; then
echo "Admin service is ready!"
break
fi
echo "Attempt $i/60: Admin not ready yet, waiting 2s..."
sleep 2
done
if ! grep -q "Uvicorn running on" /tmp/rock-admin.log 2>/dev/null; then
echo "ERROR: Admin service failed to start!"
cat /tmp/rock-admin.log
exit 1
fi

# --- Node.js & TS SDK Setup ---
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install pnpm
run: |
echo "=== Task started at: $(date '+%Y-%m-%d %H:%M:%S') ==="
npm install -g pnpm

- name: Install TS SDK dependencies
working-directory: rock/ts-sdk
run: |
echo "=== Task started at: $(date '+%Y-%m-%d %H:%M:%S') ==="
pnpm install --frozen-lockfile

# --- Run Integration Tests ---
- name: Run integration tests
working-directory: rock/ts-sdk
env:
ROCK_BASE_URL: http://127.0.0.1:8080
ROCK_TEST_IMAGE: python:3.11
ROCK_TEST_CLUSTER: default
ROCK_STARTUP_TIMEOUT: "600"
ROCK_TEST_TIMEOUT: "660000"
run: |
echo "=== Task started at: $(date '+%Y-%m-%d %H:%M:%S') ==="
pnpm test:integration

# --- Cleanup & Diagnostics ---
- name: Print admin logs on failure
if: always()
run: |
echo "=== ROCK Admin Logs (last 200 lines) ==="
tail -200 /tmp/rock-admin.log || true
echo "=== Docker Containers ==="
docker ps -a || true
echo "=== Ray Status ==="
uv run ray status 2>/dev/null || true
echo "=== Ray Runtime Env Logs ==="
find /tmp/ray -name "runtime_env*.log" -exec tail -50 {} \; 2>/dev/null || true

- name: Cleanup
if: always()
run: |
docker rm -f $(docker ps -aq) 2>/dev/null || true
ray stop --force 2>/dev/null || true
pkill -f "admin --env ci" 2>/dev/null || true


14 changes: 14 additions & 0 deletions rock-conf/rock-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ray:
runtime_env:
working_dir: ./
pip: ./requirements_sandbox_actor.txt
namespace: "rock-sandbox-ci"

runtime:
standard_spec:
memory: "2g"
cpus: 1

warmup:
images:
- "python:3.11"
5 changes: 4 additions & 1 deletion rock/rocklet/local_files/docker_run_with_uv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ if [ ! -f /etc/alpine-release ]; then
UV_CMD=$HOME/.local/bin/uv
fi

cd $PROJECT_ROOT
# Copy project to a writable directory (volume may be mounted read-only)
WRITABLE_PROJECT=/tmp/rocklet-project
cp -r $PROJECT_ROOT $WRITABLE_PROJECT
cd $WRITABLE_PROJECT

# Create virtual environment
$UV_CMD venv --python 3.11 /tmp/rocklet-venv
Expand Down
12 changes: 6 additions & 6 deletions rock/ts-sdk/tests/integration/file-system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import * as os from 'os';

const TEST_CONFIG = {
baseUrl: process.env.ROCK_BASE_URL || 'http://11.166.8.116:8080',
image: 'reg.docker.alibaba-inc.com/yanan/python:3.11',
cluster: 'zb',
startupTimeout: 120,
image: process.env.ROCK_TEST_IMAGE || 'reg.docker.alibaba-inc.com/yanan/python:3.11',
cluster: process.env.ROCK_TEST_CLUSTER || 'zb',
startupTimeout: parseInt(process.env.ROCK_STARTUP_TIMEOUT || '120', 10),
};

describe('FileSystem Integration', () => {
Expand All @@ -32,7 +32,7 @@ describe('FileSystem Integration', () => {

// Create a temporary directory for test files
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'rock-test-'));
}, 180000); // 3 minutes timeout for sandbox startup
}, parseInt(process.env.ROCK_TEST_TIMEOUT || '180000', 10));

afterEach(async () => {
// Cleanup: ensure sandbox is stopped even if test fails
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('FileSystem Integration', () => {
// Assert: Nested files should exist
const nestedResult = await sandbox.arun(`cat ${targetDir}/subdir/file3.txt`, { mode: RunMode.NORMAL });
expect(nestedResult.output.trim()).toBe('Nested File');
}, 180000);
}, parseInt(process.env.ROCK_TEST_TIMEOUT || '180000', 10));

test('should return error when source directory does not exist', async () => {
const nonExistentDir = path.join(tempDir, 'nonexistent');
Expand Down Expand Up @@ -149,6 +149,6 @@ describe('FileSystem Integration', () => {
// Use test command instead of ls to avoid throwing on non-existent file
const oldFileCheck = await sandbox.arun(`test -f ${targetDir}/oldfile.txt && echo "exists" || echo "not exists"`, { mode: RunMode.NORMAL });
expect(oldFileCheck.output.trim()).toBe('not exists');
}, 180000);
}, parseInt(process.env.ROCK_TEST_TIMEOUT || '180000', 10));
});
});
8 changes: 4 additions & 4 deletions rock/ts-sdk/tests/integration/sandbox-lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { Sandbox } from '../../src/sandbox/client.js';

const TEST_CONFIG = {
baseUrl: process.env.ROCK_BASE_URL || 'http://11.166.8.116:8080',
image: 'reg.docker.alibaba-inc.com/yanan/python:3.11',
cluster: 'zb',
startupTimeout: 120, // 2 minutes timeout for sandbox startup
image: process.env.ROCK_TEST_IMAGE || 'reg.docker.alibaba-inc.com/yanan/python:3.11',
cluster: process.env.ROCK_TEST_CLUSTER || 'zb',
startupTimeout: parseInt(process.env.ROCK_STARTUP_TIMEOUT || '120', 10),
};

describe('Sandbox Lifecycle Integration', () => {
Expand Down Expand Up @@ -53,5 +53,5 @@ describe('Sandbox Lifecycle Integration', () => {
// After stop, isAlive may throw error, which is acceptable
expect(String(e)).toContain('Failed to get is alive');
}
}, 180000); // 3 minutes timeout for the whole test
}, parseInt(process.env.ROCK_TEST_TIMEOUT || '180000', 10));
});
Loading