|
| 1 | +name: Cloudbase-Init - build and functionally test MSI |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + runs-on: ${{ matrix.os }} |
| 8 | + strategy: |
| 9 | + max-parallel: 100 |
| 10 | + matrix: |
| 11 | + os: ['windows-2022'] |
| 12 | + cbsinit_repo: ['https://github.com/cloudbase/cloudbase-init'] |
| 13 | + cbsinit_branch: ['master'] |
| 14 | + python_version: ['3.13_13'] |
| 15 | + platform: ['x64'] |
| 16 | + cloud: [openstack] |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + - name: Add msbuild to PATH |
| 21 | + uses: microsoft/setup-msbuild@v2 |
| 22 | + - name: Build msi |
| 23 | + shell: cmd |
| 24 | + run: |
| 25 | + powershell.exe .\BuildAutomation\BuildCloudbaseInitSetup.ps1 ^ |
| 26 | + -ClonePullInstallerRepo:$false ^ |
| 27 | + -PythonVersion ${{ matrix.python_version }} ^ |
| 28 | + -Platform ${{ matrix.platform }} ^ |
| 29 | + -VCVars "automatic" ^ |
| 30 | + -VSRedistDir "''" ^ |
| 31 | + -CloudbaseInitRepoUrl ${{ matrix.cbsinit_repo }} ^ |
| 32 | + -CloudbaseInitRepoBranch ${{ matrix.cbsinit_branch }} |
| 33 | + - uses: actions/upload-artifact@v4 |
| 34 | + with: |
| 35 | + name: "CloudbaseInit_${{ matrix.platform }}_${{ matrix.os }}_MSI_${{ matrix.cbsinit_branch }}" |
| 36 | + path: 'CloudbaseInitSetup/bin/release/${{ matrix.platform }}/CloudbaseInitSetup.msi' |
| 37 | + - name: Download external dependencies |
| 38 | + shell: powershell |
| 39 | + run: | |
| 40 | + try { git clone "https://github.com/ader1990/cloudbase-init-test-resources-1" -b "add_openstack_packet_check" cbs-test-res }catch{} |
| 41 | + pushd "cbs-test-res/${{ matrix.cloud }}" |
| 42 | + try { |
| 43 | + & "../bin/mkisofs.exe" -o "../../cloudbase-init-config-drive.iso" -ignore-error -ldots -allow-lowercase -allow-multidot -l -publisher "cbsl" -quiet -J -r -V "config-2" "cloudbase-init-metadata" 2>&1 | %{ "$_" } |
| 44 | + } catch {} |
| 45 | + popd |
| 46 | + - name: Install MSI and functionally test Cloudbase-Init |
| 47 | + shell: powershell |
| 48 | + run: | |
| 49 | + $Erroractionpreference = "Continue" |
| 50 | + $log = "install.log" |
| 51 | + touch $log |
| 52 | + $msiPath = (Resolve-Path "CloudbaseInitSetup/bin/release/${{ matrix.platform }}/CloudbaseInitSetup.msi").Path |
| 53 | + Write-Output $msiPath |
| 54 | + echo $msiPath |
| 55 | + $procMain = Start-Process "msiexec" "/i `"$msiPath`" /qn /l*! `"$log`"" -NoNewWindow -PassThru |
| 56 | + $procLog = Start-Process "powershell" "Get-Content -Path `"$log`" -Wait" -NoNewWindow -PassThru |
| 57 | + $procMain.WaitForExit() |
| 58 | + $procLog.Kill() |
| 59 | + Mount-DiskImage -ImagePath (Resolve-Path ./cloudbase-init-config-drive.iso) | Out-Null |
| 60 | + Get-PSDrive | Out-Null |
| 61 | + mkdir "./metadata" | Out-Null |
| 62 | + cp -recurse -force "$((Get-DiskImage (Resolve-Path './cloudbase-init-config-drive.iso') | Get-Volume).DriveLetter):\*" "./metadata"; |
| 63 | + if (Test-path ".\metadata\openstack\latest\network_data.json.template") { |
| 64 | + (Get-Content ".\metadata\openstack\latest\network_data.json.template").Replace("REPLACE_MAC_ADDRESS", ((Get-NetAdapter Ethernet).macaddress).Replace("-",":")) | Set-Content ".\metadata\openstack\latest\network_data.json" -Encoding Ascii |
| 65 | + } |
| 66 | + $pythonPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\python.exe" |
| 67 | + Write-Output "Python version:" |
| 68 | + & $pythonPath --version |
| 69 | + $cloudbaseInitPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\cloudbase-init.exe" |
| 70 | + $pipAuditPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\pip-audit.exe" |
| 71 | + if (!(Test-Path $pythonPath)) { |
| 72 | + $pythonPath = "C:\\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python\python.exe" |
| 73 | + $cloudbaseInitPath = "C:\\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\cloudbase-init.exe" |
| 74 | + $pipAuditPath = "C:\\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\pip-audit.exe" |
| 75 | + } |
| 76 | + Start-Process -FilePath $pythonPath -ArgumentList "-m http.server" -NoNewWindow -WorkingDirectory (Resolve-Path("./metadata")) 2>&1 >> http_server.log |
| 77 | + cd "cbs-test-res/${{ matrix.cloud }}/" |
| 78 | + try { |
| 79 | + $logs = & $cloudbaseInitPath --noreset_service_password --config-file ./cloudbase-init.conf |
| 80 | + } catch {} |
| 81 | + echo $logs |
| 82 | + $errors = $($logs | Where-Object {$_ -like "*error*"}) |
| 83 | + $pluginExecution = $($logs | Where-Object {$_ -like "*Plugins execution done*"}) |
| 84 | + if ($errors -or !$pluginExecution) { |
| 85 | + Write-Output $logs |
| 86 | + Write-Output "Errors found in the execution $($errors.Length)" |
| 87 | + Write-Output $errors |
| 88 | + $userPass501Err = "plugin 'SetUserPasswordPlugin' failed with error '501 Server Error: Unsupported method ('POST') for url" |
| 89 | + if ($errors.Length -gt 20 -and $errors.length -lt 34 -and $errors[0].indexOf($userPass501Err) -gt -1) { |
| 90 | + Write-Output "Expected errors" |
| 91 | + } else { |
| 92 | + Write-Output $("Unexpected error lines: " + $errors.Length + " and found: " + $errors[0].indexOf($userPass501Err)) |
| 93 | + exit 1 |
| 94 | + } |
| 95 | + } |
| 96 | + & $pythonPath -m pip install pip-audit |
| 97 | + $pipAuditLogs = & $pipAuditPath |
| 98 | + Write-Output "$pipAuditLogs" |
| 99 | + if ($LASTEXITCODE) { |
| 100 | + throw "pip audit failed" |
| 101 | + } |
0 commit comments