|
| 1 | +name: Test Chocolatey Package |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'packaging/chocolatey/**' |
| 7 | + - '.github/workflows/test-chocolatey.yml' |
| 8 | + push: |
| 9 | + branches: [main] |
| 10 | + paths: |
| 11 | + - 'packaging/chocolatey/**' |
| 12 | + - '.github/workflows/test-chocolatey.yml' |
| 13 | + |
| 14 | +jobs: |
| 15 | + test-chocolatey: |
| 16 | + runs-on: windows-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Set up Go |
| 21 | + uses: actions/setup-go@v5 |
| 22 | + with: |
| 23 | + go-version: '1.22' |
| 24 | + |
| 25 | + - name: Build binary for testing |
| 26 | + run: go build -o packaging/chocolatey/tools/cfl.exe ./cmd/cfl |
| 27 | + |
| 28 | + - name: Prepare test package |
| 29 | + shell: pwsh |
| 30 | + working-directory: packaging/chocolatey |
| 31 | + run: | |
| 32 | + # Replace placeholder version with test version (must not be prerelease) |
| 33 | + (Get-Content confluence-cli.nuspec) ` |
| 34 | + -replace '<version>0.0.0</version>', '<version>0.0.1</version>' | |
| 35 | + Set-Content confluence-cli.nuspec |
| 36 | +
|
| 37 | + # Create a simple install script that uses the local binary |
| 38 | + # (the real script downloads from GitHub, but we test structure here) |
| 39 | + @' |
| 40 | + $ErrorActionPreference = 'Stop' |
| 41 | + $toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition |
| 42 | +
|
| 43 | + # Binary is already in tools/ from CI build |
| 44 | + Write-Host "confluence-cli installed from local build for testing" |
| 45 | +
|
| 46 | + # Exclude non-executables from shimming |
| 47 | + New-Item "$toolsDir\LICENSE.ignore" -Type File -Force | Out-Null |
| 48 | + New-Item "$toolsDir\README.md.ignore" -Type File -Force | Out-Null |
| 49 | + '@ | Set-Content tools/chocolateyInstall.ps1 |
| 50 | +
|
| 51 | + - name: Pack Chocolatey package |
| 52 | + shell: pwsh |
| 53 | + working-directory: packaging/chocolatey |
| 54 | + run: choco pack |
| 55 | + |
| 56 | + - name: Install package locally |
| 57 | + shell: pwsh |
| 58 | + working-directory: packaging/chocolatey |
| 59 | + run: choco install confluence-cli -dv -s . --force |
| 60 | + |
| 61 | + - name: Verify installation |
| 62 | + shell: pwsh |
| 63 | + run: | |
| 64 | + Write-Host "Testing cfl --version..." |
| 65 | + cfl --version |
| 66 | + if ($LASTEXITCODE -ne 0) { |
| 67 | + Write-Error "cfl --version failed" |
| 68 | + exit 1 |
| 69 | + } |
| 70 | + Write-Host "cfl is working!" |
| 71 | +
|
| 72 | + - name: Test uninstall |
| 73 | + shell: pwsh |
| 74 | + run: | |
| 75 | + choco uninstall confluence-cli -y |
| 76 | +
|
| 77 | + # Verify cfl is no longer available |
| 78 | + $cflPath = Get-Command cfl -ErrorAction SilentlyContinue |
| 79 | + if ($cflPath) { |
| 80 | + Write-Error "cfl should not be available after uninstall" |
| 81 | + exit 1 |
| 82 | + } |
| 83 | + Write-Host "Uninstall successful!" |
0 commit comments