|
| 1 | +name: Linux E2E Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + e2e-linux: |
| 12 | + name: E2E Tests (Linux) |
| 13 | + runs-on: ubuntu-latest |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + shell: [bash, zsh] |
| 18 | + # Note: fish is excluded for now as wt shellenv doesn't support fish yet |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Generate GitHub App token |
| 22 | + id: generate-token |
| 23 | + if: ${{ secrets.BOT_APP_ID != '' }} |
| 24 | + uses: actions/create-github-app-token@v1 |
| 25 | + with: |
| 26 | + app-id: ${{ secrets.BOT_APP_ID }} |
| 27 | + private-key: ${{ secrets.BOT_PRIVATE_KEY }} |
| 28 | + |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + token: ${{ steps.generate-token.outputs.token || github.token }} |
| 33 | + |
| 34 | + - name: Set up Go |
| 35 | + uses: actions/setup-go@v5 |
| 36 | + with: |
| 37 | + go-version: '1.23' |
| 38 | + |
| 39 | + - name: Install zsh |
| 40 | + if: matrix.shell == 'zsh' |
| 41 | + run: | |
| 42 | + sudo apt-get update |
| 43 | + sudo apt-get install -y zsh |
| 44 | +
|
| 45 | + - name: Download dependencies |
| 46 | + run: go mod download |
| 47 | + |
| 48 | + - name: Build wt binary |
| 49 | + run: | |
| 50 | + mkdir -p bin |
| 51 | + go build -o bin/wt . |
| 52 | +
|
| 53 | + - name: Verify binary |
| 54 | + run: | |
| 55 | + ./bin/wt --help |
| 56 | + file bin/wt |
| 57 | +
|
| 58 | + - name: Run e2e tests for ${{ matrix.shell }} |
| 59 | + run: | |
| 60 | + # Set up isolated test environment |
| 61 | + export TMPDIR=$(mktemp -d) |
| 62 | + export HOME=$TMPDIR |
| 63 | +
|
| 64 | + # Run e2e tests with verbose output |
| 65 | + if [ "${{ matrix.shell }}" = "bash" ]; then |
| 66 | + go test -v -run TestE2EAutoCdWithNonInteractiveCommand ./... |
| 67 | + go test -v -run TestE2EAutoCdWithCreate ./... |
| 68 | + elif [ "${{ matrix.shell }}" = "zsh" ]; then |
| 69 | + go test -v -run TestE2EAutoCdInZsh ./... |
| 70 | + fi |
| 71 | +
|
| 72 | + - name: Test shellenv output |
| 73 | + run: | |
| 74 | + # Capture shellenv output for inspection |
| 75 | + ./bin/wt shellenv > shellenv-${{ matrix.shell }}.txt |
| 76 | +
|
| 77 | + # Verify shellenv produces output |
| 78 | + if [ ! -s shellenv-${{ matrix.shell }}.txt ]; then |
| 79 | + echo "ERROR: shellenv produced no output" |
| 80 | + exit 1 |
| 81 | + fi |
| 82 | +
|
| 83 | + # Check for key components (wt function) |
| 84 | + if ! grep -q "wt()" shellenv-${{ matrix.shell }}.txt; then |
| 85 | + echo "ERROR: wt function not found in shellenv output" |
| 86 | + exit 1 |
| 87 | + fi |
| 88 | +
|
| 89 | + # Verify shell-specific features |
| 90 | + if [ "${{ matrix.shell }}" = "bash" ]; then |
| 91 | + grep -q "BASH_VERSION" shellenv-${{ matrix.shell }}.txt || (echo "ERROR: bash-specific code not found" && exit 1) |
| 92 | + elif [ "${{ matrix.shell }}" = "zsh" ]; then |
| 93 | + grep -q "ZSH_VERSION" shellenv-${{ matrix.shell }}.txt || (echo "ERROR: zsh-specific code not found" && exit 1) |
| 94 | + fi |
| 95 | +
|
| 96 | + echo "shellenv validation passed for ${{ matrix.shell }}" |
| 97 | +
|
| 98 | + - name: Test worktree CRUD operations with auto-cd |
| 99 | + run: | |
| 100 | + # Save workspace directory before creating test repo |
| 101 | + WORKSPACE_DIR=$(pwd) |
| 102 | + WT_BIN="$WORKSPACE_DIR/bin/wt" |
| 103 | + WT_BIN_DIR="$WORKSPACE_DIR/bin" |
| 104 | +
|
| 105 | + # Create isolated test environment |
| 106 | + export WORKTREE_ROOT=$(mktemp -d)/worktrees |
| 107 | + export PATH=$WT_BIN_DIR:$PATH |
| 108 | +
|
| 109 | + # Create a test git repo |
| 110 | + TEST_REPO=$(mktemp -d)/test-repo |
| 111 | + mkdir -p $TEST_REPO |
| 112 | + cd $TEST_REPO |
| 113 | + git init |
| 114 | + git config user.email "test@example.com" |
| 115 | + git config user.name "Test User" |
| 116 | + git commit --allow-empty -m "initial commit" |
| 117 | + git branch -M main |
| 118 | +
|
| 119 | + # Create a test branch |
| 120 | + git checkout -b test-branch |
| 121 | + git commit --allow-empty -m "test commit" |
| 122 | + git checkout main |
| 123 | +
|
| 124 | + # Test with shell integration |
| 125 | + if [ "${{ matrix.shell }}" = "bash" ]; then |
| 126 | + SHELL_CMD="bash" |
| 127 | + else |
| 128 | + SHELL_CMD="zsh" |
| 129 | + fi |
| 130 | +
|
| 131 | + # Generate shellenv script for the shell |
| 132 | + $WT_BIN shellenv > /tmp/wt-shellenv-${{ matrix.shell }}.sh |
| 133 | +
|
| 134 | + # Run test in a subshell with shellenv sourced |
| 135 | + $SHELL_CMD -c " |
| 136 | + export WORKTREE_ROOT=$WORKTREE_ROOT |
| 137 | + export PATH=$WT_BIN_DIR:\$PATH |
| 138 | + cd $TEST_REPO |
| 139 | + source /tmp/wt-shellenv-${{ matrix.shell }}.sh |
| 140 | +
|
| 141 | + echo 'Testing: wt checkout test-branch' |
| 142 | + wt checkout test-branch |
| 143 | +
|
| 144 | + # Verify we're in the worktree directory |
| 145 | + CURRENT_DIR=\$(pwd) |
| 146 | + EXPECTED_DIR=$WORKTREE_ROOT/test-repo/test-branch |
| 147 | + if [[ \"\$CURRENT_DIR\" != \"\$EXPECTED_DIR\" ]]; then |
| 148 | + echo \"ERROR: Auto-cd failed. Expected: \$EXPECTED_DIR, Got: \$CURRENT_DIR\" |
| 149 | + exit 1 |
| 150 | + fi |
| 151 | + echo \"✓ Auto-cd to worktree verified: \$CURRENT_DIR\" |
| 152 | +
|
| 153 | + # Verify worktree was created |
| 154 | + wt list | grep test-branch || (echo 'ERROR: worktree not in list' && exit 1) |
| 155 | + echo '✓ Worktree created and listed' |
| 156 | +
|
| 157 | + # Go back to original repo to test create |
| 158 | + cd $TEST_REPO |
| 159 | +
|
| 160 | + # Test create command |
| 161 | + echo 'Testing: wt create feature-test' |
| 162 | + wt create feature-test |
| 163 | + CURRENT_DIR=\$(pwd) |
| 164 | + EXPECTED_DIR=$WORKTREE_ROOT/test-repo/feature-test |
| 165 | + if [[ \"\$CURRENT_DIR\" != \"\$EXPECTED_DIR\" ]]; then |
| 166 | + echo \"ERROR: Auto-cd failed for create. Expected: \$EXPECTED_DIR, Got: \$CURRENT_DIR\" |
| 167 | + exit 1 |
| 168 | + fi |
| 169 | + echo \"✓ Auto-cd to new worktree verified: \$CURRENT_DIR\" |
| 170 | +
|
| 171 | + # Go back to original repo to test remove |
| 172 | + cd $TEST_REPO |
| 173 | +
|
| 174 | + # Test remove command |
| 175 | + echo 'Testing: wt remove test-branch' |
| 176 | + wt remove test-branch |
| 177 | +
|
| 178 | + # Verify worktree was removed |
| 179 | + if wt list | grep test-branch; then |
| 180 | + echo 'ERROR: worktree not removed' |
| 181 | + exit 1 |
| 182 | + fi |
| 183 | + echo '✓ Worktree removed successfully' |
| 184 | +
|
| 185 | + echo 'CRUD operations with auto-cd test passed!' |
| 186 | + " |
| 187 | +
|
| 188 | + - name: Upload shellenv output as artifact |
| 189 | + if: always() |
| 190 | + uses: actions/upload-artifact@v4 |
| 191 | + with: |
| 192 | + name: shellenv-output-${{ matrix.shell }} |
| 193 | + path: shellenv-${{ matrix.shell }}.txt |
| 194 | + retention-days: 7 |
| 195 | + |
| 196 | + - name: Upload test logs |
| 197 | + if: failure() |
| 198 | + uses: actions/upload-artifact@v4 |
| 199 | + with: |
| 200 | + name: e2e-logs-${{ matrix.shell }} |
| 201 | + path: | |
| 202 | + /tmp/*.log |
| 203 | + /var/tmp/*.log |
| 204 | + retention-days: 7 |
| 205 | + if-no-files-found: ignore |
0 commit comments