From 084d09dcd3b212a8b5b0729a67f4515d8b3042bb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 03:35:33 +0000 Subject: [PATCH 1/8] Initial plan From ed775ba9b3be1e28f3d732c1ee8d77dcbf459e99 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 03:38:15 +0000 Subject: [PATCH 2/8] Add create-test.sh integration test script and update CI workflow Co-authored-by: RetricSu <23436060+RetricSu@users.noreply.github.com> --- .github/workflows/test.yml | 4 + scripts/create-test.sh | 180 +++++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+) create mode 100755 scripts/create-test.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3787bce..a64205b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,6 +42,10 @@ jobs: shell: bash run: bash scripts/starting-node-test.sh + - name: Integration test - Create project workflow + shell: bash + run: bash scripts/create-test.sh + - name: Upload coverage to Codecov (Ubuntu only) if: matrix.os == 'ubuntu-latest' uses: codecov/codecov-action@v4 diff --git a/scripts/create-test.sh b/scripts/create-test.sh new file mode 100755 index 0000000..f1e04cc --- /dev/null +++ b/scripts/create-test.sh @@ -0,0 +1,180 @@ +#!/bin/bash +set -e + +# Create a unique test project name to avoid conflicts +TEST_PROJECT_NAME="test-project-$$" +TEST_PROJECT_DIR="/tmp/${TEST_PROJECT_NAME}" + +echo "Starting offckb create integration test..." +echo "Test project: ${TEST_PROJECT_NAME}" + +# Cleanup function +cleanup() { + echo "Cleaning up..." + + # Stop the node if it's still running + if [ ! -z "$NODE_PID" ]; then + echo "Stopping node (PID: $NODE_PID)..." + kill $NODE_PID 2>/dev/null || true + wait $NODE_PID 2>/dev/null || true + fi + + # Remove test project directory + if [ -d "$TEST_PROJECT_DIR" ]; then + echo "Removing test project directory..." + rm -rf "$TEST_PROJECT_DIR" + fi + + echo "Cleanup complete." +} + +# Set up trap to cleanup on exit +trap cleanup EXIT INT TERM + +# Start the node in the background +echo "Starting devnet node..." +pnpm start node & +NODE_PID=$! +echo "Node started with PID: $NODE_PID" + +# Wait for the node to be ready (max 60 seconds) +echo "Waiting for node to start..." +for i in {1..60}; do + if curl -s -f -X POST -H 'content-type: application/json' \ + -d '{"id":2,"jsonrpc":"2.0","method":"get_tip_block_number","params":[]}' \ + http://127.0.0.1:28114 > /dev/null 2>&1; then + echo "✓ Node is ready!" + break + fi + if [ $i -eq 60 ]; then + echo "✗ Timeout waiting for node to start" + exit 1 + fi + sleep 1 +done + +# Test the RPC endpoint to verify node is working +echo "Verifying node is responding..." +RESPONSE=$(echo '{"id":2,"jsonrpc":"2.0","method":"get_tip_block_number","params":[]}' | \ + tr -d '\n' | \ + curl -s -H 'content-type: application/json' -d @- http://127.0.0.1:28114) + +if echo "$RESPONSE" | grep -q '"result"'; then + echo "✓ Node is responding to RPC calls" +else + echo "✗ Node is not responding correctly" + echo "Response: $RESPONSE" + exit 1 +fi + +# Create test project with non-interactive mode +echo "" +echo "Creating test project with offckb create..." +cd /tmp +pnpm start create "$TEST_PROJECT_NAME" --no-interactive --no-git --no-install -l typescript + +# Check if project was created +if [ ! -d "$TEST_PROJECT_DIR" ]; then + echo "✗ Failed to create project directory" + exit 1 +fi + +echo "✓ Project directory created" + +# Check for essential files +echo "Checking for essential project files..." +ESSENTIAL_FILES=( + "package.json" + "README.md" + ".env" + ".env.example" + ".gitignore" + "jest.config.cjs" + "tsconfig.json" + "scripts/build-all.js" + "scripts/deploy.js" + "contracts/hello-world/src/index.ts" + "tests/hello-world.mock.test.ts" + "tests/hello-world.devnet.test.ts" + "deployment/scripts.json" + "deployment/system-scripts.json" +) + +for file in "${ESSENTIAL_FILES[@]}"; do + if [ ! -f "$TEST_PROJECT_DIR/$file" ]; then + echo "✗ Missing essential file: $file" + exit 1 + fi +done + +echo "✓ All essential files are present" + +# Install dependencies +echo "" +echo "Installing dependencies..." +cd "$TEST_PROJECT_DIR" +pnpm install --frozen-lockfile || pnpm install + +echo "✓ Dependencies installed" + +# Build the project +echo "" +echo "Building the project..." +pnpm run build + +if [ ! -d "$TEST_PROJECT_DIR/dist" ]; then + echo "✗ Build failed - dist directory not created" + exit 1 +fi + +# Check if the contract binary was built +if [ ! -f "$TEST_PROJECT_DIR/dist/hello-world.js" ]; then + echo "✗ Build failed - contract binary not created" + exit 1 +fi + +echo "✓ Project built successfully" + +# Deploy the project +echo "" +echo "Deploying the project..." +pnpm run deploy + +# Check if deployment artifacts were created +if [ ! -f "$TEST_PROJECT_DIR/deployment/devnet.json" ]; then + echo "✗ Deploy failed - deployment record not created" + exit 1 +fi + +echo "✓ Project deployed successfully" + +# Verify deployment record contains expected data +echo "" +echo "Verifying deployment record..." +DEPLOY_RECORD=$(cat "$TEST_PROJECT_DIR/deployment/devnet.json") + +if ! echo "$DEPLOY_RECORD" | grep -q '"contractName"'; then + echo "✗ Deployment record is missing contractName" + exit 1 +fi + +if ! echo "$DEPLOY_RECORD" | grep -q '"txHash"'; then + echo "✗ Deployment record is missing txHash" + exit 1 +fi + +echo "✓ Deployment record is valid" + +# Run a quick test to make sure the test framework works +echo "" +echo "Running mock tests..." +pnpm run test -- hello-world.mock.test.ts + +echo "✓ Mock tests passed" + +echo "" +echo "========================================" +echo "✓ All offckb create integration tests passed!" +echo "========================================" + +exit 0 From 984a8b3d655756a2e3e9de6e122386ecfcacaeb2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 03:39:42 +0000 Subject: [PATCH 3/8] Fix create-test.sh to install dependencies during project creation Co-authored-by: RetricSu <23436060+RetricSu@users.noreply.github.com> --- scripts/create-test.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/create-test.sh b/scripts/create-test.sh index f1e04cc..21f54e0 100755 --- a/scripts/create-test.sh +++ b/scripts/create-test.sh @@ -71,7 +71,7 @@ fi echo "" echo "Creating test project with offckb create..." cd /tmp -pnpm start create "$TEST_PROJECT_NAME" --no-interactive --no-git --no-install -l typescript +pnpm start create "$TEST_PROJECT_NAME" --no-interactive --no-git -l typescript # Check if project was created if [ ! -d "$TEST_PROJECT_DIR" ]; then @@ -109,13 +109,17 @@ done echo "✓ All essential files are present" -# Install dependencies +# Note: Dependencies should have been installed during project creation +# since we didn't use --no-install flag echo "" -echo "Installing dependencies..." -cd "$TEST_PROJECT_DIR" -pnpm install --frozen-lockfile || pnpm install - -echo "✓ Dependencies installed" +echo "Checking if dependencies were installed..." +if [ ! -d "$TEST_PROJECT_DIR/node_modules" ]; then + echo "Dependencies not found, installing manually..." + cd "$TEST_PROJECT_DIR" + pnpm install --frozen-lockfile || pnpm install +else + echo "✓ Dependencies already installed" +fi # Build the project echo "" From c3b51dccef548c916b11ce030ee1a17a93cef8a2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 03:41:56 +0000 Subject: [PATCH 4/8] Address code review feedback: make test more deterministic and explicit Co-authored-by: RetricSu <23436060+RetricSu@users.noreply.github.com> --- scripts/create-test.sh | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/scripts/create-test.sh b/scripts/create-test.sh index 21f54e0..39fac17 100755 --- a/scripts/create-test.sh +++ b/scripts/create-test.sh @@ -71,7 +71,7 @@ fi echo "" echo "Creating test project with offckb create..." cd /tmp -pnpm start create "$TEST_PROJECT_NAME" --no-interactive --no-git -l typescript +pnpm start create "$TEST_PROJECT_NAME" --no-interactive --no-git --no-install -l typescript -c hello-world # Check if project was created if [ ! -d "$TEST_PROJECT_DIR" ]; then @@ -109,21 +109,18 @@ done echo "✓ All essential files are present" -# Note: Dependencies should have been installed during project creation -# since we didn't use --no-install flag +# Install dependencies explicitly to make test deterministic echo "" -echo "Checking if dependencies were installed..." -if [ ! -d "$TEST_PROJECT_DIR/node_modules" ]; then - echo "Dependencies not found, installing manually..." - cd "$TEST_PROJECT_DIR" - pnpm install --frozen-lockfile || pnpm install -else - echo "✓ Dependencies already installed" -fi +echo "Installing dependencies..." +cd "$TEST_PROJECT_DIR" +pnpm install --frozen-lockfile || pnpm install + +echo "✓ Dependencies installed" # Build the project echo "" echo "Building the project..." +cd "$TEST_PROJECT_DIR" pnpm run build if [ ! -d "$TEST_PROJECT_DIR/dist" ]; then @@ -142,6 +139,7 @@ echo "✓ Project built successfully" # Deploy the project echo "" echo "Deploying the project..." +cd "$TEST_PROJECT_DIR" pnpm run deploy # Check if deployment artifacts were created @@ -172,6 +170,7 @@ echo "✓ Deployment record is valid" # Run a quick test to make sure the test framework works echo "" echo "Running mock tests..." +cd "$TEST_PROJECT_DIR" pnpm run test -- hello-world.mock.test.ts echo "✓ Mock tests passed" From 9e6eeba9fe09a7db57c6ed9205518646d22a98e6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 03:43:23 +0000 Subject: [PATCH 5/8] Improve test script readability and error messaging Co-authored-by: RetricSu <23436060+RetricSu@users.noreply.github.com> --- scripts/create-test.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/create-test.sh b/scripts/create-test.sh index 39fac17..dfb5a81 100755 --- a/scripts/create-test.sh +++ b/scripts/create-test.sh @@ -71,7 +71,18 @@ fi echo "" echo "Creating test project with offckb create..." cd /tmp -pnpm start create "$TEST_PROJECT_NAME" --no-interactive --no-git --no-install -l typescript -c hello-world +# Create project with explicit options: +# - --no-interactive: Skip all interactive prompts +# - --no-git: Skip git initialization (not needed for CI) +# - --no-install: Skip automatic dependency installation (we'll do it explicitly) +# - -l typescript: Use TypeScript language +# - -c hello-world: Name the first contract 'hello-world' +pnpm start create "$TEST_PROJECT_NAME" \ + --no-interactive \ + --no-git \ + --no-install \ + -l typescript \ + -c hello-world # Check if project was created if [ ! -d "$TEST_PROJECT_DIR" ]; then @@ -113,9 +124,15 @@ echo "✓ All essential files are present" echo "" echo "Installing dependencies..." cd "$TEST_PROJECT_DIR" -pnpm install --frozen-lockfile || pnpm install - -echo "✓ Dependencies installed" +# Note: First try with frozen-lockfile, but fall back to regular install +# since the newly created project might not have a lock file initially +if pnpm install --frozen-lockfile 2>/dev/null; then + echo "✓ Dependencies installed with frozen lockfile" +else + echo "⚠ Frozen lockfile not available, installing with regular mode..." + pnpm install + echo "✓ Dependencies installed" +fi # Build the project echo "" From f0bb39ef65378765d1918b5cd1f91e17ba0d9bf7 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Mon, 19 Jan 2026 09:52:58 +0800 Subject: [PATCH 6/8] fix create test script cd --- scripts/create-test.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/create-test.sh b/scripts/create-test.sh index dfb5a81..cbb27a4 100755 --- a/scripts/create-test.sh +++ b/scripts/create-test.sh @@ -70,14 +70,13 @@ fi # Create test project with non-interactive mode echo "" echo "Creating test project with offckb create..." -cd /tmp # Create project with explicit options: # - --no-interactive: Skip all interactive prompts # - --no-git: Skip git initialization (not needed for CI) # - --no-install: Skip automatic dependency installation (we'll do it explicitly) # - -l typescript: Use TypeScript language # - -c hello-world: Name the first contract 'hello-world' -pnpm start create "$TEST_PROJECT_NAME" \ +pnpm start create "$TEST_PROJECT_DIR" \ --no-interactive \ --no-git \ --no-install \ From 79b9efe1edd5eb19eddce5647d80823487c70da7 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Mon, 19 Jan 2026 10:06:50 +0800 Subject: [PATCH 7/8] add ckb-debugger install in ci --- .github/workflows/test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a64205b..ab4f6db 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,6 +41,12 @@ jobs: - name: Integration test - Start node and test RPC shell: bash run: bash scripts/starting-node-test.sh + + - uses: sigoden/install-binary@v1 + with: + repo: nervosnetwork/ckb-standalone-debugger + name: ckb-debugger + cache: true - name: Integration test - Create project workflow shell: bash From 98b26dede96fc04b6e95a167ded644eaf1fc7c59 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Mon, 19 Jan 2026 10:12:55 +0800 Subject: [PATCH 8/8] fix(ci): create test install offckb --- .github/workflows/test.yml | 6 ------ scripts/create-test.sh | 10 ++++++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab4f6db..6cd76d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,12 +42,6 @@ jobs: shell: bash run: bash scripts/starting-node-test.sh - - uses: sigoden/install-binary@v1 - with: - repo: nervosnetwork/ckb-standalone-debugger - name: ckb-debugger - cache: true - - name: Integration test - Create project workflow shell: bash run: bash scripts/create-test.sh diff --git a/scripts/create-test.sh b/scripts/create-test.sh index cbb27a4..6acb692 100755 --- a/scripts/create-test.sh +++ b/scripts/create-test.sh @@ -67,6 +67,12 @@ else exit 1 fi +# Install offckb since create test need it +echo "" +echo "Installing offckb CLI tool..." +npm install -g @offckb/cli +echo "✓ offckb installed" + # Create test project with non-interactive mode echo "" echo "Creating test project with offckb create..." @@ -187,9 +193,9 @@ echo "✓ Deployment record is valid" echo "" echo "Running mock tests..." cd "$TEST_PROJECT_DIR" -pnpm run test -- hello-world.mock.test.ts +pnpm run test -echo "✓ Mock tests passed" +echo "✓ All tests passed" echo "" echo "========================================"