From 0a3de63baaa3b5b6f7c04803702fa0bc8e247bf8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 05:11:50 +0000 Subject: [PATCH 1/8] Initial plan From fb07e511dd70b4b0d32105800e9eb6bd64ce96ee Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 05:15:29 +0000 Subject: [PATCH 2/8] Add comprehensive test scripts for ObjectDocs lifecycle Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> --- .gitignore | 7 +- README.md | 14 ++ TESTING.md | 327 +++++++++++++++++++++++++++++++++++++++++ package.json | 2 + test-quick.sh | 108 ++++++++++++++ test-site.sh | 392 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 849 insertions(+), 1 deletion(-) create mode 100644 TESTING.md create mode 100755 test-quick.sh create mode 100755 test-site.sh diff --git a/.gitignore b/.gitignore index 9727bcb..b7cd8b6 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,9 @@ next-env.d.ts .next # objectdocs -content/.objectdocs \ No newline at end of file +content/.objectdocs + +# test artifacts +/tmp/objectdocs-test-* +/tmp/dev-server.log +/tmp/start-server.log \ No newline at end of file diff --git a/README.md b/README.md index 6f06663..3edf5e6 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,20 @@ This repository is a monorepo managed by pnpm workspaces: - **[examples/starter](./examples/starter)**: A complete starter template demonstrating the recommended project structure. Includes comprehensive documentation on architecture, testing, and deployment guides. Ready for production use on Vercel and other platforms. +## 🧪 Testing + +ObjectDocs includes comprehensive test scripts to validate the complete lifecycle: + +```bash +# Quick build test (recommended for CI) +pnpm test:quick + +# Full lifecycle test (includes server startup tests) +pnpm test:site +``` + +See [TESTING.md](./TESTING.md) for detailed testing documentation. + ## 🤝 Contributing Contributions are welcome! Please read our [Contributing Guide](./CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests. diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 0000000..23e733d --- /dev/null +++ b/TESTING.md @@ -0,0 +1,327 @@ +# ObjectDocs Testing Guide + +This document describes how to test ObjectDocs across different scenarios and environments. + +## Test Scripts Overview + +ObjectDocs provides multiple test scripts to validate the complete lifecycle of documentation site creation, from initialization to production deployment. + +### Available Test Scripts + +#### 1. `test-site.sh` - Complete Lifecycle Test + +**Purpose**: Comprehensive end-to-end test covering the entire ObjectDocs workflow. + +**What it tests**: +- ✅ Project initialization (`pnpm init`) +- ✅ CLI installation (`@objectdocs/cli`) +- ✅ ObjectDocs initialization (`objectdocs init`) +- ✅ Content creation (MDX files, configuration) +- ✅ Development server startup and accessibility +- ✅ Production build compilation +- ✅ Production server startup and accessibility + +**Usage**: +```bash +./test-site.sh +``` + +**Duration**: ~2-5 minutes (includes server startup tests) + +**Requirements**: +- Node.js +- pnpm +- curl (for HTTP testing) +- Available port 7777 + +**Output**: Detailed step-by-step progress with color-coded success/failure indicators. + +#### 2. `test-quick.sh` - Quick Build Test + +**Purpose**: Fast CI/CD-friendly test that validates build process without running servers. + +**What it tests**: +- ✅ Project initialization +- ✅ CLI installation +- ✅ ObjectDocs initialization +- ✅ Content creation +- ✅ Build compilation +- ✅ Build output verification + +**Usage**: +```bash +./test-quick.sh +``` + +**Duration**: ~1-2 minutes + +**Requirements**: +- Node.js +- pnpm + +**Output**: Minimal output focused on build success. + +#### 3. `examples/starter/validate.sh` - Starter Template Validation + +**Purpose**: Validates the example starter template structure and configuration. + +**What it tests**: +- ✅ package.json configuration +- ✅ Content directory structure +- ✅ Configuration files (docs.site.json, meta.json) +- ✅ MDX frontmatter validity +- ✅ Dependencies installation +- ✅ Vercel configuration +- ✅ .gitignore setup + +**Usage**: +```bash +cd examples/starter +./validate.sh +``` + +**Duration**: < 10 seconds + +**Requirements**: None (static file validation only) + +## Testing Scenarios + +### 1. Local Development Testing + +When working on ObjectDocs itself: + +```bash +# In the monorepo root +pnpm install +pnpm build + +# Run comprehensive test +./test-site.sh +``` + +### 2. CI/CD Testing + +For automated testing in CI/CD pipelines: + +```bash +# Quick test (recommended for CI) +./test-quick.sh + +# Or full test if time permits +./test-site.sh +``` + +Add to your CI configuration: +```yaml +# .github/workflows/test.yml +- name: Run ObjectDocs tests + run: | + chmod +x ./test-quick.sh + ./test-quick.sh +``` + +### 3. Testing Standalone Installation + +To test as an end user would experience it (outside monorepo): + +```bash +# Create a temporary directory +mkdir /tmp/objectdocs-standalone-test +cd /tmp/objectdocs-standalone-test + +# Initialize project +pnpm init -y + +# Install CLI from npm (or local tarball) +pnpm add -D @objectdocs/cli + +# Configure scripts +cat > package.json << 'EOF' +{ + "name": "test-site", + "scripts": { + "dev": "objectdocs dev", + "build": "objectdocs build", + "start": "objectdocs start" + }, + "devDependencies": { + "@objectdocs/cli": "latest" + } +} +EOF + +# Initialize ObjectDocs +pnpm objectdocs init + +# Create content +mkdir -p content/docs +# ... add your content files + +# Test +pnpm build +pnpm start +``` + +### 4. Testing with npm pack + +For pre-release testing: + +```bash +# In the monorepo +cd packages/cli +pnpm pack +# Creates objectdocs-cli-X.X.X.tgz + +# In a test directory +mkdir /tmp/test-tarball +cd /tmp/test-tarball +pnpm init -y +pnpm add -D ../../packages/cli/objectdocs-cli-X.X.X.tgz + +# Continue with normal setup +``` + +## Manual Testing Checklist + +When preparing for a release, manually verify: + +### Development Workflow +- [ ] `pnpm objectdocs init` creates `.objectdocs` directory +- [ ] `pnpm dev` starts development server on port 7777 +- [ ] Hot reload works when editing MDX files +- [ ] Hot reload works when editing `meta.json` +- [ ] Hot reload works when editing `docs.site.json` + +### Build Process +- [ ] `pnpm build` completes without errors +- [ ] Build output is created in `content/.objectdocs/.next` +- [ ] No TypeScript errors +- [ ] No ESLint errors (if configured) + +### Production Server +- [ ] `pnpm start` runs the production build +- [ ] All pages are accessible +- [ ] Navigation works correctly +- [ ] Search functionality works (if enabled) +- [ ] Dark mode toggle works + +### Content Features +- [ ] MDX frontmatter is parsed correctly +- [ ] Code blocks render with syntax highlighting +- [ ] Callouts and custom components render +- [ ] Internal links work +- [ ] External links work +- [ ] Images load correctly + +### Configuration +- [ ] Branding (name, logo) appears correctly +- [ ] Navigation links appear in header +- [ ] Sidebar structure matches `meta.json` +- [ ] SEO meta tags are generated + +## Troubleshooting + +### Common Test Failures + +#### "Port 7777 already in use" + +**Solution**: +```bash +# Kill any process using port 7777 +lsof -ti:7777 | xargs kill -9 + +# Or use a different port +PORT=8888 ./test-site.sh +``` + +#### "Build timeout" + +**Cause**: Build taking longer than 5 minutes. + +**Solution**: Increase `BUILD_TIMEOUT` in test script or check for build errors: +```bash +cd /tmp/objectdocs-test-* +pnpm build +``` + +#### "Cannot find module '@objectdocs/site'" + +**Cause**: CLI not finding the site package. + +**Solution**: Ensure you've built the monorepo first: +```bash +cd /home/runner/work/objectdocs/objectdocs +pnpm install +pnpm build +``` + +#### "Dev server failed to start" + +**Cause**: Port conflict or build error. + +**Solution**: Check the server logs: +```bash +cat /tmp/dev-server.log +``` + +### Debug Mode + +Run tests with verbose output: + +```bash +# Enable bash debug mode +bash -x ./test-site.sh + +# Or add set -x to the script temporarily +``` + +## Test Coverage + +### What is Tested +- ✅ CLI installation and initialization +- ✅ Content creation workflow +- ✅ Development server functionality +- ✅ Production build process +- ✅ Production server functionality +- ✅ Configuration file validation +- ✅ MDX file parsing + +### What is NOT Tested (Yet) +- ⚠️ Translation features (`objectdocs translate`) +- ⚠️ Interactive UI components +- ⚠️ Search functionality +- ⚠️ Browser-based E2E tests +- ⚠️ Multiple language support +- ⚠️ Theme customization + +## Contributing Test Improvements + +When adding new features to ObjectDocs, please: + +1. **Update test scripts** if the feature affects the core workflow +2. **Add manual test steps** to this document +3. **Document new configuration** that should be validated +4. **Add edge cases** to the test suite + +### Adding a New Test Script + +1. Create the script in the root directory +2. Make it executable: `chmod +x test-name.sh` +3. Document it in this file +4. Add it to CI configuration if appropriate + +### Test Script Standards + +All test scripts should: +- Use `set -e` to exit on errors +- Include color-coded output +- Clean up temporary files on exit +- Provide clear success/failure messages +- Include a summary section +- Be idempotent (can run multiple times safely) + +## References + +- [examples/starter/TESTING.md](./examples/starter/TESTING.md) - Standalone testing guide +- [examples/starter/validate.sh](./examples/starter/validate.sh) - Template validation script +- [README.md](./README.md) - Main project documentation diff --git a/package.json b/package.json index 62f784b..66f3b93 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,8 @@ "translate": "objectdocs translate", "translate:all": "objectdocs translate --all", "test": "pnpm -r test", + "test:site": "bash test-site.sh", + "test:quick": "bash test-quick.sh", "changeset": "changeset", "release": "changeset publish" }, diff --git a/test-quick.sh b/test-quick.sh new file mode 100755 index 0000000..f0aea63 --- /dev/null +++ b/test-quick.sh @@ -0,0 +1,108 @@ +#!/bin/bash +# Quick test script for CI/CD environments +# Tests basic build functionality without running servers + +set -e + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +BLUE='\033[0;34m' +NC='\033[0m' + +print_section() { + echo "" + echo "================================================" + echo -e "${BLUE}$1${NC}" + echo "================================================" +} + +print_success() { + echo -e "${GREEN}✓${NC} $1" +} + +print_error() { + echo -e "${RED}✗${NC} $1" +} + +TEST_DIR="/tmp/objectdocs-quick-test-$(date +%s)" + +# Cleanup on exit +cleanup() { + if [ -d "$TEST_DIR" ]; then + rm -rf "$TEST_DIR" + fi +} +trap cleanup EXIT + +main() { + print_section "ObjectDocs Quick Build Test" + + # Create test project + mkdir -p "$TEST_DIR" + cd "$TEST_DIR" + + pnpm init -y + print_success "Initialized project" + + # Install CLI from workspace + MONOREPO_ROOT="/home/runner/work/objectdocs/objectdocs" + pnpm add -D "$MONOREPO_ROOT/packages/cli" + print_success "Installed @objectdocs/cli" + + # Configure scripts + pnpm pkg set scripts.build="objectdocs build" + + # Initialize ObjectDocs + pnpm objectdocs init + print_success "Initialized ObjectDocs" + + # Create minimal content + mkdir -p content/docs + + cat > content/docs.site.json << 'EOF' +{ + "branding": { + "name": "Test Site" + } +} +EOF + + cat > content/docs/meta.json << 'EOF' +{ + "pages": ["index"] +} +EOF + + cat > content/docs/index.mdx << 'EOF' +--- +title: Test +description: Test page +--- +# Test Page +EOF + + print_success "Created content" + + # Run build + print_section "Running Build" + if pnpm build; then + print_success "Build completed successfully" + else + print_error "Build failed" + exit 1 + fi + + # Check build output + if [ -d "content/.objectdocs/.next" ] || [ -d ".next" ]; then + print_success "Build output exists" + else + print_error "Build output not found" + exit 1 + fi + + print_section "Summary" + echo -e "${GREEN}✅ Quick build test passed!${NC}" +} + +main "$@" diff --git a/test-site.sh b/test-site.sh new file mode 100755 index 0000000..b3e5e0d --- /dev/null +++ b/test-site.sh @@ -0,0 +1,392 @@ +#!/bin/bash +# ObjectDocs Site Testing Script +# Tests the complete lifecycle: init -> create -> startup -> build -> run +# 测试站点完整流程:初始化 -> 创建 -> 启动 -> 编译 -> 运行 + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Configuration +TEST_DIR="/tmp/objectdocs-test-$(date +%s)" +PORT=7777 +BUILD_TIMEOUT=300 # 5 minutes for build +DEV_TIMEOUT=30 # 30 seconds for dev server to start + +# Cleanup function +cleanup() { + echo "" + echo -e "${BLUE}Cleaning up...${NC}" + + # Kill any running dev/start servers + if [ ! -z "$DEV_PID" ]; then + kill $DEV_PID 2>/dev/null || true + fi + if [ ! -z "$START_PID" ]; then + kill $START_PID 2>/dev/null || true + fi + + # Kill any process using the test port + lsof -ti:$PORT | xargs kill -9 2>/dev/null || true + + # Remove test directory + if [ -d "$TEST_DIR" ]; then + rm -rf "$TEST_DIR" + fi + + echo -e "${BLUE}Cleanup complete${NC}" +} + +# Register cleanup on exit +trap cleanup EXIT + +# Print section header +print_section() { + echo "" + echo "================================================" + echo -e "${BLUE}$1${NC}" + echo "================================================" +} + +# Print success message +print_success() { + echo -e "${GREEN}✓${NC} $1" +} + +# Print error message +print_error() { + echo -e "${RED}✗${NC} $1" +} + +# Print warning message +print_warning() { + echo -e "${YELLOW}⚠${NC} $1" +} + +# Print info message +print_info() { + echo -e "${BLUE}ℹ${NC} $1" +} + +# Check if command exists +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +# Wait for server to be ready +wait_for_server() { + local port=$1 + local timeout=$2 + local elapsed=0 + + print_info "Waiting for server on port $port (timeout: ${timeout}s)..." + + while [ $elapsed -lt $timeout ]; do + if curl -s http://localhost:$port > /dev/null 2>&1; then + return 0 + fi + sleep 2 + elapsed=$((elapsed + 2)) + done + + return 1 +} + +# Main test script +main() { + print_section "ObjectDocs Complete Lifecycle Test" + echo "Test directory: $TEST_DIR" + echo "Port: $PORT" + echo "" + + # Check prerequisites + print_section "Step 0: Checking Prerequisites" + + if ! command_exists node; then + print_error "Node.js is not installed" + exit 1 + fi + print_success "Node.js installed: $(node --version)" + + if ! command_exists pnpm; then + print_error "pnpm is not installed" + exit 1 + fi + print_success "pnpm installed: $(pnpm --version)" + + if ! command_exists curl; then + print_error "curl is not installed" + exit 1 + fi + print_success "curl installed" + + # Step 1: Create test directory and initialize project + print_section "Step 1: Initializing New Project" + + mkdir -p "$TEST_DIR" + cd "$TEST_DIR" + print_success "Created test directory: $TEST_DIR" + + # Initialize package.json + print_info "Running pnpm init..." + pnpm init -y + print_success "package.json created" + + # Install @objectdocs/cli as dev dependency + print_info "Installing @objectdocs/cli..." + + # Get the absolute path to the monorepo root + MONOREPO_ROOT="/home/runner/work/objectdocs/objectdocs" + + # Install CLI from workspace + if [ -d "$MONOREPO_ROOT/packages/cli" ]; then + print_info "Installing CLI from local workspace..." + pnpm add -D "$MONOREPO_ROOT/packages/cli" + else + print_error "CLI package not found at $MONOREPO_ROOT/packages/cli" + exit 1 + fi + print_success "@objectdocs/cli installed" + + # Step 2: Configure scripts + print_section "Step 2: Configuring Package Scripts" + + # Add scripts to package.json using pnpm pkg + pnpm pkg set scripts.dev="objectdocs dev" + pnpm pkg set scripts.build="objectdocs build" + pnpm pkg set scripts.start="objectdocs start" + + print_success "Scripts configured in package.json" + + # Step 3: Initialize ObjectDocs + print_section "Step 3: Running ObjectDocs Init" + + print_info "Running: pnpm objectdocs init" + if pnpm objectdocs init; then + print_success "ObjectDocs initialized successfully" + else + print_error "ObjectDocs init failed" + exit 1 + fi + + # Verify init created necessary files + if [ -d "content/.objectdocs" ]; then + print_success "Site engine copied to content/.objectdocs" + else + print_warning "content/.objectdocs not found (might use different structure)" + fi + + # Step 4: Create content + print_section "Step 4: Creating Documentation Content" + + mkdir -p content/docs + print_success "Created content/docs directory" + + # Create docs.site.json + cat > content/docs.site.json << 'EOF' +{ + "branding": { + "name": "Test Site", + "description": "ObjectDocs Test Site" + }, + "links": [ + { "text": "Home", "url": "/" }, + { "text": "Docs", "url": "/docs" } + ] +} +EOF + print_success "Created content/docs.site.json" + + # Create meta.json + cat > content/docs/meta.json << 'EOF' +{ + "title": "Documentation", + "pages": ["index", "getting-started"] +} +EOF + print_success "Created content/docs/meta.json" + + # Create index.mdx + cat > content/docs/index.mdx << 'EOF' +--- +title: Welcome to ObjectDocs +description: Getting started with ObjectDocs +--- + +# Welcome to ObjectDocs + +This is a test documentation site created to validate the ObjectDocs setup process. + +## Features + +- Fast and modern documentation engine +- Built on Next.js 14 +- Powered by Fumadocs +- Configuration as Code + +## Next Steps + +Check out the [Getting Started](/docs/getting-started) guide to learn more. +EOF + print_success "Created content/docs/index.mdx" + + # Create getting-started.mdx + cat > content/docs/getting-started.mdx << 'EOF' +--- +title: Getting Started +description: Quick start guide for ObjectDocs +--- + +# Getting Started + +Welcome to the ObjectDocs quick start guide! + +## Installation + +```bash +pnpm add -D @objectdocs/cli +``` + +## Usage + +Start the development server: + +```bash +pnpm dev +``` + +Build for production: + +```bash +pnpm build +``` + +Start production server: + +```bash +pnpm start +``` +EOF + print_success "Created content/docs/getting-started.mdx" + + # Step 5: Test development server + print_section "Step 5: Testing Development Server" + + print_info "Starting dev server..." + pnpm dev > /tmp/dev-server.log 2>&1 & + DEV_PID=$! + + if wait_for_server $PORT $DEV_TIMEOUT; then + print_success "Dev server started successfully on http://localhost:$PORT" + + # Test if we can fetch the homepage + if curl -s http://localhost:$PORT > /dev/null; then + print_success "Homepage is accessible" + else + print_warning "Homepage returned unexpected response" + fi + + # Test if we can fetch a docs page + if curl -s http://localhost:$PORT/docs > /dev/null; then + print_success "Docs page is accessible" + else + print_warning "Docs page returned unexpected response" + fi + else + print_error "Dev server failed to start within ${DEV_TIMEOUT}s" + print_info "Server log output:" + cat /tmp/dev-server.log || true + exit 1 + fi + + # Stop dev server + print_info "Stopping dev server..." + kill $DEV_PID 2>/dev/null || true + wait $DEV_PID 2>/dev/null || true + DEV_PID="" + sleep 2 + print_success "Dev server stopped" + + # Step 6: Test build process + print_section "Step 6: Testing Build Process" + + print_info "Running build (this may take a few minutes)..." + if timeout $BUILD_TIMEOUT pnpm build; then + print_success "Build completed successfully" + else + print_error "Build failed or timed out" + exit 1 + fi + + # Check if build output exists + if [ -d "content/.objectdocs/.next" ] || [ -d ".next" ]; then + print_success "Build output directory created" + else + print_warning "Build output directory not found in expected locations" + fi + + # Step 7: Test production server + print_section "Step 7: Testing Production Server" + + print_info "Starting production server..." + pnpm start > /tmp/start-server.log 2>&1 & + START_PID=$! + + if wait_for_server $PORT $DEV_TIMEOUT; then + print_success "Production server started successfully on http://localhost:$PORT" + + # Test if we can fetch the homepage + if curl -s http://localhost:$PORT > /dev/null; then + print_success "Production homepage is accessible" + else + print_warning "Production homepage returned unexpected response" + fi + + # Test if we can fetch a docs page + if curl -s http://localhost:$PORT/docs > /dev/null; then + print_success "Production docs page is accessible" + else + print_warning "Production docs page returned unexpected response" + fi + else + print_error "Production server failed to start within ${DEV_TIMEOUT}s" + print_info "Server log output:" + cat /tmp/start-server.log || true + exit 1 + fi + + # Stop production server + print_info "Stopping production server..." + kill $START_PID 2>/dev/null || true + wait $START_PID 2>/dev/null || true + START_PID="" + sleep 2 + print_success "Production server stopped" + + # Final summary + print_section "Test Summary" + + echo "" + echo -e "${GREEN}✅ All tests passed successfully!${NC}" + echo "" + echo "Tested lifecycle stages:" + echo " ✓ Project initialization (pnpm init)" + echo " ✓ CLI installation (@objectdocs/cli)" + echo " ✓ ObjectDocs initialization (objectdocs init)" + echo " ✓ Content creation (MDX files, configuration)" + echo " ✓ Development server (pnpm dev)" + echo " ✓ Production build (pnpm build)" + echo " ✓ Production server (pnpm start)" + echo "" + echo "Test directory: $TEST_DIR" + echo "" + print_info "Test directory will be cleaned up on exit" +} + +# Run main function +main "$@" From ba5f67a2e06ec17c3598b27f5c9b6148d72b20b1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 05:18:17 +0000 Subject: [PATCH 3/8] Fix cleanup and add CI workflow for tests Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> --- .github/workflows/test-lifecycle.yml | 77 ++++++++++++++++++++++++++++ test-quick.sh | 4 +- test-site.sh | 8 +-- 3 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/test-lifecycle.yml diff --git a/.github/workflows/test-lifecycle.yml b/.github/workflows/test-lifecycle.yml new file mode 100644 index 0000000..0c971cf --- /dev/null +++ b/.github/workflows/test-lifecycle.yml @@ -0,0 +1,77 @@ +name: Test ObjectDocs Lifecycle + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] + workflow_dispatch: + +jobs: + test-quick: + name: Quick Build Test + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + + - name: Install dependencies + run: pnpm install + + - name: Run quick build test + run: pnpm test:quick + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: quick-test-results + path: /tmp/test-*.log + retention-days: 7 + if-no-files-found: ignore + + test-full: + name: Full Lifecycle Test + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + + - name: Install dependencies + run: pnpm install + + - name: Run full lifecycle test + run: pnpm test:site + + - name: Upload server logs + if: always() + uses: actions/upload-artifact@v4 + with: + name: full-test-results + path: | + /tmp/dev-server.log + /tmp/start-server.log + retention-days: 7 + if-no-files-found: ignore diff --git a/test-quick.sh b/test-quick.sh index f0aea63..65e9d3a 100755 --- a/test-quick.sh +++ b/test-quick.sh @@ -30,7 +30,7 @@ TEST_DIR="/tmp/objectdocs-quick-test-$(date +%s)" # Cleanup on exit cleanup() { if [ -d "$TEST_DIR" ]; then - rm -rf "$TEST_DIR" + rm -rf "$TEST_DIR" 2>/dev/null || true fi } trap cleanup EXIT @@ -42,7 +42,7 @@ main() { mkdir -p "$TEST_DIR" cd "$TEST_DIR" - pnpm init -y + echo "{}" > package.json print_success "Initialized project" # Install CLI from workspace diff --git a/test-site.sh b/test-site.sh index b3e5e0d..b0c19e2 100755 --- a/test-site.sh +++ b/test-site.sh @@ -34,9 +34,9 @@ cleanup() { # Kill any process using the test port lsof -ti:$PORT | xargs kill -9 2>/dev/null || true - # Remove test directory + # Remove test directory (force recursive delete) if [ -d "$TEST_DIR" ]; then - rm -rf "$TEST_DIR" + rm -rf "$TEST_DIR" 2>/dev/null || true fi echo -e "${BLUE}Cleanup complete${NC}" @@ -133,8 +133,8 @@ main() { print_success "Created test directory: $TEST_DIR" # Initialize package.json - print_info "Running pnpm init..." - pnpm init -y + print_info "Creating package.json..." + echo "{}" > package.json print_success "package.json created" # Install @objectdocs/cli as dev dependency From e5e664750a66e77440abbc54397a096e07daf923 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 05:20:05 +0000 Subject: [PATCH 4/8] Add Makefile and Chinese testing documentation Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> --- Makefile | 46 ++++++ TESTING.zh-CN.md | 356 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 402 insertions(+) create mode 100644 Makefile create mode 100644 TESTING.zh-CN.md diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..75566da --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +# ObjectDocs Development Tasks +# Run with: make or pnpm run