From 9f0aed11c6967eba231cbc2f400f984d246d9cd0 Mon Sep 17 00:00:00 2001 From: Elliott de Launay Date: Tue, 27 Oct 2026 02:05:27 +0000 Subject: [PATCH 1/2] fix(build): replace required Git LFS archive with automatic generation --- .gitattributes | 2 - .github/workflows/pr.yml | 1 + .github/workflows/release.yml | 4 +- BUILD.md | 6 + CHANGELOG.md | 7 + README.md | 2 +- jetbrains_plugin/.gitignore | 6 +- jetbrains_plugin/build.gradle.kts | 43 ++++-- jetbrains_plugin/platform.zip | 3 - scripts/setup.sh | 65 +-------- scripts/test.sh | 221 +++++++++++++++++------------- test-results/test-report.txt | 23 ++++ 12 files changed, 208 insertions(+), 175 deletions(-) delete mode 100644 jetbrains_plugin/platform.zip create mode 100644 test-results/test-report.txt diff --git a/.gitattributes b/.gitattributes index 2e0da0e..b086bda 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1 @@ -jetbrains_plugin/platform.zip filter=lfs diff=lfs merge=lfs -text - *.ps1 text eol=crlf diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 916504b..66d5bdf 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -4,6 +4,7 @@ on: pull_request: paths: - "jetbrains_plugin/**" + - "scripts/**" - ".github/workflows/pr.yml" permissions: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 78eb161..d7e093c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -135,10 +135,12 @@ jobs: contents: write steps: + # The repository stores no Git LFS objects: the platform archive is + # generated by the build. A plain checkout keeps releases independent of + # LFS object availability. - name: Check out the JetBrains plugin uses: actions/checkout@v5 with: - lfs: true submodules: recursive persist-credentials: false diff --git a/BUILD.md b/BUILD.md index bb15ebe..b665ff2 100644 --- a/BUILD.md +++ b/BUILD.md @@ -153,6 +153,12 @@ ZOO_EXTENSION_VERSION=3.78.0 ./scripts/release.sh --mode release --clean - Optimized builds - Production-ready artifacts - Minimal debug information +- Packages the VS Code platform archive: when `jetbrains_plugin/platform.zip` is + missing or invalid, the build runs the `genPlatform` task, which downloads the + four VS Code distributions pinned by `vscodeVersion` in + `jetbrains_plugin/gradle.properties` and merges their node_modules. The + archive is not stored in git and the repository needs no Git LFS. The + generation needs network access to `update.code.visualstudio.com`. ### Debug Mode - Development builds diff --git a/CHANGELOG.md b/CHANGELOG.md index f550b04..b8fb9fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,3 +7,10 @@ - The plugin requests ConPTY explicitly through the public pty4j setter. The JetBrains registry key `terminal.use.conpty.on.windows` is no longer read. - If the ConPTY native library fails to load, the process falls back to winpty and the session continues. - Other process start failures propagate to the terminal error handling. + +### Checkout and release builds without Git LFS + +- `jetbrains_plugin/platform.zip` is no longer stored in git, and `.gitattributes` no longer tracks it with Git LFS. Fresh clones, including Windows and WSL checkouts, no longer fail on a missing LFS object. +- Release builds run the existing `genPlatform` task when the archive is missing or invalid and package the generated archive. A stale Git LFS pointer left by an older checkout also triggers regeneration. +- `scripts/setup.sh` no longer requires or installs Git LFS. +- The pull request workflow now also runs when files under `scripts/` change. diff --git a/README.md b/README.md index 9748cbe..d13bf4e 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,6 @@ The installable plugin is written to the `dist/` directory. Install that ZIP thr The setup script handles: -- Git LFS initialization - Git submodule initialization and updates - Dependency installation - Patch application @@ -136,6 +135,7 @@ The build script then: - Downloads the latest Zoo Code extension from the VS Code Marketplace - Builds the Extension Host runtime +- Generates the VS Code platform archive (`platform.zip`) when a release build needs it and no valid archive is present; the archive is not stored in git and the repository requires no Git LFS - Builds the JetBrains plugin with Zoo Code integrated - Writes a ready-to-install plugin to the `dist/` directory diff --git a/jetbrains_plugin/.gitignore b/jetbrains_plugin/.gitignore index a9088e4..9c07758 100644 --- a/jetbrains_plugin/.gitignore +++ b/jetbrains_plugin/.gitignore @@ -4,6 +4,10 @@ .gradle build/ + +# Generated from the VS Code distributions by the genPlatform task; never +# committed. See build.gradle.kts and genPlatform.gradle. +/platform.zip !gradle/wrapper/gradle-wrapper.jar !**/src/main/**/build/ !**/src/test/**/build/ @@ -50,4 +54,4 @@ zoo-code-messages.log prodDep.txt ### Backup files ### -*.bak \ No newline at end of file +*.bak diff --git a/jetbrains_plugin/build.gradle.kts b/jetbrains_plugin/build.gradle.kts index 609f245..9bdf5e2 100644 --- a/jetbrains_plugin/build.gradle.kts +++ b/jetbrains_plugin/build.gradle.kts @@ -47,7 +47,10 @@ val verificationJavaLauncher = javaToolchains.launcherFor { // - Typically used when running IntelliJ with an Extension Host for live debugging and hot-reloading. // // 2. "release" — Production build mode (used to generate deployment artifacts) -// - Requires platform.zip to exist, which can be retrieved via git-lfs or generated with genPlatform.gradle. +// - Packages platform.zip, which the genPlatform task generates from the VS Code +// distributions pinned by vscodeVersion in gradle.properties. The archive is not +// stored in git; when it is missing or invalid, prepareSandbox depends on +// genPlatform and the archive is generated before the sandbox is prepared. // - This file includes the full runtime environment for VSCode plugins (e.g., node_modules, platform.txt). // - The zip is extracted to build/platform/, and its node_modules take precedence over other dependencies. // - Copies compiled extension_host outputs (dist, package.json, node_modules) and plugin resources. @@ -183,25 +186,45 @@ fun Sync.prepareSandbox() { copyAndTrack("src/main/resources/themes/", "${sandboxDir}/${vsCodePluginName}/integrations/theme/default-themes/") copyAndTrack("src/main/resources/themes/", "${sandboxDir}/themes/") - // The platform.zip file required for release mode is associated with the code in ../base/vscode, currently using version 1.100.0. If upgrading this code later - // Need to modify the vscodeVersion value in gradle.properties, then execute the task named genPlatform, which will generate a new platform.zip file for submission - // To support new architectures, modify according to the logic in genPlatform.gradle script + // The platform.zip archive holds the merged node_modules of the four VS Code + // distributions pinned by vscodeVersion in gradle.properties. It is not stored + // in git: genPlatform builds it, and prepareSandbox depends on that task when + // the archive is missing or invalid (for example a stale Git LFS pointer left + // by an older checkout). To support new architectures, modify genPlatform.gradle. if (debugMode == "release") { - // Check if platform.zip file exists and is larger than 1MB, otherwise throw exception - val platformZip = File("platform.zip") - if (platformZip.exists() && platformZip.length() >= 1024 * 1024) { + // Resolved against the project directory: the daemon working directory + // is not the project directory. + val platformZip = project.file("platform.zip") + val platformUsable = platformZip.exists() && platformZip.length() >= 1024 * 1024 + val platformDir = File("${project.buildDir}/platform") + if (platformUsable) { // Extract platform.zip to the platform subdirectory under the project build directory - val platformDir = File("${project.buildDir}/platform") platformDir.mkdirs() logger.lifecycle("[prepareSandbox] Extracting platform.zip -> ${platformDir.absolutePath}") copy { from(zipTree(platformZip)) into(platformDir) } - copyOps.add(platformZip.absolutePath to platformDir.absolutePath) } else { - throw IllegalStateException("platform.zip file does not exist or is smaller than 1MB. This file is supported through git lfs and needs to be obtained through git lfs") + logger.lifecycle("[prepareSandbox] platform.zip is missing or invalid; genPlatform will generate it before the sandbox is prepared") + dependsOn(project.tasks.named("genPlatform")) + // genPlatform runs before this task, so the archive can only be + // extracted at execution time. + doFirst { + val generatedZip = project.file("platform.zip") + check(generatedZip.exists() && generatedZip.length() >= 1024 * 1024) { + "genPlatform did not produce a valid platform.zip at ${generatedZip.absolutePath}. " + + "Check network access to update.code.visualstudio.com and the vscodeVersion value in gradle.properties." + } + platformDir.mkdirs() + logger.lifecycle("[prepareSandbox] Extracting platform.zip -> ${platformDir.absolutePath}") + project.copy { + from(zipTree(generatedZip)) + into(platformDir) + } + } } + copyOps.add(platformZip.absolutePath to platformDir.absolutePath) copyAndTrack(File(project.buildDir, "platform/platform.txt"), "${sandboxDir}/") // Copy platform node_modules last to ensure it takes precedence over extension_host node_modules diff --git a/jetbrains_plugin/platform.zip b/jetbrains_plugin/platform.zip deleted file mode 100644 index 33911e5..0000000 --- a/jetbrains_plugin/platform.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3706ca90dc04ebc1a9bc1ffc48a3cbe033f9fa68f23a4ea30b38e9a1eac9df1e -size 46079271 diff --git a/scripts/setup.sh b/scripts/setup.sh index b9a4643..789def5 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -31,8 +31,6 @@ USAGE: DESCRIPTION: DESCRIPTION: This script initializes the development environment by: - - Validating system requirements (including Git LFS) - - Setting up Git LFS for large file handling - Initializing git submodules - Installing project dependencies - Applying necessary patches @@ -57,8 +55,11 @@ ENVIRONMENT: SKIP_VALIDATION Skip environment validation if set to 'true' REQUIREMENTS: - - Git LFS must be installed for handling large files - - Run 'git lfs install' manually if setup fails + - Git, unzip and curl must be installed + +NOTES: + - The release-mode platform archive is generated by the Gradle build when + needed; this script does not handle it. EXIT CODES: 0 Success @@ -133,12 +134,6 @@ validate_system_requirements() { log_debug "Found development tool: $tool" done - # Check for Git LFS - if ! command_exists "git-lfs"; then - die "Git LFS not found. Please install Git LFS: https://git-lfs.github.io/" 2 - fi - log_debug "Found Git LFS" - # Check Git configuration if ! git config user.name >/dev/null 2>&1; then log_warn "Git user.name not configured. Run: git config --global user.name 'Your Name'" @@ -163,55 +158,6 @@ validate_system_requirements() { log_success "System requirements validated" } -# Initialize Git LFS -setup_git_lfs() { - log_step "Setting up Git LFS..." - - cd "$PROJECT_ROOT" - - # Check if Git LFS is already initialized - if git lfs env >/dev/null 2>&1; then - log_debug "Git LFS environment already configured" - else - log_info "Initializing Git LFS..." - execute_cmd "git lfs install" "Git LFS installation" - fi - - # Check if .gitattributes exists and has LFS entries - if [[ -f ".gitattributes" ]]; then - local lfs_files - lfs_files=$(grep -c "filter=lfs" .gitattributes 2>/dev/null || echo "0") - if [[ "$lfs_files" -gt 0 ]]; then - log_info "Found $lfs_files LFS file pattern(s) in .gitattributes" - - # Pull LFS files - log_info "Pulling LFS files..." - execute_cmd "git lfs pull" "Git LFS pull" - - # Verify LFS files - log_info "Verifying LFS files..." - if git lfs ls-files >/dev/null 2>&1; then - local lfs_file_count - lfs_file_count=$(git lfs ls-files | wc -l | tr -d ' ') - if [[ "$lfs_file_count" -gt 0 ]]; then - log_success "Successfully pulled $lfs_file_count LFS file(s)" - git lfs ls-files | while read -r line; do - log_debug "LFS file: $line" - done - else - log_warn "No LFS files found in repository" - fi - fi - else - log_info "No LFS file patterns found in .gitattributes" - fi - else - log_warn "No .gitattributes file found, skipping LFS file pull" - fi - - log_success "Git LFS setup completed" -} - # Initialize git submodules setup_submodules() { if [[ "$SKIP_SUBMODULES" == "true" ]]; then @@ -502,7 +448,6 @@ main() { # Run setup steps validate_system_requirements - setup_git_lfs setup_submodules install_dependencies apply_patches diff --git a/scripts/test.sh b/scripts/test.sh index c64a464..52f4dc8 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -7,6 +7,8 @@ set -euo pipefail # Source common utilities source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/common.sh" +# Provides IDEA_DIR and the build configuration shared with build.sh and setup.sh +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/build.sh" # Script configuration readonly SCRIPT_NAME="test.sh" @@ -119,7 +121,7 @@ parse_test_args() { ;; esac done - + # Validate test type case "$TEST_TYPE" in "$TEST_ALL"|"$TEST_UNIT"|"$TEST_INTEGRATION"|"$TEST_LINT"|"$TEST_BUILD"|"$TEST_ENV") @@ -135,24 +137,24 @@ parse_test_args() { # Setup test environment setup_test_environment() { log_step "Setting up test environment..." - + # Set CI environment variables if [[ "${CI:-false}" == "true" ]]; then log_info "Running in CI environment" export NODE_ENV="test" export CI="true" fi - + # Set test timeout export TEST_TIMEOUT="${TEST_TIMEOUT:-300}" - + # Set coverage threshold export COVERAGE_THRESHOLD="${COVERAGE_THRESHOLD:-80}" - + # Create test output directories ensure_dir "$PROJECT_ROOT/test-results" ensure_dir "$PROJECT_ROOT/coverage" - + log_success "Test environment set up" } @@ -161,51 +163,52 @@ run_env_tests() { if [[ "$TEST_TYPE" != "$TEST_ENV" && "$TEST_TYPE" != "$TEST_ALL" ]]; then return 0 fi - + log_step "Running environment validation tests..." - + local test_failures=0 - + # Test 1: Validate system requirements log_info "Testing system requirements..." - if validate_environment 2>/dev/null; then + # Subshell contains die, so a failed validation counts instead of aborting + if (validate_environment) 2>/dev/null; then log_success "✓ System requirements test passed" else log_error "✗ System requirements test failed" - ((test_failures++)) + test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi - + # Test 2: Check project structure log_info "Testing project structure..." local required_dirs=("$EXTENSION_HOST_DIR" "$IDEA_DIR" "scripts") local structure_ok=true - + for dir in "${required_dirs[@]}"; do if [[ ! -d "$PROJECT_ROOT/$dir" ]]; then log_error "Required directory missing: $dir" structure_ok=false fi done - + if [[ "$structure_ok" == "true" ]]; then log_success "✓ Project structure test passed" else log_error "✗ Project structure test failed" - ((test_failures++)) + test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi - + # Test 3: Check Git configuration log_info "Testing Git configuration..." if git rev-parse --git-dir >/dev/null 2>&1; then log_success "✓ Git configuration test passed" else log_error "✗ Git configuration test failed" - ((test_failures++)) + test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi - + log_info "Environment tests completed with $test_failures failures" return $test_failures } @@ -215,17 +218,17 @@ run_lint_tests() { if [[ "$TEST_TYPE" != "$TEST_LINT" && "$TEST_TYPE" != "$TEST_ALL" ]]; then return 0 fi - + log_step "Running linting tests..." - + local test_failures=0 - + # Test shell scripts with shellcheck if available if command_exists "shellcheck"; then log_info "Running shellcheck on shell scripts..." local shell_files shell_files=$(find "$PROJECT_ROOT/scripts" -name "*.sh" -type f) - + if [[ -n "$shell_files" ]]; then if [[ "$DRY_RUN" == "true" ]]; then log_debug "Would run: shellcheck on shell scripts" @@ -234,7 +237,7 @@ run_lint_tests() { log_success "✓ Shell script linting passed" else log_error "✗ Shell script linting failed" - ((test_failures++)) + test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi fi @@ -242,13 +245,13 @@ run_lint_tests() { else log_warn "shellcheck not found, skipping shell script linting" fi - + # Test base extension linting local base_dir="$PROJECT_ROOT/$EXTENSION_HOST_DIR" if [[ -f "$base_dir/package.json" ]]; then log_info "Running base extension linting..." cd "$base_dir" - + if npm run lint --if-present >/dev/null 2>&1; then if [[ "$DRY_RUN" == "true" ]]; then log_debug "Would run: npm run lint in base directory" @@ -257,7 +260,7 @@ run_lint_tests() { log_success "✓ Base extension linting passed" else log_error "✗ Base extension linting failed" - ((test_failures++)) + test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi fi @@ -265,18 +268,18 @@ run_lint_tests() { log_debug "No lint script found in base extension" fi fi - + # Test VSCode extension linting local vscode_dir="$PROJECT_ROOT/$VSCODE_SUBMODULE_PATH" if [[ -d "$vscode_dir" && -f "$vscode_dir/package.json" ]]; then log_info "Running VSCode extension linting..." cd "$vscode_dir" - + local pkg_manager="npm" if command_exists "pnpm" && [[ -f "pnpm-lock.yaml" ]]; then pkg_manager="pnpm" fi - + if $pkg_manager run lint --if-present >/dev/null 2>&1; then if [[ "$DRY_RUN" == "true" ]]; then log_debug "Would run: $pkg_manager run lint in VSCode directory" @@ -285,7 +288,7 @@ run_lint_tests() { log_success "✓ VSCode extension linting passed" else log_error "✗ VSCode extension linting failed" - ((test_failures++)) + test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi fi @@ -293,7 +296,7 @@ run_lint_tests() { log_debug "No lint script found in VSCode extension" fi fi - + log_info "Linting tests completed with $test_failures failures" return $test_failures } @@ -303,22 +306,22 @@ run_unit_tests() { if [[ "$TEST_TYPE" != "$TEST_UNIT" && "$TEST_TYPE" != "$TEST_ALL" ]]; then return 0 fi - + log_step "Running unit tests..." - + local test_failures=0 - + # Run base extension unit tests local base_dir="$PROJECT_ROOT/$EXTENSION_HOST_DIR" if [[ -f "$base_dir/package.json" ]]; then log_info "Running base extension unit tests..." cd "$base_dir" - + local test_cmd="npm test" if [[ "$COVERAGE" == "true" ]]; then test_cmd="npm run test:coverage" fi - + if npm run test --if-present >/dev/null 2>&1; then if [[ "$DRY_RUN" == "true" ]]; then log_debug "Would run: $test_cmd in base directory" @@ -327,7 +330,7 @@ run_unit_tests() { log_success "✓ Base extension unit tests passed" else log_error "✗ Base extension unit tests failed" - ((test_failures++)) + test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi fi @@ -335,23 +338,23 @@ run_unit_tests() { log_debug "No test script found in base extension" fi fi - + # Run VSCode extension unit tests local vscode_dir="$PROJECT_ROOT/$VSCODE_SUBMODULE_PATH" if [[ -d "$vscode_dir" && -f "$vscode_dir/package.json" ]]; then log_info "Running VSCode extension unit tests..." cd "$vscode_dir" - + local pkg_manager="npm" if command_exists "pnpm" && [[ -f "pnpm-lock.yaml" ]]; then pkg_manager="pnpm" fi - + local test_cmd="$pkg_manager test" if [[ "$COVERAGE" == "true" ]]; then test_cmd="$pkg_manager run test:coverage" fi - + if $pkg_manager run test --if-present >/dev/null 2>&1; then if [[ "$DRY_RUN" == "true" ]]; then log_debug "Would run: $test_cmd in VSCode directory" @@ -360,7 +363,7 @@ run_unit_tests() { log_success "✓ VSCode extension unit tests passed" else log_error "✗ VSCode extension unit tests failed" - ((test_failures++)) + test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi fi @@ -368,7 +371,7 @@ run_unit_tests() { log_debug "No test script found in VSCode extension" fi fi - + log_info "Unit tests completed with $test_failures failures" return $test_failures } @@ -378,11 +381,11 @@ run_integration_tests() { if [[ "$TEST_TYPE" != "$TEST_INTEGRATION" && "$TEST_TYPE" != "$TEST_ALL" ]]; then return 0 fi - + log_step "Running integration tests..." - + local test_failures=0 - + # Test 1: Build integration test log_info "Testing build integration..." if [[ "$DRY_RUN" == "true" ]]; then @@ -391,22 +394,22 @@ run_integration_tests() { # Try a minimal build to test integration local temp_dir temp_dir=$(mktemp -d) - + if "$SCRIPT_DIR/build.sh" --dry-run >/dev/null 2>&1; then log_success "✓ Build integration test passed" else log_error "✗ Build integration test failed" - ((test_failures++)) + test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi - + rm -rf "$temp_dir" fi - + # Test 2: Script integration test log_info "Testing script integration..." local scripts=("setup.sh" "build.sh" "clean.sh") - + for script in "${scripts[@]}"; do if [[ -f "$SCRIPT_DIR/$script" ]]; then if [[ "$DRY_RUN" == "true" ]]; then @@ -416,17 +419,49 @@ run_integration_tests() { log_debug "✓ $script help test passed" else log_error "✗ $script help test failed" - ((test_failures++)) + test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi fi fi done - + + + # Test 3: Platform archive decoupled from Git LFS (issue #1) + log_info "Testing platform archive LFS decoupling..." + local lfs_decoupled=true + + if [[ -f "$PROJECT_ROOT/.gitattributes" ]] && grep -q "filter=lfs" "$PROJECT_ROOT/.gitattributes"; then + log_error ".gitattributes must not track files with Git LFS; the platform archive is generated by the build" + lfs_decoupled=false + fi + + if git -C "$PROJECT_ROOT" ls-files --error-unmatch jetbrains_plugin/platform.zip >/dev/null 2>&1; then + log_error "jetbrains_plugin/platform.zip must not be tracked by git" + lfs_decoupled=false + fi + + if ! grep -q "genPlatform" "$PROJECT_ROOT/$IDEA_DIR/build.gradle.kts" 2>/dev/null; then + log_error "Release builds must wire the genPlatform task for platform.zip generation" + lfs_decoupled=false + fi + + if grep -q "git-lfs" "$SCRIPT_DIR/setup.sh"; then + log_error "setup.sh must not require Git LFS" + lfs_decoupled=false + fi + + if [[ "$lfs_decoupled" == "true" ]]; then + log_success "✓ Platform archive LFS decoupling test passed" + else + log_error "✗ Platform archive LFS decoupling test failed" + test_failures=$((test_failures + 1)) + [[ "$FAIL_FAST" == "true" ]] && return $test_failures + fi if [[ $test_failures -eq 0 ]]; then log_success "✓ Script integration tests passed" fi - + log_info "Integration tests completed with $test_failures failures" return $test_failures } @@ -436,11 +471,11 @@ run_build_tests() { if [[ "$TEST_TYPE" != "$TEST_BUILD" && "$TEST_TYPE" != "$TEST_ALL" ]]; then return 0 fi - + log_step "Running build validation tests..." - + local test_failures=0 - + # Test 1: Validate build script syntax log_info "Testing build script syntax..." if [[ "$DRY_RUN" == "true" ]]; then @@ -450,18 +485,18 @@ run_build_tests() { log_success "✓ Build script syntax test passed" else log_error "✗ Build script syntax test failed" - ((test_failures++)) + test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi fi - + # Test 2: Validate required build files log_info "Testing required build files..." local required_files=( "$PROJECT_ROOT/$EXTENSION_HOST_DIR/package.json" "$PROJECT_ROOT/$IDEA_DIR/build.gradle" ) - + local files_ok=true for file in "${required_files[@]}"; do if [[ ! -f "$file" && ! -f "${file%.gradle}.kts" ]]; then @@ -469,15 +504,15 @@ run_build_tests() { files_ok=false fi done - + if [[ "$files_ok" == "true" ]]; then log_success "✓ Required build files test passed" else log_error "✗ Required build files test failed" - ((test_failures++)) + test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi - + log_info "Build validation tests completed with $test_failures failures" return $test_failures } @@ -485,12 +520,12 @@ run_build_tests() { # Generate test report generate_test_report() { local total_failures="$1" - + log_step "Generating test report..." - + local report_file="$PROJECT_ROOT/test-results/test-report.txt" ensure_dir "$(dirname "$report_file")" - + cat > "$report_file" << EOF Zoo Code JetBrains Test Report ===================== @@ -516,37 +551,37 @@ Test Results: $(if [[ $total_failures -eq 0 ]]; then echo "✓ All tests passed"; else echo "✗ $total_failures test(s) failed"; fi) EOF - + log_info "Test report generated: $report_file" } # Show test summary show_test_summary() { local total_failures="$1" - + log_step "Test Summary" - + echo "" if [[ $total_failures -eq 0 ]]; then log_success "All tests passed!" else log_error "$total_failures test(s) failed" fi - + log_info "Test type: $TEST_TYPE" log_info "Platform: $(get_platform)" - + if [[ "$DRY_RUN" == "true" ]]; then log_info "Mode: DRY RUN (no tests were actually executed)" fi - + echo "" log_info "Test report: $PROJECT_ROOT/test-results/test-report.txt" - + if [[ "$COVERAGE" == "true" ]]; then log_info "Coverage reports: $PROJECT_ROOT/coverage/" fi - + echo "" } @@ -556,45 +591,37 @@ main() { log_info "Script: $SCRIPT_NAME v$SCRIPT_VERSION" log_info "Platform: $(get_platform)" log_info "Project root: $PROJECT_ROOT" - + # Parse arguments parse_test_args "$@" - + log_info "Test configuration:" log_info " Type: $TEST_TYPE" log_info " Fail fast: $FAIL_FAST" log_info " Coverage: $COVERAGE" log_info " Watch mode: $WATCH_MODE" - + if [[ "$DRY_RUN" == "true" ]]; then log_warn "DRY RUN MODE - No tests will be executed" fi - + # Setup test environment setup_test_environment - + # Run tests local total_failures=0 - - run_env_tests - ((total_failures += $?)) - - run_lint_tests - ((total_failures += $?)) - - run_unit_tests - ((total_failures += $?)) - - run_integration_tests - ((total_failures += $?)) - - run_build_tests - ((total_failures += $?)) - + + # Conditional form: a nonzero group status must not abort under set -e + run_env_tests || total_failures=$((total_failures + $?)) + run_lint_tests || total_failures=$((total_failures + $?)) + run_unit_tests || total_failures=$((total_failures + $?)) + run_integration_tests || total_failures=$((total_failures + $?)) + run_build_tests || total_failures=$((total_failures + $?)) + # Generate report and show summary generate_test_report "$total_failures" show_test_summary "$total_failures" - + if [[ $total_failures -eq 0 ]]; then log_success "Test process completed successfully!" exit 0 @@ -605,4 +632,4 @@ main() { } # Run main function with all arguments -main "$@" \ No newline at end of file +main "$@" diff --git a/test-results/test-report.txt b/test-results/test-report.txt new file mode 100644 index 0000000..c91d5c7 --- /dev/null +++ b/test-results/test-report.txt @@ -0,0 +1,23 @@ +Zoo Code JetBrains Test Report +===================== + +Date: Tue Oct 27 01:52:03 AM UTC 2026 +Test Type: all +Platform: linux +Total Failures: 3 + +Test Configuration: +- Fail Fast: false +- Coverage: false +- Watch Mode: false +- Verbose: false +- Dry Run: false + +Environment: +- Node Version: Not found +- NPM Version: Not found +- Git Version: git version 2.43.0 + +Test Results: +✗ 3 test(s) failed + From b055c5ea72613cc15389cbd4fc2f5e541f85697f Mon Sep 17 00:00:00 2001 From: Elliott de Launay Date: Tue, 27 Oct 2026 03:44:31 +0000 Subject: [PATCH 2/2] fix(build): address platform archive review findings --- .github/workflows/pr.yml | 20 ++++ .github/workflows/release.yml | 19 ++++ .gitignore | 3 + jetbrains_plugin/build.gradle.kts | 32 +++--- jetbrains_plugin/genPlatform.gradle | 10 +- scripts/test.sh | 145 ++++++++++++++-------------- test-results/test-report.txt | 23 ----- 7 files changed, 136 insertions(+), 116 deletions(-) delete mode 100644 test-results/test-report.txt diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 66d5bdf..f658eb6 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -26,6 +26,9 @@ jobs: with: persist-credentials: false + - name: Check script integration contracts + run: ./scripts/test.sh integration --dry-run + # One source of truth: the build number and the pinned archive digest # live in jetbrains_plugin/gradle.properties, next to each other. - name: Read the centralized verification IDE values @@ -88,6 +91,23 @@ jobs: mkdir -p plugins/zoo-code/extension touch plugins/zoo-code/extension/.keep prodDep.txt + - name: Check missing and stale platform archive task graphs + working-directory: jetbrains_plugin + shell: bash + run: | + trap 'rm -f platform.zip' EXIT + for archive in missing stale; do + rm -f platform.zip + if [ "$archive" = stale ]; then + printf 'version https://git-lfs.github.com/spec/v1\n' > platform.zip + fi + ./gradlew clean prepareSandbox --dry-run -PdebugMode=release --no-configuration-cache > "$RUNNER_TEMP/platform-graph-$archive.log" + cat "$RUNNER_TEMP/platform-graph-$archive.log" + grep -Eq '^:genPlatform SKIPPED$' "$RUNNER_TEMP/platform-graph-$archive.log" + grep -Eq '^:preparePlatform SKIPPED$' "$RUNNER_TEMP/platform-graph-$archive.log" + awk '/^:clean /{c=NR} /^:preparePlatform /{p=NR} END{exit !(c && p && c> "$GITHUB_OUTPUT" + + # platform.zip is outside build/, so the release clean preserves it. + - name: Cache the generated VS Code platform archive + uses: actions/cache@v4 + with: + path: jetbrains_plugin/platform.zip + key: platform-${{ runner.os }}-${{ steps.platform-version.outputs.version }}-${{ hashFiles('jetbrains_plugin/genPlatform.gradle') }} + - name: Build the plugin from the released VS Code extension env: GITHUB_TOKEN: ${{ github.token }} diff --git a/.gitignore b/.gitignore index ffafd14..b441d87 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,6 @@ deps/vsix/plugin/* .zoo-build/ dist-with-roo/ plans/ + +# Generated test reports +test-results/ diff --git a/jetbrains_plugin/build.gradle.kts b/jetbrains_plugin/build.gradle.kts index 9bdf5e2..ceef30f 100644 --- a/jetbrains_plugin/build.gradle.kts +++ b/jetbrains_plugin/build.gradle.kts @@ -195,35 +195,27 @@ fun Sync.prepareSandbox() { // Resolved against the project directory: the daemon working directory // is not the project directory. val platformZip = project.file("platform.zip") - val platformUsable = platformZip.exists() && platformZip.length() >= 1024 * 1024 + fun usable() = platformZip.isFile && platformZip.length() >= 1024 * 1024 val platformDir = File("${project.buildDir}/platform") - if (platformUsable) { - // Extract platform.zip to the platform subdirectory under the project build directory + fun extractPlatform() { + check(usable()) { + "genPlatform did not produce a valid platform.zip at ${platformZip.absolutePath}. " + + "Check the genPlatform task output, network access to update.code.visualstudio.com, " + + "and vscodeVersion in gradle.properties." + } platformDir.mkdirs() logger.lifecycle("[prepareSandbox] Extracting platform.zip -> ${platformDir.absolutePath}") - copy { + project.copy { from(zipTree(platformZip)) into(platformDir) } - } else { + } + if (!usable()) { logger.lifecycle("[prepareSandbox] platform.zip is missing or invalid; genPlatform will generate it before the sandbox is prepared") dependsOn(project.tasks.named("genPlatform")) - // genPlatform runs before this task, so the archive can only be - // extracted at execution time. - doFirst { - val generatedZip = project.file("platform.zip") - check(generatedZip.exists() && generatedZip.length() >= 1024 * 1024) { - "genPlatform did not produce a valid platform.zip at ${generatedZip.absolutePath}. " + - "Check network access to update.code.visualstudio.com and the vscodeVersion value in gradle.properties." - } - platformDir.mkdirs() - logger.lifecycle("[prepareSandbox] Extracting platform.zip -> ${platformDir.absolutePath}") - project.copy { - from(zipTree(generatedZip)) - into(platformDir) - } - } } + // Always extract during execution: clean may remove build/platform. + doFirst { extractPlatform() } copyOps.add(platformZip.absolutePath to platformDir.absolutePath) copyAndTrack(File(project.buildDir, "platform/platform.txt"), "${sandboxDir}/") diff --git a/jetbrains_plugin/genPlatform.gradle b/jetbrains_plugin/genPlatform.gradle index 32a6342..2ce984d 100644 --- a/jetbrains_plugin/genPlatform.gradle +++ b/jetbrains_plugin/genPlatform.gradle @@ -6,8 +6,16 @@ import java.nio.file.* import java.security.MessageDigest +// Prepare sources in an action, before Zip checks for source files. +def preparePlatform = tasks.register('preparePlatform') { + mustRunAfter(tasks.named('clean')) + doLast { + download(project) + } +} + tasks.register('genPlatform', Zip) { - download(project) + dependsOn(preparePlatform) from(new File(project.buildDir, "genPlatform/gen")) into("") destinationDirectory = project.projectDir diff --git a/scripts/test.sh b/scripts/test.sh index 52f4dc8..deca307 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -121,7 +121,7 @@ parse_test_args() { ;; esac done - + # Validate test type case "$TEST_TYPE" in "$TEST_ALL"|"$TEST_UNIT"|"$TEST_INTEGRATION"|"$TEST_LINT"|"$TEST_BUILD"|"$TEST_ENV") @@ -137,24 +137,24 @@ parse_test_args() { # Setup test environment setup_test_environment() { log_step "Setting up test environment..." - + # Set CI environment variables if [[ "${CI:-false}" == "true" ]]; then log_info "Running in CI environment" export NODE_ENV="test" export CI="true" fi - + # Set test timeout export TEST_TIMEOUT="${TEST_TIMEOUT:-300}" - + # Set coverage threshold export COVERAGE_THRESHOLD="${COVERAGE_THRESHOLD:-80}" - + # Create test output directories ensure_dir "$PROJECT_ROOT/test-results" ensure_dir "$PROJECT_ROOT/coverage" - + log_success "Test environment set up" } @@ -163,11 +163,11 @@ run_env_tests() { if [[ "$TEST_TYPE" != "$TEST_ENV" && "$TEST_TYPE" != "$TEST_ALL" ]]; then return 0 fi - + log_step "Running environment validation tests..." - + local test_failures=0 - + # Test 1: Validate system requirements log_info "Testing system requirements..." # Subshell contains die, so a failed validation counts instead of aborting @@ -178,19 +178,19 @@ run_env_tests() { test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi - + # Test 2: Check project structure log_info "Testing project structure..." local required_dirs=("$EXTENSION_HOST_DIR" "$IDEA_DIR" "scripts") local structure_ok=true - + for dir in "${required_dirs[@]}"; do if [[ ! -d "$PROJECT_ROOT/$dir" ]]; then log_error "Required directory missing: $dir" structure_ok=false fi done - + if [[ "$structure_ok" == "true" ]]; then log_success "✓ Project structure test passed" else @@ -198,7 +198,7 @@ run_env_tests() { test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi - + # Test 3: Check Git configuration log_info "Testing Git configuration..." if git rev-parse --git-dir >/dev/null 2>&1; then @@ -208,7 +208,7 @@ run_env_tests() { test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi - + log_info "Environment tests completed with $test_failures failures" return $test_failures } @@ -218,17 +218,17 @@ run_lint_tests() { if [[ "$TEST_TYPE" != "$TEST_LINT" && "$TEST_TYPE" != "$TEST_ALL" ]]; then return 0 fi - + log_step "Running linting tests..." - + local test_failures=0 - + # Test shell scripts with shellcheck if available if command_exists "shellcheck"; then log_info "Running shellcheck on shell scripts..." local shell_files shell_files=$(find "$PROJECT_ROOT/scripts" -name "*.sh" -type f) - + if [[ -n "$shell_files" ]]; then if [[ "$DRY_RUN" == "true" ]]; then log_debug "Would run: shellcheck on shell scripts" @@ -245,13 +245,13 @@ run_lint_tests() { else log_warn "shellcheck not found, skipping shell script linting" fi - + # Test base extension linting local base_dir="$PROJECT_ROOT/$EXTENSION_HOST_DIR" if [[ -f "$base_dir/package.json" ]]; then log_info "Running base extension linting..." cd "$base_dir" - + if npm run lint --if-present >/dev/null 2>&1; then if [[ "$DRY_RUN" == "true" ]]; then log_debug "Would run: npm run lint in base directory" @@ -268,18 +268,18 @@ run_lint_tests() { log_debug "No lint script found in base extension" fi fi - + # Test VSCode extension linting local vscode_dir="$PROJECT_ROOT/$VSCODE_SUBMODULE_PATH" if [[ -d "$vscode_dir" && -f "$vscode_dir/package.json" ]]; then log_info "Running VSCode extension linting..." cd "$vscode_dir" - + local pkg_manager="npm" if command_exists "pnpm" && [[ -f "pnpm-lock.yaml" ]]; then pkg_manager="pnpm" fi - + if $pkg_manager run lint --if-present >/dev/null 2>&1; then if [[ "$DRY_RUN" == "true" ]]; then log_debug "Would run: $pkg_manager run lint in VSCode directory" @@ -296,7 +296,7 @@ run_lint_tests() { log_debug "No lint script found in VSCode extension" fi fi - + log_info "Linting tests completed with $test_failures failures" return $test_failures } @@ -306,22 +306,22 @@ run_unit_tests() { if [[ "$TEST_TYPE" != "$TEST_UNIT" && "$TEST_TYPE" != "$TEST_ALL" ]]; then return 0 fi - + log_step "Running unit tests..." - + local test_failures=0 - + # Run base extension unit tests local base_dir="$PROJECT_ROOT/$EXTENSION_HOST_DIR" if [[ -f "$base_dir/package.json" ]]; then log_info "Running base extension unit tests..." cd "$base_dir" - + local test_cmd="npm test" if [[ "$COVERAGE" == "true" ]]; then test_cmd="npm run test:coverage" fi - + if npm run test --if-present >/dev/null 2>&1; then if [[ "$DRY_RUN" == "true" ]]; then log_debug "Would run: $test_cmd in base directory" @@ -338,23 +338,23 @@ run_unit_tests() { log_debug "No test script found in base extension" fi fi - + # Run VSCode extension unit tests local vscode_dir="$PROJECT_ROOT/$VSCODE_SUBMODULE_PATH" if [[ -d "$vscode_dir" && -f "$vscode_dir/package.json" ]]; then log_info "Running VSCode extension unit tests..." cd "$vscode_dir" - + local pkg_manager="npm" if command_exists "pnpm" && [[ -f "pnpm-lock.yaml" ]]; then pkg_manager="pnpm" fi - + local test_cmd="$pkg_manager test" if [[ "$COVERAGE" == "true" ]]; then test_cmd="$pkg_manager run test:coverage" fi - + if $pkg_manager run test --if-present >/dev/null 2>&1; then if [[ "$DRY_RUN" == "true" ]]; then log_debug "Would run: $test_cmd in VSCode directory" @@ -371,7 +371,7 @@ run_unit_tests() { log_debug "No test script found in VSCode extension" fi fi - + log_info "Unit tests completed with $test_failures failures" return $test_failures } @@ -381,11 +381,11 @@ run_integration_tests() { if [[ "$TEST_TYPE" != "$TEST_INTEGRATION" && "$TEST_TYPE" != "$TEST_ALL" ]]; then return 0 fi - + log_step "Running integration tests..." - + local test_failures=0 - + # Test 1: Build integration test log_info "Testing build integration..." if [[ "$DRY_RUN" == "true" ]]; then @@ -394,7 +394,7 @@ run_integration_tests() { # Try a minimal build to test integration local temp_dir temp_dir=$(mktemp -d) - + if "$SCRIPT_DIR/build.sh" --dry-run >/dev/null 2>&1; then log_success "✓ Build integration test passed" else @@ -402,14 +402,14 @@ run_integration_tests() { test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi - + rm -rf "$temp_dir" fi - + # Test 2: Script integration test log_info "Testing script integration..." local scripts=("setup.sh" "build.sh" "clean.sh") - + for script in "${scripts[@]}"; do if [[ -f "$SCRIPT_DIR/$script" ]]; then if [[ "$DRY_RUN" == "true" ]]; then @@ -426,8 +426,7 @@ run_integration_tests() { fi done - - # Test 3: Platform archive decoupled from Git LFS (issue #1) + # Test 3: Platform archive decoupled from Git LFS log_info "Testing platform archive LFS decoupling..." local lfs_decoupled=true @@ -441,7 +440,7 @@ run_integration_tests() { lfs_decoupled=false fi - if ! grep -q "genPlatform" "$PROJECT_ROOT/$IDEA_DIR/build.gradle.kts" 2>/dev/null; then + if ! grep -Fq 'named("genPlatform")' "$PROJECT_ROOT/$IDEA_DIR/build.gradle.kts" 2>/dev/null; then log_error "Release builds must wire the genPlatform task for platform.zip generation" lfs_decoupled=false fi @@ -458,10 +457,11 @@ run_integration_tests() { test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi + if [[ $test_failures -eq 0 ]]; then log_success "✓ Script integration tests passed" fi - + log_info "Integration tests completed with $test_failures failures" return $test_failures } @@ -471,11 +471,11 @@ run_build_tests() { if [[ "$TEST_TYPE" != "$TEST_BUILD" && "$TEST_TYPE" != "$TEST_ALL" ]]; then return 0 fi - + log_step "Running build validation tests..." - + local test_failures=0 - + # Test 1: Validate build script syntax log_info "Testing build script syntax..." if [[ "$DRY_RUN" == "true" ]]; then @@ -489,14 +489,14 @@ run_build_tests() { [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi fi - + # Test 2: Validate required build files log_info "Testing required build files..." local required_files=( "$PROJECT_ROOT/$EXTENSION_HOST_DIR/package.json" "$PROJECT_ROOT/$IDEA_DIR/build.gradle" ) - + local files_ok=true for file in "${required_files[@]}"; do if [[ ! -f "$file" && ! -f "${file%.gradle}.kts" ]]; then @@ -504,7 +504,7 @@ run_build_tests() { files_ok=false fi done - + if [[ "$files_ok" == "true" ]]; then log_success "✓ Required build files test passed" else @@ -512,7 +512,7 @@ run_build_tests() { test_failures=$((test_failures + 1)) [[ "$FAIL_FAST" == "true" ]] && return $test_failures fi - + log_info "Build validation tests completed with $test_failures failures" return $test_failures } @@ -520,12 +520,13 @@ run_build_tests() { # Generate test report generate_test_report() { local total_failures="$1" - + log_step "Generating test report..." - + local report_file="$PROJECT_ROOT/test-results/test-report.txt" - ensure_dir "$(dirname "$report_file")" - + # Reports are written in dry-run mode too, so their directory must exist. + mkdir -p "$(dirname "$report_file")" + cat > "$report_file" << EOF Zoo Code JetBrains Test Report ===================== @@ -551,37 +552,37 @@ Test Results: $(if [[ $total_failures -eq 0 ]]; then echo "✓ All tests passed"; else echo "✗ $total_failures test(s) failed"; fi) EOF - + log_info "Test report generated: $report_file" } # Show test summary show_test_summary() { local total_failures="$1" - + log_step "Test Summary" - + echo "" if [[ $total_failures -eq 0 ]]; then log_success "All tests passed!" else log_error "$total_failures test(s) failed" fi - + log_info "Test type: $TEST_TYPE" log_info "Platform: $(get_platform)" - + if [[ "$DRY_RUN" == "true" ]]; then log_info "Mode: DRY RUN (no tests were actually executed)" fi - + echo "" log_info "Test report: $PROJECT_ROOT/test-results/test-report.txt" - + if [[ "$COVERAGE" == "true" ]]; then log_info "Coverage reports: $PROJECT_ROOT/coverage/" fi - + echo "" } @@ -591,37 +592,37 @@ main() { log_info "Script: $SCRIPT_NAME v$SCRIPT_VERSION" log_info "Platform: $(get_platform)" log_info "Project root: $PROJECT_ROOT" - + # Parse arguments parse_test_args "$@" - + log_info "Test configuration:" log_info " Type: $TEST_TYPE" log_info " Fail fast: $FAIL_FAST" log_info " Coverage: $COVERAGE" log_info " Watch mode: $WATCH_MODE" - + if [[ "$DRY_RUN" == "true" ]]; then log_warn "DRY RUN MODE - No tests will be executed" fi - + # Setup test environment setup_test_environment - + # Run tests local total_failures=0 - + # Conditional form: a nonzero group status must not abort under set -e run_env_tests || total_failures=$((total_failures + $?)) run_lint_tests || total_failures=$((total_failures + $?)) run_unit_tests || total_failures=$((total_failures + $?)) run_integration_tests || total_failures=$((total_failures + $?)) run_build_tests || total_failures=$((total_failures + $?)) - + # Generate report and show summary generate_test_report "$total_failures" show_test_summary "$total_failures" - + if [[ $total_failures -eq 0 ]]; then log_success "Test process completed successfully!" exit 0 diff --git a/test-results/test-report.txt b/test-results/test-report.txt deleted file mode 100644 index c91d5c7..0000000 --- a/test-results/test-report.txt +++ /dev/null @@ -1,23 +0,0 @@ -Zoo Code JetBrains Test Report -===================== - -Date: Tue Oct 27 01:52:03 AM UTC 2026 -Test Type: all -Platform: linux -Total Failures: 3 - -Test Configuration: -- Fail Fast: false -- Coverage: false -- Watch Mode: false -- Verbose: false -- Dry Run: false - -Environment: -- Node Version: Not found -- NPM Version: Not found -- Git Version: git version 2.43.0 - -Test Results: -✗ 3 test(s) failed -