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..f658eb6 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: @@ -25,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 @@ -87,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/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..ceef30f 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,37 @@ 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) { - // Extract platform.zip to the platform subdirectory under the project build directory - val platformDir = File("${project.buildDir}/platform") + // Resolved against the project directory: the daemon working directory + // is not the project directory. + val platformZip = project.file("platform.zip") + fun usable() = platformZip.isFile && platformZip.length() >= 1024 * 1024 + val platformDir = File("${project.buildDir}/platform") + 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) } - 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") } + 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")) + } + // 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}/") // Copy platform node_modules last to ensure it takes precedence over extension_host node_modules 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/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..deca307 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" @@ -168,11 +170,12 @@ run_env_tests() { # 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 @@ -192,7 +195,7 @@ run_env_tests() { 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 @@ -202,7 +205,7 @@ run_env_tests() { 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -396,7 +399,7 @@ run_integration_tests() { 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 @@ -416,13 +419,45 @@ 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 + 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 -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 + + 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 @@ -450,7 +485,7 @@ 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 @@ -474,7 +509,7 @@ run_build_tests() { 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 @@ -489,7 +524,8 @@ generate_test_report() { 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 @@ -576,20 +612,12 @@ main() { # 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" @@ -605,4 +633,4 @@ main() { } # Run main function with all arguments -main "$@" \ No newline at end of file +main "$@"