|
| 1 | +--- |
| 2 | +name: Installation Test |
| 3 | + |
| 4 | +on: |
| 5 | + release: |
| 6 | + types: [published] |
| 7 | + workflow_dispatch: {} |
| 8 | + |
| 9 | +jobs: |
| 10 | + test-unix-install: |
| 11 | + name: Test Unix Installation |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + os: [ubuntu-latest, macos-latest] |
| 15 | + include: |
| 16 | + - os: ubuntu-latest |
| 17 | + target: x86_64-unknown-linux-gnu |
| 18 | + - os: macos-latest |
| 19 | + target: x86_64-apple-darwin |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v3 |
| 23 | + |
| 24 | + - name: Get install script |
| 25 | + id: get_linux_install_script |
| 26 | + shell: bash |
| 27 | + run: | |
| 28 | + script=$(awk '/<!-- LINUX_INSTALLATION_BEGIN -->/{p=1;next}/<!-- LINUX_INSTALLATION_END -->/{p=0}p' README.md | grep -v '^```') |
| 29 | + # Ensure script is not empty |
| 30 | + if [ -z "$script" ]; then |
| 31 | + echo "Error: Could not extract Linux installation script from README.md" |
| 32 | + exit 1 |
| 33 | + fi |
| 34 | + # Escape multiline output |
| 35 | + script="${script//'%'/'%25'}" |
| 36 | + script="${script//$'\n'/'%0A'}" |
| 37 | + script="${script//$'\r'/'%0D'}" |
| 38 | + echo "script=$script" >> $GITHUB_OUTPUT |
| 39 | +
|
| 40 | + - name: Install Rust |
| 41 | + uses: dtolnay/rust-toolchain@stable |
| 42 | + with: |
| 43 | + targets: ${{ matrix.target }} |
| 44 | + |
| 45 | + - name: Build yek |
| 46 | + shell: bash |
| 47 | + run: | |
| 48 | + cargo build --release --target ${{ matrix.target }} --locked |
| 49 | + # Verify binary exists |
| 50 | + binary="target/${{ matrix.target }}/release/yek" |
| 51 | + if [ ! -f "$binary" ]; then |
| 52 | + echo "Error: Binary not found at: $binary" |
| 53 | + find target -name "yek" -o -name "yek.exe" |
| 54 | + exit 1 |
| 55 | + fi |
| 56 | + ls -l "$binary" |
| 57 | +
|
| 58 | + - name: Setup test environment |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + # Create test directory |
| 62 | + sudo mkdir -p /usr/local/bin |
| 63 | + # Copy binary |
| 64 | + sudo cp "target/${{ matrix.target }}/release/yek" /usr/local/bin/ |
| 65 | + # Make executable |
| 66 | + sudo chmod +x /usr/local/bin/yek |
| 67 | + # Verify binary is executable |
| 68 | + if ! which yek; then |
| 69 | + echo "Error: yek not found in PATH after manual installation" |
| 70 | + echo "PATH: $PATH" |
| 71 | + exit 1 |
| 72 | + fi |
| 73 | +
|
| 74 | + - name: Test installation script |
| 75 | + run: ${{ steps.get_linux_install_script.outputs.script }} |
| 76 | + |
| 77 | + - name: Verify installation |
| 78 | + run: | |
| 79 | + # Ensure yek is in PATH |
| 80 | + which yek || { |
| 81 | + echo "Error: yek not found in PATH" |
| 82 | + echo "PATH: $PATH" |
| 83 | + exit 1 |
| 84 | + } |
| 85 | + # Test version output |
| 86 | + yek --version || { |
| 87 | + echo "Error: yek --version failed" |
| 88 | + exit 1 |
| 89 | + } |
| 90 | + # Create test file |
| 91 | + echo "test content" > test.txt |
| 92 | + # Test basic functionality |
| 93 | + yek test.txt || { |
| 94 | + echo "Error: yek failed to process test file" |
| 95 | + exit 1 |
| 96 | + } |
| 97 | + # Verify output exists |
| 98 | + test -f repo-serialized/chunk-0.txt || { |
| 99 | + echo "Error: Output file not found" |
| 100 | + ls -la repo-serialized/ || true |
| 101 | + exit 1 |
| 102 | + } |
| 103 | +
|
| 104 | + test-windows-install: |
| 105 | + name: Test Windows Installation |
| 106 | + runs-on: windows-latest |
| 107 | + steps: |
| 108 | + - uses: actions/checkout@v3 |
| 109 | + |
| 110 | + - name: Get install script |
| 111 | + id: get_windows_install_script |
| 112 | + shell: bash |
| 113 | + run: | |
| 114 | + script=$(awk '/<!-- WINDOWS_INSTALLATION_BEGIN -->/{p=1;next}/<!-- WINDOWS_INSTALLATION_END -->/{p=0}p' README.md | grep -v '^```') |
| 115 | + # Ensure script is not empty |
| 116 | + if [ -z "$script" ]; then |
| 117 | + echo "Error: Could not extract Windows installation script from README.md" |
| 118 | + exit 1 |
| 119 | + fi |
| 120 | + # Escape multiline output |
| 121 | + script="${script//'%'/'%25'}" |
| 122 | + script="${script//$'\n'/'%0A'}" |
| 123 | + script="${script//$'\r'/'%0D'}" |
| 124 | + echo "script=$script" >> $GITHUB_OUTPUT |
| 125 | +
|
| 126 | + - name: Install Rust |
| 127 | + uses: dtolnay/rust-toolchain@stable |
| 128 | + with: |
| 129 | + targets: x86_64-pc-windows-msvc |
| 130 | + |
| 131 | + - name: Build yek |
| 132 | + shell: powershell |
| 133 | + run: | |
| 134 | + cargo build --release --target x86_64-pc-windows-msvc --locked |
| 135 | + # Verify binary exists |
| 136 | + $binary = "target\x86_64-pc-windows-msvc\release\yek.exe" |
| 137 | + if (-not (Test-Path $binary)) { |
| 138 | + Write-Error "Binary not found at: $binary" |
| 139 | + Get-ChildItem target -Recurse | Where-Object { $_.Name -like "yek.exe" } |
| 140 | + exit 1 |
| 141 | + } |
| 142 | + Write-Host "Binary size: $((Get-Item $binary).Length) bytes" |
| 143 | +
|
| 144 | + - name: Setup test environment |
| 145 | + shell: powershell |
| 146 | + run: | |
| 147 | + # Create test directory |
| 148 | + New-Item -ItemType Directory -Path "$env:USERPROFILE\.local\bin" -Force |
| 149 | + # Add to PATH |
| 150 | + $env:Path = "$env:USERPROFILE\.local\bin;" + $env:Path |
| 151 | + # Copy binary |
| 152 | + Copy-Item "target\x86_64-pc-windows-msvc\release\yek.exe" "$env:USERPROFILE\.local\bin\yek.exe" |
| 153 | + # Verify binary is executable |
| 154 | + if (-not (Get-Command yek -ErrorAction SilentlyContinue)) { |
| 155 | + Write-Error "yek not found in PATH after manual installation" |
| 156 | + Write-Host "PATH: $env:Path" |
| 157 | + exit 1 |
| 158 | + } |
| 159 | +
|
| 160 | + - name: Test installation script |
| 161 | + shell: powershell |
| 162 | + run: ${{ steps.get_windows_install_script.outputs.script }} |
| 163 | + |
| 164 | + - name: Verify installation |
| 165 | + shell: powershell |
| 166 | + run: | |
| 167 | + # Ensure yek is in PATH |
| 168 | + if (-not (Get-Command yek -ErrorAction SilentlyContinue)) { |
| 169 | + Write-Error "yek not found in PATH" |
| 170 | + Write-Host "PATH: $env:PATH" |
| 171 | + exit 1 |
| 172 | + } |
| 173 | + # Test version output |
| 174 | + $version = yek --version |
| 175 | + if (-not $?) { |
| 176 | + Write-Error "yek --version failed" |
| 177 | + exit 1 |
| 178 | + } |
| 179 | + Write-Host "Version: $version" |
| 180 | + # Create test file |
| 181 | + "test content" | Out-File -FilePath test.txt -Encoding utf8 |
| 182 | + # Test basic functionality |
| 183 | + yek test.txt |
| 184 | + if (-not $?) { |
| 185 | + Write-Error "yek failed to process test file" |
| 186 | + exit 1 |
| 187 | + } |
| 188 | + # Verify output exists |
| 189 | + if (-not (Test-Path repo-serialized/chunk-0.txt)) { |
| 190 | + Write-Error "Output file not found" |
| 191 | + Get-ChildItem repo-serialized -ErrorAction SilentlyContinue |
| 192 | + exit 1 |
| 193 | + } |
0 commit comments