|
| 1 | +name: E2E Shell Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + branches: [ "main" ] |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + test_model: |
| 10 | + description: "Model to test with" |
| 11 | + required: false |
| 12 | + default: "ai/smollm2" |
| 13 | + |
| 14 | +jobs: |
| 15 | + e2e-shell-tests: |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + strategy: |
| 18 | + fail-fast: false # Continue other tests even if one fails |
| 19 | + matrix: |
| 20 | + include: |
| 21 | + # Linux shells |
| 22 | + - os: ubuntu-latest |
| 23 | + shell-name: bash |
| 24 | + shell-type: bash |
| 25 | + test-script: ./e2e/shells/bash_test.sh |
| 26 | + |
| 27 | + - os: ubuntu-latest |
| 28 | + shell-name: zsh |
| 29 | + shell-type: bash |
| 30 | + test-script: ./e2e/shells/zsh_test.sh |
| 31 | + |
| 32 | + # Windows shells |
| 33 | + - os: windows-latest |
| 34 | + shell-name: cmd |
| 35 | + shell-type: cmd |
| 36 | + test-script: e2e\shells\cmd_test.bat |
| 37 | + |
| 38 | + - os: windows-latest |
| 39 | + shell-name: git-bash |
| 40 | + shell-type: bash |
| 41 | + test-script: ./e2e/shells/mintty_test.sh |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Checkout repository |
| 45 | + uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Set up Go |
| 48 | + uses: actions/setup-go@v5 |
| 49 | + with: |
| 50 | + go-version-file: go.mod |
| 51 | + cache: true |
| 52 | + |
| 53 | + # Cross-platform Docker setup |
| 54 | + - name: Set up Docker |
| 55 | + uses: docker/setup-docker-action@v4 |
| 56 | + |
| 57 | + - name: Install model-cli as Docker plugin |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + echo "Installing model-cli as Docker plugin..." |
| 61 | + make install |
| 62 | + echo "Installation completed successfully" |
| 63 | +
|
| 64 | + - name: Test docker model version |
| 65 | + shell: bash |
| 66 | + run: | |
| 67 | + echo "Testing docker model version command..." |
| 68 | + docker model version |
| 69 | + |
| 70 | + # Verify the command returns successfully |
| 71 | + if [ $? -eq 0 ]; then |
| 72 | + echo "✅ docker model version command works correctly" |
| 73 | + else |
| 74 | + echo "❌ docker model version command failed" |
| 75 | + exit 1 |
| 76 | + fi |
| 77 | +
|
| 78 | + - name: Test model pull and run |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + MODEL="${{ github.event.inputs.test_model || 'ai/smollm2' }}" |
| 82 | + echo "Testing with model: $MODEL" |
| 83 | + |
| 84 | + # Test model pull |
| 85 | + echo "Pulling model..." |
| 86 | + docker model pull "$MODEL" |
| 87 | + |
| 88 | + if [ $? -eq 0 ]; then |
| 89 | + echo "✅ Model pull successful" |
| 90 | + else |
| 91 | + echo "❌ Model pull failed" |
| 92 | + exit 1 |
| 93 | + fi |
| 94 | + |
| 95 | + # Test basic model run (with timeout to avoid hanging) |
| 96 | + echo "Testing docker model run..." |
| 97 | + if [ "$RUNNER_OS" = "Windows" ]; then |
| 98 | + # Windows doesn't have timeout command, use PowerShell |
| 99 | + powershell -Command "& { Start-Process -FilePath 'docker' -ArgumentList 'model', 'run', '$MODEL', 'Give me a fact about whales.' -Wait -TimeoutSec 60 }" || { |
| 100 | + exit_code=$? |
| 101 | + if [ $exit_code -eq 1 ]; then |
| 102 | + echo "✅ Model run test completed (timed out as expected for non-interactive test)" |
| 103 | + else |
| 104 | + echo "❌ Model run failed with exit code: $exit_code" |
| 105 | + exit 1 |
| 106 | + fi |
| 107 | + } |
| 108 | + else |
| 109 | + timeout 60s docker model run "$MODEL" "Give me a fact about whales." || { |
| 110 | + exit_code=$? |
| 111 | + if [ $exit_code -eq 124 ]; then |
| 112 | + echo "✅ Model run test completed (timed out as expected for non-interactive test)" |
| 113 | + else |
| 114 | + echo "❌ Model run failed with exit code: $exit_code" |
| 115 | + exit 1 |
| 116 | + fi |
| 117 | + } |
| 118 | + fi |
| 119 | +
|
| 120 | + # Shell-specific setup |
| 121 | + - name: Install Zsh (Linux) |
| 122 | + if: matrix.shell-name == 'zsh' && runner.os == 'Linux' |
| 123 | + shell: bash |
| 124 | + run: sudo apt-get update && sudo apt-get install -y zsh |
| 125 | + |
| 126 | + # Shell-specific test execution |
| 127 | + - name: Run Bash E2E Tests |
| 128 | + if: matrix.shell-name == 'bash' |
| 129 | + shell: bash |
| 130 | + run: | |
| 131 | + chmod +x ${{ matrix.test-script }} |
| 132 | + ${{ matrix.test-script }} |
| 133 | +
|
| 134 | + - name: Run Zsh E2E Tests |
| 135 | + if: matrix.shell-name == 'zsh' |
| 136 | + shell: bash |
| 137 | + run: | |
| 138 | + chmod +x ${{ matrix.test-script }} |
| 139 | + zsh ${{ matrix.test-script }} |
| 140 | +
|
| 141 | + - name: Run CMD E2E Tests |
| 142 | + if: matrix.shell-name == 'cmd' |
| 143 | + shell: cmd |
| 144 | + run: ${{ matrix.test-script }} |
| 145 | + |
| 146 | + - name: Run Git Bash E2E Tests |
| 147 | + if: matrix.shell-name == 'git-bash' |
| 148 | + shell: bash |
| 149 | + run: | |
| 150 | + chmod +x ${{ matrix.test-script }} |
| 151 | + ${{ matrix.test-script }} |
0 commit comments