Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 91 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,18 @@ jobs:
- name: Install shells for PTY tests
run: |
sudo apt-get update
sudo apt-get install -y bash zsh
sudo apt-get install -y bash zsh wget
# Fix zsh permissions to avoid compinit security warnings
sudo chmod -R 755 /usr/share/zsh
sudo chown -R root:root /usr/share/zsh

# Install PowerShell on Linux
# Download and install PowerShell package
wget -q https://github.com/PowerShell/PowerShell/releases/download/v7.4.6/powershell_7.4.6-1.deb_amd64.deb
sudo dpkg -i powershell_7.4.6-1.deb_amd64.deb
sudo apt-get install -f -y
pwsh --version

- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...

Expand Down Expand Up @@ -161,7 +168,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
shell: ['bash', 'zsh']
shell: ['bash', 'zsh', 'pwsh']

steps:
- name: Generate GitHub App token
Expand Down Expand Up @@ -194,6 +201,10 @@ jobs:
./bin/wt --help
file bin/wt

- name: Install PowerShell (if needed)
if: matrix.shell == 'pwsh'
run: brew install --cask powershell

- name: Run e2e tests for ${{ matrix.shell }}
run: |
# Set up isolated test environment
Expand All @@ -207,6 +218,9 @@ jobs:
elif [ "${{ matrix.shell }}" = "zsh" ]; then
# Run both old e2e test and new PTY interactive tests for zsh
go test -v -run 'TestE2EAutoCdInZsh|TestInteractiveCheckoutWithoutArgs|TestNonInteractiveCheckoutWithArgs' .
elif [ "${{ matrix.shell }}" = "pwsh" ]; then
# Run PowerShell PTY interactive tests
go test -v -run 'TestInteractiveCheckoutWithoutArgsPowerShell|TestNonInteractiveCheckoutWithArgsPowerShell' .
fi

# Cleanup (best effort - ignore errors from Go cache files)
Expand All @@ -224,16 +238,28 @@ jobs:
fi

# Check for key components (wt function)
if ! grep -q "wt()" shellenv-${{ matrix.shell }}.txt; then
echo "ERROR: wt function not found in shellenv output"
exit 1
if [ "${{ matrix.shell }}" = "pwsh" ]; then
# PowerShell uses "function wt"
if ! grep -q "function wt" shellenv-${{ matrix.shell }}.txt; then
echo "ERROR: wt function not found in shellenv output"
exit 1
fi
else
# Bash/Zsh use "wt()"
if ! grep -q "wt()" shellenv-${{ matrix.shell }}.txt; then
echo "ERROR: wt function not found in shellenv output"
exit 1
fi
fi

# Verify shell-specific features
if [ "${{ matrix.shell }}" = "bash" ]; then
grep -q "BASH_VERSION" shellenv-${{ matrix.shell }}.txt || (echo "ERROR: bash-specific code not found" && exit 1)
elif [ "${{ matrix.shell }}" = "zsh" ]; then
grep -q "ZSH_VERSION" shellenv-${{ matrix.shell }}.txt || (echo "ERROR: zsh-specific code not found" && exit 1)
elif [ "${{ matrix.shell }}" = "pwsh" ]; then
grep -q "PowerShell" shellenv-${{ matrix.shell }}.txt || (echo "ERROR: PowerShell-specific code not found" && exit 1)
grep -q "Get-Command" shellenv-${{ matrix.shell }}.txt || (echo "ERROR: PowerShell Get-Command not found" && exit 1)
fi

echo "shellenv validation passed for ${{ matrix.shell }}"
Expand Down Expand Up @@ -358,17 +384,65 @@ jobs:
retention-days: 7
if-no-files-found: ignore

# e2e-windows:
# name: E2E Tests (Windows)
# runs-on: windows-latest
# strategy:
# matrix:
# shell: ['powershell', 'pwsh']
e2e-windows:
name: E2E Tests (Windows)
runs-on: windows-latest
strategy:
matrix:
shell: ['powershell', 'pwsh']

# Disabled for now - TODO: re-enable once Windows PTY support is added
e2e-windows-disabled:
name: E2E Tests (Windows) - Disabled
runs-on: ubuntu-latest
steps:
- name: Skip Windows tests
run: echo "Windows e2e tests are temporarily disabled. TODO add Windows PTY support"
- name: Generate GitHub App token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}

- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'

- name: Download dependencies
run: go mod download

- name: Build wt binary
run: |
mkdir -p bin
go build -o bin/wt.exe .

- name: Verify binary
run: |
./bin/wt.exe --help

- name: Run e2e tests for ${{ matrix.shell }}
shell: pwsh
run: |
# Set up isolated test environment
$env:ISOLATED_TMPDIR = New-TemporaryFile | ForEach-Object { Remove-Item $_; New-Item -ItemType Directory -Path $_ }
$env:HOME = $env:ISOLATED_TMPDIR

# Run specific e2e tests based on shell
if ('${{ matrix.shell }}' -eq 'powershell') {
# Skip pwsh-specific tests for older PowerShell
go test -v -run 'TestNonInteractiveCheckoutWithArgsPowerShell' .
} elseif ('${{ matrix.shell }}' -eq 'pwsh') {
# Run both interactive and non-interactive tests for pwsh
go test -v -run 'TestInteractiveCheckoutWithoutArgsPowerShell|TestNonInteractiveCheckoutWithArgsPowerShell' .
}

- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-logs-${{ matrix.shell }}
path: |
${{ runner.temp }}/*.log
retention-days: 7
if-no-files-found: ignore
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ sudo cp bin/wt /usr/local/bin/

### Shell Integration (Optional but Recommended)

#### Bash/Zsh (Linux, macOS)

Add this to the **END** of your `~/.bashrc` or `~/.zshrc`:

```bash
Expand All @@ -62,9 +64,42 @@ source <(wt shellenv)

**Note for zsh users:** Place this after `compinit` in your config file.

This enables:
#### PowerShell (Windows, macOS, Linux)

Add this to your PowerShell `$PROFILE`:

```powershell
& wt shellenv | Out-String | Invoke-Expression
```

To find your profile location, run:
```powershell
$PROFILE
```

To edit it:
```powershell
notepad $PROFILE # Windows
code $PROFILE # VS Code
nano $PROFILE # Unix/macOS
```

After editing, reload your profile:
```powershell
. $PROFILE
```

To verify the integration is working:
```powershell
# Should show CommandType: Function
Get-Command wt | Select-Object CommandType, Source
```

#### What Shell Integration Enables

- Automatic `cd` to worktree after `checkout`/`create`/`pr`/`mr` commands
- Tab completion for commands and branch names
- Tab completion for commands and branch names (Bash/Zsh/PowerShell)
- Interactive prompts work correctly in all shells

## Usage

Expand Down
Loading
Loading