diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index e8c67fb..fd42a34 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -21,9 +21,11 @@ Guidance for Claude Code when working with the dtvem codebase. 2. **Write tests** - All new/refactored code requires comprehensive unit tests 3. **Cross-platform** - All features must work on Windows, macOS, and Linux 4. **Conventional commits** - Format: `type(scope): description` -5. **GitHub Issues for TODOs** - Use `gh` CLI to manage issues, no local TODO files -6. **Run validation before commits** - Run `npm run check` (format, lint, test) before committing and pushing - +5. **GitHub Issues for TODOs** - Use `gh` CLI to manage issues, no local TODO files. Use conventional commit format for issue titles +6. **Pull Requests** - Use the conventional commit format for PR titles as you do for commits +7. **Run validation before commits** - Run `npm run check` (format, lint, test) before committing and pushing +8. **Working an issue** - When working an issue, always create a new branch from an updated main branch +9. **Branch Names** - Always use the conventional commit `type` from the issue title as the first prefix, and the `scope` as the second, then a very short description, example `feat/ci/integration-tests` --- ## Quick Reference diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 86c0a1a..c365810 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,7 @@ on: - '.github/workflows/generate-changelog.yml' - '.github/workflows/preview-changelog.yml' - '.github/workflows/contributors.yml' + - '.github/workflows/integration-test*.yml' - '.idea/**' - '.claude/**' - '.gitignore' @@ -32,6 +33,7 @@ on: - '.github/workflows/generate-changelog.yml' - '.github/workflows/preview-changelog.yml' - '.github/workflows/contributors.yml' + - '.github/workflows/integration-test*.yml' - '.idea/**' - '.claude/**' - '.gitignore' diff --git a/.github/workflows/integration-test-migrate-node-macos-fnm.yml b/.github/workflows/integration-test-migrate-node-macos-fnm.yml new file mode 100644 index 0000000..b876bc2 --- /dev/null +++ b/.github/workflows/integration-test-migrate-node-macos-fnm.yml @@ -0,0 +1,75 @@ +name: Integration Tests - Migrate Node.js from fnm (macOS) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Node.js from fnm (macOS) + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim ./src/cmd/shim + + - name: Initialize dtvem + run: ./dist/dtvem init --yes + + - name: Add dtvem to PATH + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: "Install fnm" + run: | + curl -fsSL https://fnm.vercel.app/install | bash -s -- --skip-shell + echo "$HOME/.local/share/fnm" >> $GITHUB_PATH + + - name: "Install Node.js 20.18.0 via fnm" + run: | + export PATH="$HOME/.local/share/fnm:$PATH" + eval "$(fnm env --shell bash)" + fnm install 20.18.0 + fnm use 20.18.0 + echo "fnm Node.js installed at: $(which node)" + node --version + + - name: "Migrate fnm Node.js to dtvem" + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\nn\n" | ./dist/dtvem migrate node || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem list node + + - name: "Verify migrated version" + run: | + ./dist/dtvem list node | grep -E "20\.18\.0" || (echo "ERROR: Expected Node.js 20.18.0 to be migrated" && exit 1) + echo "SUCCESS: Node.js 20.18.0 was migrated from fnm" + + - name: Generate summary + if: always() + run: | + echo "## Node.js Migration from fnm (macOS)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** fnm" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 20.18.0" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem list node >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-node-macos-system.yml b/.github/workflows/integration-test-migrate-node-macos-system.yml new file mode 100644 index 0000000..a8a0976 --- /dev/null +++ b/.github/workflows/integration-test-migrate-node-macos-system.yml @@ -0,0 +1,68 @@ +name: Integration Tests - Migrate Node.js from System (macOS) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Node.js from System (macOS) + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim ./src/cmd/shim + + - name: Initialize dtvem + run: ./dist/dtvem init --yes + + - name: Add dtvem to PATH + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: "Install Node.js 18.x via Homebrew" + run: | + brew install node@18 + brew link --overwrite node@18 + echo "System Node.js installed at: $(which node)" + node --version + + - name: "Migrate system Node.js to dtvem" + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\n" | ./dist/dtvem migrate node || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem list node + + - name: "Verify migrated version" + run: | + ./dist/dtvem list node | grep -E "18\." || (echo "ERROR: Expected Node.js 18.x to be migrated" && exit 1) + echo "SUCCESS: Node.js 18.x was migrated from system" + + - name: Generate summary + if: always() + run: | + echo "## Node.js Migration from System (macOS)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** Homebrew" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 18.x" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem list node >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-node-ubuntu-nvm.yml b/.github/workflows/integration-test-migrate-node-ubuntu-nvm.yml new file mode 100644 index 0000000..c389daa --- /dev/null +++ b/.github/workflows/integration-test-migrate-node-ubuntu-nvm.yml @@ -0,0 +1,71 @@ +name: Integration Tests - Migrate Node.js from nvm (Ubuntu) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Node.js from nvm (Ubuntu) + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim ./src/cmd/shim + + - name: Initialize dtvem + run: ./dist/dtvem init --yes + + - name: Add dtvem to PATH + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: "Install Node.js 20.18.0 via nvm" + run: | + # nvm is preinstalled on Ubuntu runners + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + nvm install 20.18.0 + nvm use 20.18.0 + echo "nvm Node.js installed at: $(which node)" + node --version + + - name: "Migrate nvm Node.js to dtvem" + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\nn\n" | ./dist/dtvem migrate node || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem list node + + - name: "Verify migrated version" + run: | + ./dist/dtvem list node | grep -E "20\.18\.0" || (echo "ERROR: Expected Node.js 20.18.0 to be migrated" && exit 1) + echo "SUCCESS: Node.js 20.18.0 was migrated from nvm" + + - name: Generate summary + if: always() + run: | + echo "## Node.js Migration from nvm (Ubuntu)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** nvm" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 20.18.0" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem list node >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-node-ubuntu-system.yml b/.github/workflows/integration-test-migrate-node-ubuntu-system.yml new file mode 100644 index 0000000..5b40835 --- /dev/null +++ b/.github/workflows/integration-test-migrate-node-ubuntu-system.yml @@ -0,0 +1,69 @@ +name: Integration Tests - Migrate Node.js from System (Ubuntu) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Node.js from System (Ubuntu) + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim ./src/cmd/shim + + - name: Initialize dtvem + run: ./dist/dtvem init --yes + + - name: Add dtvem to PATH + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: "Install Node.js 18.x via apt (NodeSource)" + run: | + curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - + sudo apt-get install -y nodejs + echo "System Node.js installed at: $(which node)" + node --version + + - name: "Migrate system Node.js to dtvem" + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\n" | ./dist/dtvem migrate node || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem list node + + - name: "Verify migrated version" + run: | + # Check that we have a version starting with 18 + ./dist/dtvem list node | grep -E "18\." || (echo "ERROR: Expected Node.js 18.x to be migrated" && exit 1) + echo "SUCCESS: Node.js 18.x was migrated from system" + + - name: Generate summary + if: always() + run: | + echo "## Node.js Migration from System (Ubuntu)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** apt (NodeSource)" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 18.x" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem list node >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-node-windows-nvm.yml b/.github/workflows/integration-test-migrate-node-windows-nvm.yml new file mode 100644 index 0000000..b865dd4 --- /dev/null +++ b/.github/workflows/integration-test-migrate-node-windows-nvm.yml @@ -0,0 +1,82 @@ +name: Integration Tests - Migrate Node.js from nvm-windows (Windows) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Node.js from nvm-windows (Windows) + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + shell: bash + run: | + go build -v -ldflags="-s -w" -o dist/dtvem.exe ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim.exe ./src/cmd/shim + + - name: Initialize dtvem + shell: bash + run: ./dist/dtvem.exe init --yes + + - name: Add dtvem to PATH + shell: pwsh + run: | + "$env:USERPROFILE\.dtvem\shims" | Out-File -FilePath $env:GITHUB_PATH -Append + "$env:USERPROFILE\.dtvem\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + + - name: "Install nvm-windows" + shell: pwsh + run: | + choco install nvm -y + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + + - name: "Install Node.js 20.18.0 via nvm-windows" + shell: pwsh + run: | + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + nvm install 20.18.0 + nvm use 20.18.0 + Write-Host "nvm-windows Node.js version:" + node --version + + - name: "Migrate nvm-windows Node.js to dtvem" + shell: bash + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\nn\n" | ./dist/dtvem.exe migrate node || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem.exe list node + + - name: "Verify migrated version" + shell: bash + run: | + ./dist/dtvem.exe list node | grep -E "20\.18\.0" || (echo "ERROR: Expected Node.js 20.18.0 to be migrated" && exit 1) + echo "SUCCESS: Node.js 20.18.0 was migrated from nvm-windows" + + - name: Generate summary + if: always() + shell: bash + run: | + echo "## Node.js Migration from nvm-windows (Windows)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** nvm-windows" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 20.18.0" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem.exe list node >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-node-windows-system.yml b/.github/workflows/integration-test-migrate-node-windows-system.yml new file mode 100644 index 0000000..28f9978 --- /dev/null +++ b/.github/workflows/integration-test-migrate-node-windows-system.yml @@ -0,0 +1,83 @@ +name: Integration Tests - Migrate Node.js from System (Windows) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Node.js from System (Windows) + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + shell: bash + run: | + go build -v -ldflags="-s -w" -o dist/dtvem.exe ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim.exe ./src/cmd/shim + + - name: Initialize dtvem + shell: bash + run: ./dist/dtvem.exe init --yes + + - name: Add dtvem to PATH + shell: pwsh + run: | + "$env:USERPROFILE\.dtvem\shims" | Out-File -FilePath $env:GITHUB_PATH -Append + "$env:USERPROFILE\.dtvem\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + + - name: "Install Node.js 18.x via Chocolatey" + shell: pwsh + run: | + choco install nodejs-lts --version=18.20.4 -y + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + Write-Host "System Node.js installed at: $(where.exe node)" + node --version + + - name: "Add Chocolatey Node.js to PATH" + shell: pwsh + run: | + $nodePath = "C:\Program Files\nodejs" + if (Test-Path $nodePath) { + $nodePath | Out-File -FilePath $env:GITHUB_PATH -Append + } + + - name: "Migrate system Node.js to dtvem" + shell: bash + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\n" | ./dist/dtvem.exe migrate node || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem.exe list node + + - name: "Verify migrated version" + shell: bash + run: | + ./dist/dtvem.exe list node | grep -E "18\." || (echo "ERROR: Expected Node.js 18.x to be migrated" && exit 1) + echo "SUCCESS: Node.js 18.x was migrated from system" + + - name: Generate summary + if: always() + shell: bash + run: | + echo "## Node.js Migration from System (Windows)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** Chocolatey" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 18.x" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem.exe list node >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-python-macos-pyenv.yml b/.github/workflows/integration-test-migrate-python-macos-pyenv.yml new file mode 100644 index 0000000..4520e21 --- /dev/null +++ b/.github/workflows/integration-test-migrate-python-macos-pyenv.yml @@ -0,0 +1,73 @@ +name: Integration Tests - Migrate Python from pyenv (macOS) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Python from pyenv (macOS) + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim ./src/cmd/shim + + - name: Initialize dtvem + run: ./dist/dtvem init --yes + + - name: Add dtvem to PATH + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: "Install pyenv via Homebrew" + run: | + brew install pyenv + + - name: "Install Python 3.11.9 via pyenv" + run: | + eval "$(pyenv init -)" + pyenv install 3.11.9 + pyenv global 3.11.9 + echo "pyenv Python installed at: $(pyenv which python)" + python --version + + - name: "Migrate pyenv Python to dtvem" + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\nn\n" | ./dist/dtvem migrate python || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem list python + + - name: "Verify migrated version" + run: | + ./dist/dtvem list python | grep -E "3\.11\.9" || (echo "ERROR: Expected Python 3.11.9 to be migrated" && exit 1) + echo "SUCCESS: Python 3.11.9 was migrated from pyenv" + + - name: Generate summary + if: always() + run: | + echo "## Python Migration from pyenv (macOS)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** pyenv" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 3.11.9" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem list python >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-python-macos-system.yml b/.github/workflows/integration-test-migrate-python-macos-system.yml new file mode 100644 index 0000000..01f4796 --- /dev/null +++ b/.github/workflows/integration-test-migrate-python-macos-system.yml @@ -0,0 +1,68 @@ +name: Integration Tests - Migrate Python from System (macOS) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Python from System (macOS) + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim ./src/cmd/shim + + - name: Initialize dtvem + run: ./dist/dtvem init --yes + + - name: Add dtvem to PATH + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: "Install Python 3.10 via Homebrew" + run: | + brew install python@3.10 + brew link --overwrite python@3.10 + echo "System Python installed at: $(which python3.10)" + python3.10 --version + + - name: "Migrate system Python to dtvem" + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\n" | ./dist/dtvem migrate python || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem list python + + - name: "Verify migrated version" + run: | + ./dist/dtvem list python | grep -E "3\.10\." || (echo "ERROR: Expected Python 3.10.x to be migrated" && exit 1) + echo "SUCCESS: Python 3.10.x was migrated from system" + + - name: Generate summary + if: always() + run: | + echo "## Python Migration from System (macOS)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** Homebrew" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 3.10.x" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem list python >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-python-ubuntu-pyenv.yml b/.github/workflows/integration-test-migrate-python-ubuntu-pyenv.yml new file mode 100644 index 0000000..168985b --- /dev/null +++ b/.github/workflows/integration-test-migrate-python-ubuntu-pyenv.yml @@ -0,0 +1,82 @@ +name: Integration Tests - Migrate Python from pyenv (Ubuntu) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Python from pyenv (Ubuntu) + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim ./src/cmd/shim + + - name: Initialize dtvem + run: ./dist/dtvem init --yes + + - name: Add dtvem to PATH + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: "Install pyenv and dependencies" + run: | + sudo apt-get update + sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \ + libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \ + libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev + curl https://pyenv.run | bash + echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc + echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc + echo 'eval "$(pyenv init -)"' >> ~/.bashrc + + - name: "Install Python 3.11.9 via pyenv" + run: | + export PYENV_ROOT="$HOME/.pyenv" + export PATH="$PYENV_ROOT/bin:$PATH" + eval "$(pyenv init -)" + pyenv install 3.11.9 + pyenv global 3.11.9 + echo "pyenv Python installed at: $(pyenv which python)" + python --version + + - name: "Migrate pyenv Python to dtvem" + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\nn\n" | ./dist/dtvem migrate python || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem list python + + - name: "Verify migrated version" + run: | + ./dist/dtvem list python | grep -E "3\.11\.9" || (echo "ERROR: Expected Python 3.11.9 to be migrated" && exit 1) + echo "SUCCESS: Python 3.11.9 was migrated from pyenv" + + - name: Generate summary + if: always() + run: | + echo "## Python Migration from pyenv (Ubuntu)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** pyenv" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 3.11.9" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem list python >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-python-ubuntu-system.yml b/.github/workflows/integration-test-migrate-python-ubuntu-system.yml new file mode 100644 index 0000000..d0a4c7e --- /dev/null +++ b/.github/workflows/integration-test-migrate-python-ubuntu-system.yml @@ -0,0 +1,69 @@ +name: Integration Tests - Migrate Python from System (Ubuntu) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Python from System (Ubuntu) + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim ./src/cmd/shim + + - name: Initialize dtvem + run: ./dist/dtvem init --yes + + - name: Add dtvem to PATH + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: "Install Python 3.10 via apt (deadsnakes PPA)" + run: | + sudo add-apt-repository ppa:deadsnakes/ppa -y + sudo apt-get update + sudo apt-get install -y python3.10 python3.10-venv python3.10-dev + echo "System Python installed at: $(which python3.10)" + python3.10 --version + + - name: "Migrate system Python to dtvem" + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\n" | ./dist/dtvem migrate python || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem list python + + - name: "Verify migrated version" + run: | + ./dist/dtvem list python | grep -E "3\.10\." || (echo "ERROR: Expected Python 3.10.x to be migrated" && exit 1) + echo "SUCCESS: Python 3.10.x was migrated from system" + + - name: Generate summary + if: always() + run: | + echo "## Python Migration from System (Ubuntu)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** apt (deadsnakes PPA)" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 3.10.x" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem list python >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-python-windows-pyenv.yml b/.github/workflows/integration-test-migrate-python-windows-pyenv.yml new file mode 100644 index 0000000..15fc111 --- /dev/null +++ b/.github/workflows/integration-test-migrate-python-windows-pyenv.yml @@ -0,0 +1,87 @@ +name: Integration Tests - Migrate Python from pyenv-win (Windows) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Python from pyenv-win (Windows) + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + shell: bash + run: | + go build -v -ldflags="-s -w" -o dist/dtvem.exe ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim.exe ./src/cmd/shim + + - name: Initialize dtvem + shell: bash + run: ./dist/dtvem.exe init --yes + + - name: Add dtvem to PATH + shell: pwsh + run: | + "$env:USERPROFILE\.dtvem\shims" | Out-File -FilePath $env:GITHUB_PATH -Append + "$env:USERPROFILE\.dtvem\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + + - name: "Install pyenv-win" + shell: pwsh + run: | + pip install pyenv-win --target "$env:USERPROFILE\.pyenv" + [System.Environment]::SetEnvironmentVariable('PYENV', "$env:USERPROFILE\.pyenv\pyenv-win\", "User") + [System.Environment]::SetEnvironmentVariable('PYENV_ROOT', "$env:USERPROFILE\.pyenv\pyenv-win\", "User") + [System.Environment]::SetEnvironmentVariable('PYENV_HOME', "$env:USERPROFILE\.pyenv\pyenv-win\", "User") + "$env:USERPROFILE\.pyenv\pyenv-win\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + "$env:USERPROFILE\.pyenv\pyenv-win\shims" | Out-File -FilePath $env:GITHUB_PATH -Append + + - name: "Install Python 3.11.9 via pyenv-win" + shell: pwsh + run: | + $env:Path = "$env:USERPROFILE\.pyenv\pyenv-win\bin;$env:USERPROFILE\.pyenv\pyenv-win\shims;$env:Path" + pyenv install 3.11.9 + pyenv global 3.11.9 + pyenv rehash + Write-Host "pyenv-win Python version:" + python --version + + - name: "Migrate pyenv-win Python to dtvem" + shell: bash + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\nn\n" | ./dist/dtvem.exe migrate python || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem.exe list python + + - name: "Verify migrated version" + shell: bash + run: | + ./dist/dtvem.exe list python | grep -E "3\.11\.9" || (echo "ERROR: Expected Python 3.11.9 to be migrated" && exit 1) + echo "SUCCESS: Python 3.11.9 was migrated from pyenv-win" + + - name: Generate summary + if: always() + shell: bash + run: | + echo "## Python Migration from pyenv-win (Windows)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** pyenv-win" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 3.11.9" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem.exe list python >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-python-windows-system.yml b/.github/workflows/integration-test-migrate-python-windows-system.yml new file mode 100644 index 0000000..c1a3985 --- /dev/null +++ b/.github/workflows/integration-test-migrate-python-windows-system.yml @@ -0,0 +1,84 @@ +name: Integration Tests - Migrate Python from System (Windows) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Python from System (Windows) + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + shell: bash + run: | + go build -v -ldflags="-s -w" -o dist/dtvem.exe ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim.exe ./src/cmd/shim + + - name: Initialize dtvem + shell: bash + run: ./dist/dtvem.exe init --yes + + - name: Add dtvem to PATH + shell: pwsh + run: | + "$env:USERPROFILE\.dtvem\shims" | Out-File -FilePath $env:GITHUB_PATH -Append + "$env:USERPROFILE\.dtvem\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + + - name: "Install Python 3.10 via Chocolatey" + shell: pwsh + run: | + choco install python310 -y + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + Write-Host "System Python installed" + python --version + + - name: "Add Chocolatey Python to PATH" + shell: pwsh + run: | + $pythonPath = "C:\Python310" + if (Test-Path $pythonPath) { + $pythonPath | Out-File -FilePath $env:GITHUB_PATH -Append + "$pythonPath\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Append + } + + - name: "Migrate system Python to dtvem" + shell: bash + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\n" | ./dist/dtvem.exe migrate python || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem.exe list python + + - name: "Verify migrated version" + shell: bash + run: | + ./dist/dtvem.exe list python | grep -E "3\.10\." || (echo "ERROR: Expected Python 3.10.x to be migrated" && exit 1) + echo "SUCCESS: Python 3.10.x was migrated from system" + + - name: Generate summary + if: always() + shell: bash + run: | + echo "## Python Migration from System (Windows)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** Chocolatey" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 3.10.x" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem.exe list python >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-ruby-macos-rbenv.yml b/.github/workflows/integration-test-migrate-ruby-macos-rbenv.yml new file mode 100644 index 0000000..cdaaea4 --- /dev/null +++ b/.github/workflows/integration-test-migrate-ruby-macos-rbenv.yml @@ -0,0 +1,73 @@ +name: Integration Tests - Migrate Ruby from rbenv (macOS) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Ruby from rbenv (macOS) + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim ./src/cmd/shim + + - name: Initialize dtvem + run: ./dist/dtvem init --yes + + - name: Add dtvem to PATH + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: "Install rbenv via Homebrew" + run: | + brew install rbenv ruby-build + + - name: "Install Ruby 3.3.6 via rbenv" + run: | + eval "$(rbenv init -)" + rbenv install 3.3.6 + rbenv global 3.3.6 + echo "rbenv Ruby installed at: $(rbenv which ruby)" + ruby --version + + - name: "Migrate rbenv Ruby to dtvem" + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\nn\n" | ./dist/dtvem migrate ruby || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem list ruby + + - name: "Verify migrated version" + run: | + ./dist/dtvem list ruby | grep -E "3\.3\.6" || (echo "ERROR: Expected Ruby 3.3.6 to be migrated" && exit 1) + echo "SUCCESS: Ruby 3.3.6 was migrated from rbenv" + + - name: Generate summary + if: always() + run: | + echo "## Ruby Migration from rbenv (macOS)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** rbenv" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 3.3.6" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem list ruby >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-ruby-macos-system.yml b/.github/workflows/integration-test-migrate-ruby-macos-system.yml new file mode 100644 index 0000000..c77ba1c --- /dev/null +++ b/.github/workflows/integration-test-migrate-ruby-macos-system.yml @@ -0,0 +1,74 @@ +name: Integration Tests - Migrate Ruby from System (macOS) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Ruby from System (macOS) + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim ./src/cmd/shim + + - name: Initialize dtvem + run: ./dist/dtvem init --yes + + - name: Add dtvem to PATH + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: "Install Ruby 3.2 via Homebrew" + run: | + brew install ruby@3.2 + brew link --overwrite ruby@3.2 + # Add to PATH for this step + export PATH="$(brew --prefix ruby@3.2)/bin:$PATH" + echo "System Ruby installed at: $(which ruby)" + ruby --version + + - name: "Add Homebrew Ruby to PATH" + run: | + echo "$(brew --prefix ruby@3.2)/bin" >> $GITHUB_PATH + + - name: "Migrate system Ruby to dtvem" + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\n" | ./dist/dtvem migrate ruby || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem list ruby + + - name: "Verify migrated version" + run: | + ./dist/dtvem list ruby | grep -E "3\.2\." || (echo "ERROR: Expected Ruby 3.2.x to be migrated" && exit 1) + echo "SUCCESS: Ruby 3.2.x was migrated from system" + + - name: Generate summary + if: always() + run: | + echo "## Ruby Migration from System (macOS)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** Homebrew" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 3.2.x" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem list ruby >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-ruby-ubuntu-rbenv.yml b/.github/workflows/integration-test-migrate-ruby-ubuntu-rbenv.yml new file mode 100644 index 0000000..a5f523f --- /dev/null +++ b/.github/workflows/integration-test-migrate-ruby-ubuntu-rbenv.yml @@ -0,0 +1,81 @@ +name: Integration Tests - Migrate Ruby from rbenv (Ubuntu) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Ruby from rbenv (Ubuntu) + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim ./src/cmd/shim + + - name: Initialize dtvem + run: ./dist/dtvem init --yes + + - name: Add dtvem to PATH + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: "Install rbenv and ruby-build" + run: | + git clone https://github.com/rbenv/rbenv.git ~/.rbenv + echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc + echo 'eval "$(rbenv init -)"' >> ~/.bashrc + git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build + # Install Ruby build dependencies + sudo apt-get update + sudo apt-get install -y autoconf patch build-essential rustc libssl-dev libyaml-dev \ + libreadline6-dev zlib1g-dev libgmp-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev uuid-dev + + - name: "Install Ruby 3.3.6 via rbenv" + run: | + export PATH="$HOME/.rbenv/bin:$PATH" + eval "$(rbenv init -)" + rbenv install 3.3.6 + rbenv global 3.3.6 + echo "rbenv Ruby installed at: $(rbenv which ruby)" + ruby --version + + - name: "Migrate rbenv Ruby to dtvem" + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\nn\n" | ./dist/dtvem migrate ruby || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem list ruby + + - name: "Verify migrated version" + run: | + ./dist/dtvem list ruby | grep -E "3\.3\.6" || (echo "ERROR: Expected Ruby 3.3.6 to be migrated" && exit 1) + echo "SUCCESS: Ruby 3.3.6 was migrated from rbenv" + + - name: Generate summary + if: always() + run: | + echo "## Ruby Migration from rbenv (Ubuntu)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** rbenv" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 3.3.6" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem list ruby >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-ruby-ubuntu-system.yml b/.github/workflows/integration-test-migrate-ruby-ubuntu-system.yml new file mode 100644 index 0000000..3d398bf --- /dev/null +++ b/.github/workflows/integration-test-migrate-ruby-ubuntu-system.yml @@ -0,0 +1,69 @@ +name: Integration Tests - Migrate Ruby from System (Ubuntu) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Ruby from System (Ubuntu) + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim ./src/cmd/shim + + - name: Initialize dtvem + run: ./dist/dtvem init --yes + + - name: Add dtvem to PATH + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: "Install Ruby 3.2 via apt" + run: | + # Install Ruby via apt (system-level install) + sudo apt-get update + sudo apt-get install -y ruby-full + echo "System Ruby installed at: $(which ruby)" + ruby --version + + - name: "Migrate system Ruby to dtvem" + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\n" | ./dist/dtvem migrate ruby || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem list ruby + + - name: "Verify migrated version" + run: | + ./dist/dtvem list ruby | grep -E "3\." || (echo "ERROR: Expected Ruby 3.x to be migrated" && exit 1) + echo "SUCCESS: Ruby 3.x was migrated from system" + + - name: Generate summary + if: always() + run: | + echo "## Ruby Migration from System (Ubuntu)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** apt" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 3.x (system default)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem list ruby >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-migrate-ruby-windows-system.yml b/.github/workflows/integration-test-migrate-ruby-windows-system.yml new file mode 100644 index 0000000..5b453e4 --- /dev/null +++ b/.github/workflows/integration-test-migrate-ruby-windows-system.yml @@ -0,0 +1,87 @@ +name: Integration Tests - Migrate Ruby from System (Windows) + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +jobs: + migrate: + name: Ruby from System (Windows) + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + shell: bash + run: | + go build -v -ldflags="-s -w" -o dist/dtvem.exe ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim.exe ./src/cmd/shim + + - name: Initialize dtvem + shell: bash + run: ./dist/dtvem.exe init --yes + + - name: Add dtvem to PATH + shell: pwsh + run: | + "$env:USERPROFILE\.dtvem\shims" | Out-File -FilePath $env:GITHUB_PATH -Append + "$env:USERPROFILE\.dtvem\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + + - name: "Install Ruby 3.2 via Chocolatey" + shell: pwsh + run: | + # Install Ruby via Chocolatey (system-level install) + choco install ruby --version=3.2.6.1 -y + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + Write-Host "System Ruby installed" + ruby --version + + - name: "Add Chocolatey Ruby to PATH" + shell: pwsh + run: | + # Ruby is typically installed to C:\tools\ruby32\bin + $rubyPath = "C:\tools\ruby32\bin" + if (Test-Path $rubyPath) { + $rubyPath | Out-File -FilePath $env:GITHUB_PATH -Append + } + + - name: "Migrate system Ruby to dtvem" + shell: bash + run: | + echo "=== Running migrate detection ===" + echo -e "1\n0\n" | ./dist/dtvem.exe migrate ruby || true + echo "" + echo "=== Verifying migration ===" + ./dist/dtvem.exe list ruby + + - name: "Verify migrated version" + shell: bash + run: | + ./dist/dtvem.exe list ruby | grep -E "3\.2\." || (echo "ERROR: Expected Ruby 3.2.x to be migrated" && exit 1) + echo "SUCCESS: Ruby 3.2.x was migrated from system" + + - name: Generate summary + if: always() + shell: bash + run: | + echo "## Ruby Migration from System (Windows)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Source:** Chocolatey" >> $GITHUB_STEP_SUMMARY + echo "**Version:** 3.2.x" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "*Note: No rbenv equivalent on Windows. See issue #122 for RubyInstaller/uru support.*" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem.exe list ruby >> $GITHUB_STEP_SUMMARY 2>&1 || echo "No versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-test-node.yml b/.github/workflows/integration-test-node.yml new file mode 100644 index 0000000..9d3f460 --- /dev/null +++ b/.github/workflows/integration-test-node.yml @@ -0,0 +1,244 @@ +name: Integration Tests - Node.js + +on: + workflow_call: + inputs: + version1: + description: 'First Node.js version to test (LTS)' + required: false + type: string + default: '20.18.0' + version2: + description: 'Second Node.js version to test (Current)' + required: false + type: string + default: '22.11.0' + workflow_dispatch: + inputs: + version1: + description: 'First Node.js version to test (LTS)' + required: false + type: string + default: '20.18.0' + version2: + description: 'Second Node.js version to test (Current)' + required: false + type: string + default: '22.11.0' + +permissions: + contents: read + +jobs: + integration-test-node: + name: Node.js (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + platform: linux + ext: "" + - os: macos-latest + platform: macos + ext: "" + - os: windows-latest + platform: windows + ext: ".exe" + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem${{ matrix.ext }} ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim${{ matrix.ext }} ./src/cmd/shim + shell: bash + + - name: Initialize dtvem + run: | + ./dist/dtvem${{ matrix.ext }} init --yes + shell: bash + + - name: Add shims to PATH (Unix) + if: matrix.platform != 'windows' + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: Add shims to PATH (Windows) + if: matrix.platform == 'windows' + shell: pwsh + run: | + "$env:USERPROFILE\.dtvem\shims" | Out-File -FilePath $env:GITHUB_PATH -Append + "$env:USERPROFILE\.dtvem\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + + - name: "List available versions" + run: | + echo "## Node.js Available Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} list-all node | head -20 >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Install version ${{ inputs.version1 || '20.18.0' }}" + run: | + ./dist/dtvem${{ matrix.ext }} install node ${{ inputs.version1 || '20.18.0' }} + shell: bash + + - name: "Install version ${{ inputs.version2 || '22.11.0' }}" + run: | + ./dist/dtvem${{ matrix.ext }} install node ${{ inputs.version2 || '22.11.0' }} + shell: bash + + - name: "List installed versions" + run: | + echo "## Node.js Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} list node >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Set global version to ${{ inputs.version1 || '20.18.0' }}" + run: | + ./dist/dtvem${{ matrix.ext }} global node ${{ inputs.version1 || '20.18.0' }} + shell: bash + + - name: "Verify global version via current" + run: | + CURRENT=$(./dist/dtvem${{ matrix.ext }} current node) + echo "Current node version: $CURRENT" + if [[ "$CURRENT" != *"${{ inputs.version1 || '20.18.0' }}"* ]]; then + echo "ERROR: Expected ${{ inputs.version1 || '20.18.0' }} but got $CURRENT" + exit 1 + fi + shell: bash + + - name: "Verify shim works (node --version)" + run: | + NODE_VERSION=$(node --version) + echo "Node version from shim: $NODE_VERSION" + if [[ "$NODE_VERSION" != *"${{ inputs.version1 || '20.18.0' }}"* ]]; then + echo "ERROR: Expected v${{ inputs.version1 || '20.18.0' }} but got $NODE_VERSION" + exit 1 + fi + shell: bash + + - name: "Switch global version to ${{ inputs.version2 || '22.11.0' }}" + run: | + ./dist/dtvem${{ matrix.ext }} global node ${{ inputs.version2 || '22.11.0' }} + shell: bash + + - name: "Verify version switched" + run: | + NODE_VERSION=$(node --version) + echo "Node version from shim: $NODE_VERSION" + if [[ "$NODE_VERSION" != *"${{ inputs.version2 || '22.11.0' }}"* ]]; then + echo "ERROR: Expected v${{ inputs.version2 || '22.11.0' }} but got $NODE_VERSION" + exit 1 + fi + shell: bash + + - name: "Test local version override" + run: | + mkdir -p test-project + cd test-project + ../dist/dtvem${{ matrix.ext }} local node ${{ inputs.version1 || '20.18.0' }} + CURRENT=$(../dist/dtvem${{ matrix.ext }} current node) + echo "Current node version in test-project: $CURRENT" + if [[ "$CURRENT" != *"${{ inputs.version1 || '20.18.0' }}"* ]]; then + echo "ERROR: Local override failed. Expected ${{ inputs.version1 || '20.18.0' }} but got $CURRENT" + exit 1 + fi + NODE_VERSION=$(node --version) + echo "Node version from shim in test-project: $NODE_VERSION" + if [[ "$NODE_VERSION" != *"${{ inputs.version1 || '20.18.0' }}"* ]]; then + echo "ERROR: Expected v${{ inputs.version1 || '20.18.0' }} but got $NODE_VERSION" + exit 1 + fi + shell: bash + + - name: "Test which command" + run: | + echo "## Node.js Which" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} which node >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Test where command" + run: | + echo "## Node.js Where" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} where node >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Test reshim command" + run: | + ./dist/dtvem${{ matrix.ext }} reshim + echo "Reshim completed successfully" + shell: bash + + - name: "Test freeze command" + run: | + echo "## Freeze Output" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} freeze >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Uninstall version ${{ inputs.version2 || '22.11.0' }}" + run: | + ./dist/dtvem${{ matrix.ext }} uninstall node ${{ inputs.version2 || '22.11.0' }} --yes + shell: bash + + - name: "Verify uninstall" + run: | + LIST_OUTPUT=$(./dist/dtvem${{ matrix.ext }} list node) + echo "Installed versions after uninstall:" + echo "$LIST_OUTPUT" + if [[ "$LIST_OUTPUT" == *"${{ inputs.version2 || '22.11.0' }}"* ]]; then + echo "ERROR: Version ${{ inputs.version2 || '22.11.0' }} should have been uninstalled" + exit 1 + fi + shell: bash + + - name: Generate summary + if: always() + run: | + echo "" >> $GITHUB_STEP_SUMMARY + echo "---" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "## Node.js Integration Test Summary" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "| Command | Status |" >> $GITHUB_STEP_SUMMARY + echo "|---------|--------|" >> $GITHUB_STEP_SUMMARY + echo "| list-all | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| install | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| list | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| global | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| current | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| shim execution | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| local override | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| which | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| where | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| reshim | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| freeze | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| uninstall | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Platform: **${{ matrix.platform }}** (${{ matrix.os }})" >> $GITHUB_STEP_SUMMARY + shell: bash diff --git a/.github/workflows/integration-test-python.yml b/.github/workflows/integration-test-python.yml new file mode 100644 index 0000000..f9528d1 --- /dev/null +++ b/.github/workflows/integration-test-python.yml @@ -0,0 +1,244 @@ +name: Integration Tests - Python + +on: + workflow_call: + inputs: + version1: + description: 'First Python version to test' + required: false + type: string + default: '3.11.9' + version2: + description: 'Second Python version to test' + required: false + type: string + default: '3.12.7' + workflow_dispatch: + inputs: + version1: + description: 'First Python version to test' + required: false + type: string + default: '3.11.9' + version2: + description: 'Second Python version to test' + required: false + type: string + default: '3.12.7' + +permissions: + contents: read + +jobs: + integration-test-python: + name: Python (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + platform: linux + ext: "" + - os: macos-latest + platform: macos + ext: "" + - os: windows-latest + platform: windows + ext: ".exe" + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem${{ matrix.ext }} ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim${{ matrix.ext }} ./src/cmd/shim + shell: bash + + - name: Initialize dtvem + run: | + ./dist/dtvem${{ matrix.ext }} init --yes + shell: bash + + - name: Add shims to PATH (Unix) + if: matrix.platform != 'windows' + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: Add shims to PATH (Windows) + if: matrix.platform == 'windows' + shell: pwsh + run: | + "$env:USERPROFILE\.dtvem\shims" | Out-File -FilePath $env:GITHUB_PATH -Append + "$env:USERPROFILE\.dtvem\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + + - name: "List available versions" + run: | + echo "## Python Available Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} list-all python | head -20 >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Install version ${{ inputs.version1 || '3.11.9' }}" + run: | + ./dist/dtvem${{ matrix.ext }} install python ${{ inputs.version1 || '3.11.9' }} + shell: bash + + - name: "Install version ${{ inputs.version2 || '3.12.7' }}" + run: | + ./dist/dtvem${{ matrix.ext }} install python ${{ inputs.version2 || '3.12.7' }} + shell: bash + + - name: "List installed versions" + run: | + echo "## Python Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} list python >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Set global version to ${{ inputs.version1 || '3.11.9' }}" + run: | + ./dist/dtvem${{ matrix.ext }} global python ${{ inputs.version1 || '3.11.9' }} + shell: bash + + - name: "Verify global version via current" + run: | + CURRENT=$(./dist/dtvem${{ matrix.ext }} current python) + echo "Current python version: $CURRENT" + if [[ "$CURRENT" != *"${{ inputs.version1 || '3.11.9' }}"* ]]; then + echo "ERROR: Expected ${{ inputs.version1 || '3.11.9' }} but got $CURRENT" + exit 1 + fi + shell: bash + + - name: "Verify shim works (python --version)" + run: | + PYTHON_VERSION=$(python --version) + echo "Python version from shim: $PYTHON_VERSION" + if [[ "$PYTHON_VERSION" != *"${{ inputs.version1 || '3.11.9' }}"* ]]; then + echo "ERROR: Expected Python ${{ inputs.version1 || '3.11.9' }} but got $PYTHON_VERSION" + exit 1 + fi + shell: bash + + - name: "Switch global version to ${{ inputs.version2 || '3.12.7' }}" + run: | + ./dist/dtvem${{ matrix.ext }} global python ${{ inputs.version2 || '3.12.7' }} + shell: bash + + - name: "Verify version switched" + run: | + PYTHON_VERSION=$(python --version) + echo "Python version from shim: $PYTHON_VERSION" + if [[ "$PYTHON_VERSION" != *"${{ inputs.version2 || '3.12.7' }}"* ]]; then + echo "ERROR: Expected Python ${{ inputs.version2 || '3.12.7' }} but got $PYTHON_VERSION" + exit 1 + fi + shell: bash + + - name: "Test local version override" + run: | + mkdir -p test-project + cd test-project + ../dist/dtvem${{ matrix.ext }} local python ${{ inputs.version1 || '3.11.9' }} + CURRENT=$(../dist/dtvem${{ matrix.ext }} current python) + echo "Current python version in test-project: $CURRENT" + if [[ "$CURRENT" != *"${{ inputs.version1 || '3.11.9' }}"* ]]; then + echo "ERROR: Local override failed. Expected ${{ inputs.version1 || '3.11.9' }} but got $CURRENT" + exit 1 + fi + PYTHON_VERSION=$(python --version) + echo "Python version from shim in test-project: $PYTHON_VERSION" + if [[ "$PYTHON_VERSION" != *"${{ inputs.version1 || '3.11.9' }}"* ]]; then + echo "ERROR: Expected Python ${{ inputs.version1 || '3.11.9' }} but got $PYTHON_VERSION" + exit 1 + fi + shell: bash + + - name: "Test which command" + run: | + echo "## Python Which" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} which python >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Test where command" + run: | + echo "## Python Where" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} where python >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Test reshim command" + run: | + ./dist/dtvem${{ matrix.ext }} reshim + echo "Reshim completed successfully" + shell: bash + + - name: "Test freeze command" + run: | + echo "## Freeze Output" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} freeze >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Uninstall version ${{ inputs.version2 || '3.12.7' }}" + run: | + ./dist/dtvem${{ matrix.ext }} uninstall python ${{ inputs.version2 || '3.12.7' }} --yes + shell: bash + + - name: "Verify uninstall" + run: | + LIST_OUTPUT=$(./dist/dtvem${{ matrix.ext }} list python) + echo "Installed versions after uninstall:" + echo "$LIST_OUTPUT" + if [[ "$LIST_OUTPUT" == *"${{ inputs.version2 || '3.12.7' }}"* ]]; then + echo "ERROR: Version ${{ inputs.version2 || '3.12.7' }} should have been uninstalled" + exit 1 + fi + shell: bash + + - name: Generate summary + if: always() + run: | + echo "" >> $GITHUB_STEP_SUMMARY + echo "---" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "## Python Integration Test Summary" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "| Command | Status |" >> $GITHUB_STEP_SUMMARY + echo "|---------|--------|" >> $GITHUB_STEP_SUMMARY + echo "| list-all | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| install | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| list | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| global | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| current | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| shim execution | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| local override | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| which | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| where | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| reshim | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| freeze | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| uninstall | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Platform: **${{ matrix.platform }}** (${{ matrix.os }})" >> $GITHUB_STEP_SUMMARY + shell: bash diff --git a/.github/workflows/integration-test-ruby.yml b/.github/workflows/integration-test-ruby.yml new file mode 100644 index 0000000..7712e92 --- /dev/null +++ b/.github/workflows/integration-test-ruby.yml @@ -0,0 +1,244 @@ +name: Integration Tests - Ruby + +on: + workflow_call: + inputs: + version1: + description: 'First Ruby version to test' + required: false + type: string + default: '3.3.6' + version2: + description: 'Second Ruby version to test' + required: false + type: string + default: '3.4.1' + workflow_dispatch: + inputs: + version1: + description: 'First Ruby version to test' + required: false + type: string + default: '3.3.6' + version2: + description: 'Second Ruby version to test' + required: false + type: string + default: '3.4.1' + +permissions: + contents: read + +jobs: + integration-test-ruby: + name: Ruby (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + platform: linux + ext: "" + - os: macos-latest + platform: macos + ext: "" + - os: windows-latest + platform: windows + ext: ".exe" + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + cache: true + + - name: Build dtvem + run: | + go build -v -ldflags="-s -w" -o dist/dtvem${{ matrix.ext }} ./src + go build -v -ldflags="-s -w" -o dist/dtvem-shim${{ matrix.ext }} ./src/cmd/shim + shell: bash + + - name: Initialize dtvem + run: | + ./dist/dtvem${{ matrix.ext }} init --yes + shell: bash + + - name: Add shims to PATH (Unix) + if: matrix.platform != 'windows' + run: | + echo "$HOME/.dtvem/shims" >> $GITHUB_PATH + echo "$HOME/.dtvem/bin" >> $GITHUB_PATH + + - name: Add shims to PATH (Windows) + if: matrix.platform == 'windows' + shell: pwsh + run: | + "$env:USERPROFILE\.dtvem\shims" | Out-File -FilePath $env:GITHUB_PATH -Append + "$env:USERPROFILE\.dtvem\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + + - name: "List available versions" + run: | + echo "## Ruby Available Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} list-all ruby | head -20 >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Install version ${{ inputs.version1 || '3.3.6' }}" + run: | + ./dist/dtvem${{ matrix.ext }} install ruby ${{ inputs.version1 || '3.3.6' }} + shell: bash + + - name: "Install version ${{ inputs.version2 || '3.4.1' }}" + run: | + ./dist/dtvem${{ matrix.ext }} install ruby ${{ inputs.version2 || '3.4.1' }} + shell: bash + + - name: "List installed versions" + run: | + echo "## Ruby Installed Versions" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} list ruby >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Set global version to ${{ inputs.version1 || '3.3.6' }}" + run: | + ./dist/dtvem${{ matrix.ext }} global ruby ${{ inputs.version1 || '3.3.6' }} + shell: bash + + - name: "Verify global version via current" + run: | + CURRENT=$(./dist/dtvem${{ matrix.ext }} current ruby) + echo "Current ruby version: $CURRENT" + if [[ "$CURRENT" != *"${{ inputs.version1 || '3.3.6' }}"* ]]; then + echo "ERROR: Expected ${{ inputs.version1 || '3.3.6' }} but got $CURRENT" + exit 1 + fi + shell: bash + + - name: "Verify shim works (ruby --version)" + run: | + RUBY_VERSION=$(ruby --version) + echo "Ruby version from shim: $RUBY_VERSION" + if [[ "$RUBY_VERSION" != *"${{ inputs.version1 || '3.3.6' }}"* ]]; then + echo "ERROR: Expected ruby ${{ inputs.version1 || '3.3.6' }} but got $RUBY_VERSION" + exit 1 + fi + shell: bash + + - name: "Switch global version to ${{ inputs.version2 || '3.4.1' }}" + run: | + ./dist/dtvem${{ matrix.ext }} global ruby ${{ inputs.version2 || '3.4.1' }} + shell: bash + + - name: "Verify version switched" + run: | + RUBY_VERSION=$(ruby --version) + echo "Ruby version from shim: $RUBY_VERSION" + if [[ "$RUBY_VERSION" != *"${{ inputs.version2 || '3.4.1' }}"* ]]; then + echo "ERROR: Expected ruby ${{ inputs.version2 || '3.4.1' }} but got $RUBY_VERSION" + exit 1 + fi + shell: bash + + - name: "Test local version override" + run: | + mkdir -p test-project + cd test-project + ../dist/dtvem${{ matrix.ext }} local ruby ${{ inputs.version1 || '3.3.6' }} + CURRENT=$(../dist/dtvem${{ matrix.ext }} current ruby) + echo "Current ruby version in test-project: $CURRENT" + if [[ "$CURRENT" != *"${{ inputs.version1 || '3.3.6' }}"* ]]; then + echo "ERROR: Local override failed. Expected ${{ inputs.version1 || '3.3.6' }} but got $CURRENT" + exit 1 + fi + RUBY_VERSION=$(ruby --version) + echo "Ruby version from shim in test-project: $RUBY_VERSION" + if [[ "$RUBY_VERSION" != *"${{ inputs.version1 || '3.3.6' }}"* ]]; then + echo "ERROR: Expected ruby ${{ inputs.version1 || '3.3.6' }} but got $RUBY_VERSION" + exit 1 + fi + shell: bash + + - name: "Test which command" + run: | + echo "## Ruby Which" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} which ruby >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Test where command" + run: | + echo "## Ruby Where" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} where ruby >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Test reshim command" + run: | + ./dist/dtvem${{ matrix.ext }} reshim + echo "Reshim completed successfully" + shell: bash + + - name: "Test freeze command" + run: | + echo "## Freeze Output" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./dist/dtvem${{ matrix.ext }} freeze >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + shell: bash + + - name: "Uninstall version ${{ inputs.version2 || '3.4.1' }}" + run: | + ./dist/dtvem${{ matrix.ext }} uninstall ruby ${{ inputs.version2 || '3.4.1' }} --yes + shell: bash + + - name: "Verify uninstall" + run: | + LIST_OUTPUT=$(./dist/dtvem${{ matrix.ext }} list ruby) + echo "Installed versions after uninstall:" + echo "$LIST_OUTPUT" + if [[ "$LIST_OUTPUT" == *"${{ inputs.version2 || '3.4.1' }}"* ]]; then + echo "ERROR: Version ${{ inputs.version2 || '3.4.1' }} should have been uninstalled" + exit 1 + fi + shell: bash + + - name: Generate summary + if: always() + run: | + echo "" >> $GITHUB_STEP_SUMMARY + echo "---" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "## Ruby Integration Test Summary" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "| Command | Status |" >> $GITHUB_STEP_SUMMARY + echo "|---------|--------|" >> $GITHUB_STEP_SUMMARY + echo "| list-all | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| install | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| list | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| global | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| current | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| shim execution | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| local override | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| which | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| where | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| reshim | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| freeze | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| uninstall | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Platform: **${{ matrix.platform }}** (${{ matrix.os }})" >> $GITHUB_STEP_SUMMARY + shell: bash diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 0000000..af53de7 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,113 @@ +name: Integration Tests + +on: + schedule: + # Run weekly on Sunday at midnight UTC + - cron: '0 0 * * 0' + workflow_dispatch: + # Allow manual trigger + +permissions: + contents: read + +jobs: + # ========================================================================== + # Runtime Installation Tests (install, list, global, local, etc.) + # ========================================================================== + node: + name: Node.js + uses: ./.github/workflows/integration-test-node.yml + with: + version1: '20.18.0' + version2: '22.11.0' + + python: + name: Python + uses: ./.github/workflows/integration-test-python.yml + with: + version1: '3.11.9' + version2: '3.12.7' + + ruby: + name: Ruby + uses: ./.github/workflows/integration-test-ruby.yml + with: + version1: '3.3.6' + version2: '3.4.1' + + # ========================================================================== + # Migration Tests - Node.js + # ========================================================================== + migrate-node-ubuntu-system: + name: Migrate Node.js from System (Ubuntu) + uses: ./.github/workflows/integration-test-migrate-node-ubuntu-system.yml + + migrate-node-ubuntu-nvm: + name: Migrate Node.js from nvm (Ubuntu) + uses: ./.github/workflows/integration-test-migrate-node-ubuntu-nvm.yml + + migrate-node-macos-system: + name: Migrate Node.js from System (macOS) + uses: ./.github/workflows/integration-test-migrate-node-macos-system.yml + + migrate-node-macos-fnm: + name: Migrate Node.js from fnm (macOS) + uses: ./.github/workflows/integration-test-migrate-node-macos-fnm.yml + + migrate-node-windows-system: + name: Migrate Node.js from System (Windows) + uses: ./.github/workflows/integration-test-migrate-node-windows-system.yml + + migrate-node-windows-nvm: + name: Migrate Node.js from nvm-windows (Windows) + uses: ./.github/workflows/integration-test-migrate-node-windows-nvm.yml + + # ========================================================================== + # Migration Tests - Python + # ========================================================================== + migrate-python-ubuntu-system: + name: Migrate Python from System (Ubuntu) + uses: ./.github/workflows/integration-test-migrate-python-ubuntu-system.yml + + migrate-python-ubuntu-pyenv: + name: Migrate Python from pyenv (Ubuntu) + uses: ./.github/workflows/integration-test-migrate-python-ubuntu-pyenv.yml + + migrate-python-macos-system: + name: Migrate Python from System (macOS) + uses: ./.github/workflows/integration-test-migrate-python-macos-system.yml + + migrate-python-macos-pyenv: + name: Migrate Python from pyenv (macOS) + uses: ./.github/workflows/integration-test-migrate-python-macos-pyenv.yml + + migrate-python-windows-system: + name: Migrate Python from System (Windows) + uses: ./.github/workflows/integration-test-migrate-python-windows-system.yml + + migrate-python-windows-pyenv: + name: Migrate Python from pyenv-win (Windows) + uses: ./.github/workflows/integration-test-migrate-python-windows-pyenv.yml + + # ========================================================================== + # Migration Tests - Ruby + # ========================================================================== + migrate-ruby-ubuntu-system: + name: Migrate Ruby from System (Ubuntu) + uses: ./.github/workflows/integration-test-migrate-ruby-ubuntu-system.yml + + migrate-ruby-ubuntu-rbenv: + name: Migrate Ruby from rbenv (Ubuntu) + uses: ./.github/workflows/integration-test-migrate-ruby-ubuntu-rbenv.yml + + migrate-ruby-macos-system: + name: Migrate Ruby from System (macOS) + uses: ./.github/workflows/integration-test-migrate-ruby-macos-system.yml + + migrate-ruby-macos-rbenv: + name: Migrate Ruby from rbenv (macOS) + uses: ./.github/workflows/integration-test-migrate-ruby-macos-rbenv.yml + + migrate-ruby-windows-system: + name: Migrate Ruby from System (Windows) + uses: ./.github/workflows/integration-test-migrate-ruby-windows-system.yml