Skip to content

Commit 7e05d7b

Browse files
authored
Merge pull request #50 from ader1990/add_support_for_github_actions_build_with_utilsactions
Support github actions with Windows 10 SDK and VS 2022 (v142)
2 parents 2eab04b + d9e53bd commit 7e05d7b

11 files changed

Lines changed: 138 additions & 42 deletions

File tree

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+
}

BuildAutomation/BuildCloudbaseInitSetup.ps1

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ Param(
1010
[switch]$ClonePullInstallerRepo = $true,
1111
[string]$InstallerDir = $null,
1212
[string]$VSRedistDir = "${ENV:ProgramFiles(x86)}\Common Files\Merge Modules",
13-
[string]$SignTimestampUrl = "http://timestamp.digicert.com?alg=sha256"
13+
[string]$SignTimestampUrl = "http://timestamp.digicert.com?alg=sha256",
14+
[string]$VCVars="2019"
1415
)
1516

1617
$ErrorActionPreference = "Stop"
1718

1819
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
20+
$repoRootPath = split-path -parent $scriptPath
21+
1922
. "$scriptPath\BuildUtils.ps1"
2023

2124
$platformVCVarsRequired = "x86_amd64"
@@ -25,18 +28,18 @@ if ($platform -eq "x86") {
2528
$platformVCVarsRequired = "x86"
2629
}
2730

28-
SetVCVars "2019" $platformVCVarsRequired
31+
SetVCVars $VCVars $platformVCVarsRequired
2932

3033
# Needed for SSH
3134
$ENV:HOME = $ENV:USERPROFILE
3235

33-
$python_dir = "C:\Python_CloudbaseInit"
36+
$python_dir = Join-Path $repoRootPath "CloudbaseInitSetup\Python_CloudbaseInit"
37+
$basepath = Join-path $scriptPath "build\cloudbase-init"
3438

3539
$ENV:PATH = "$python_dir\;$python_dir\scripts;$ENV:PATH"
3640
$ENV:PATH += ";$ENV:ProgramFiles (x86)\Git\bin\"
3741
$ENV:PATH += ";$ENV:ProgramFiles\7-zip\"
3842

39-
$basepath = "C:\build\cloudbase-init"
4043
CheckDir $basepath
4144

4245
pushd .
@@ -164,13 +167,17 @@ try
164167

165168
$installer_sources_dir = join-path $cloudbaseInitInstallerDir "CloudbaseInitSetup"
166169

167-
if($platform -eq "x64")
168-
{
169-
copy "${VSRedistDir}\Microsoft_VC140_CRT_x64.msm" $installer_sources_dir
170-
}
171-
else
170+
171+
if ($VSRedistDir)
172172
{
173-
copy "${VSRedistDir}\Microsoft_VC140_CRT_x86.msm" $installer_sources_dir
173+
if($platform -eq "x64")
174+
{
175+
copy "${VSRedistDir}\Microsoft_VC140_CRT_x64.msm" $installer_sources_dir
176+
}
177+
else
178+
{
179+
copy "${VSRedistDir}\Microsoft_VC140_CRT_x86.msm" $installer_sources_dir
180+
}
174181
}
175182

176183
cd $cloudbaseInitInstallerDir

BuildAutomation/BuildUtils.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,25 @@ function PipInstall($package, $allow_dev=$false, $update=$false)
180180

181181
function SetVCVars($version="2019", $platform="x86_amd64") {
182182

183+
$preferedVersions = @("$version")
184+
if ($version -eq "automatic") {
185+
$preferedVersions = @("18", "2022", "2019", "2017")
186+
}
183187
$vsInstallTypes = @("Community", "Enterprise")
184188
$vsInstallArchTypes = @("$ENV:ProgramFiles (x86)", "$ENV:ProgramFiles")
185189
$vsInstallBuildFolder = $null
186190

187191
foreach ($vsInstallArchType in $vsInstallArchTypes) {
188192
foreach ($vsInstallType in $vsInstallTypes) {
189-
$vsInstallBuildFolderCheck = "${vsInstallArchType}\Microsoft Visual Studio\$version\${vsInstallType}\VC\Auxiliary\Build"
193+
foreach ($preferedVersion in $preferedVersions) {
194+
$vsInstallBuildFolderCheck = "${vsInstallArchType}\Microsoft Visual Studio\${preferedVersion}\${vsInstallType}\VC\Auxiliary\Build"
190195
if (Test-Path $vsInstallBuildFolderCheck) {
191196
$vsInstallBuildFolder = $vsInstallBuildFolderCheck
192197
break
193198
} else {
194199
Write-Host "${vsInstallBuildFolderCheck} does not exist"
195200
}
201+
}
196202
}
197203
}
198204
if ($vsInstallBuildFolder -eq $null) {
258 KB
Binary file not shown.
208 KB
Binary file not shown.

CloudbaseInitSetup/CloudbaseInitSetup.wixproj

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
2020
<OutputPath>bin\$(Configuration)\$(platform)\</OutputPath>
2121
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
22-
<DefineConstants>PythonSourcePath=C:\Python_CloudbaseInit;CarbonSourcePath=Carbon;Version=1.0.0.0;VersionStr=1.0.0.0</DefineConstants>
22+
<DefineConstants>PythonSourcePath=Python_CloudbaseInit;CarbonSourcePath=Carbon;Version=1.0.0.0;VersionStr=1.0.0.0</DefineConstants>
2323
</PropertyGroup>
2424
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
2525
<DefineConstants>Debug</DefineConstants>
2626
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
2727
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
2828
</PropertyGroup>
2929
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
30-
<DefineConstants>PythonSourcePath=C:\Python_CloudbaseInit;CarbonSourcePath=Carbon;Version=1.0.0.0;VersionStr=1.0.0.0</DefineConstants>
30+
<DefineConstants>PythonSourcePath=Python_CloudbaseInit;CarbonSourcePath=Carbon;Version=1.0.0.0;VersionStr=1.0.0.0</DefineConstants>
3131
<OutputPath>bin\$(Configuration)\$(platform)\</OutputPath>
3232
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
3333
</PropertyGroup>
@@ -259,12 +259,6 @@
259259
<Content Include="images\bannrbmp.bmp" />
260260
<Content Include="images\dlgbmp.bmp" />
261261
<Content Include="License.rtf" />
262-
<Content Include="Microsoft_VC100_CRT_x64.msm" />
263-
<Content Include="Microsoft_VC100_CRT_x86.msm" />
264-
<Content Include="Microsoft_VC90_CRT_x86.msm" />
265-
<Content Include="Microsoft_VC90_CRT_x86_x64.msm" />
266-
<Content Include="policy_9_0_Microsoft_VC90_CRT_x86.msm" />
267-
<Content Include="policy_9_0_Microsoft_VC90_CRT_x86_x64.msm" />
268262
<Content Include="Python.xslt" />
269263
<Content Include="SetSetupComplete.cmd" />
270264
<Content Include="Unattend.xml" />
@@ -309,10 +303,9 @@
309303
</ItemGroup>
310304
<Import Project="$(WixTargetsPath)" />
311305
<Target Name="BeforeBuild">
312-
<HeatDirectory DirectoryRefId="INSTALLDIR" OutputFile="Python_tmp.wxs" Directory="C:\Python_CloudbaseInit" ComponentGroupName="PythonComponentGroup" ToolPath="$(WixToolPath)" PreprocessorVariable="var.PythonSourcePath" GenerateGuidsNow="true" SuppressCom="true" SuppressRegistry="true" KeepEmptyDirectories="true" />
306+
<HeatDirectory DirectoryRefId="INSTALLDIR" OutputFile="Python_tmp.wxs" Directory="Python_CloudbaseInit" ComponentGroupName="PythonComponentGroup" ToolPath="$(WixToolPath)" PreprocessorVariable="var.PythonSourcePath" GenerateGuidsNow="true" SuppressCom="true" SuppressRegistry="true" KeepEmptyDirectories="true" RunAsSeparateProcess="true" />
313307
<XslTransformation XmlInputPaths="Python_tmp.wxs" XslInputPath="Python.xslt" OutputPaths="Python.wxs" Parameters="&lt;Parameter Name='platform' Value='$(Platform)'/&gt;" />
314-
<HeatDirectory DirectoryRefId="PowershellModules" OutputFile="Carbon.wxs" Directory="Carbon" ComponentGroupName="CarbonComponentGroup" ToolPath="$(WixToolPath)" PreprocessorVariable="var.CarbonSourcePath" GenerateGuidsNow="true" SuppressCom="true" SuppressRegistry="true" KeepEmptyDirectories="true" Transforms="Carbon.xslt">
315-
</HeatDirectory>
308+
<HeatDirectory DirectoryRefId="PowershellModules" OutputFile="Carbon.wxs" Directory="Carbon" ComponentGroupName="CarbonComponentGroup" ToolPath="$(WixToolPath)" PreprocessorVariable="var.CarbonSourcePath" GenerateGuidsNow="true" SuppressCom="true" SuppressRegistry="true" KeepEmptyDirectories="true" Transforms="Carbon.xslt" RunAsSeparateProcess="true" />
316309
</Target>
317310
<!--
318311
To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -322,4 +315,4 @@
322315
<Target Name="AfterBuild">
323316
</Target>
324317
-->
325-
</Project>
318+
</Project>

CloudbaseInitSetup/Product.wxs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
<ComponentRef Id="mtools" />
2828
<ComponentRef Id="SetSetupComplete" />
2929

30-
<Feature Id="VC140Redist" Title="Visual C++ 14.0 Runtime" AllowAdvertise="no" Display="hidden" Level="1">
31-
<MergeRef Id="VC140Redist" />
32-
</Feature>
33-
3430
<Feature Id="Carbon" Title="Carbon PowerShell Module" AllowAdvertise="no" Level="1" InstallDefault="followParent" Absent="allow"
3531
Description="Carbon is an open source PowerShell module with lots of features for deployment automation. More info: http://get-carbon.org/">
3632
<ComponentGroupRef Id="CarbonComponentGroup" />
@@ -161,17 +157,6 @@
161157
</DirectoryRef>
162158
</Fragment>
163159

164-
<Fragment>
165-
<DirectoryRef Id="TARGETDIR">
166-
<?if $(var.Platform) = x64 ?>
167-
<!-- TODO: use a variable to select the correct CRT version -->
168-
<Merge Id="VC140Redist" SourceFile="Microsoft_VC140_CRT_x64.msm" DiskId="1" Language="0" />
169-
<?else ?>
170-
<Merge Id="VC140Redist" SourceFile="Microsoft_VC140_CRT_x86.msm" DiskId="1" Language="0" />
171-
<?endif ?>
172-
</DirectoryRef>
173-
</Fragment>
174-
175160
<Fragment>
176161
<Component Id="ElevateUtils" Directory="BINFOLDER" Guid="{90A6F90D-34DF-4226-B368-0C2AA4F08BB8}" Win64="$(var.Win64)">
177162
<File Id="Elevate.exe" Source="Binaries\$(var.Platform)\Elevate.exe" KeyPath="yes" Checksum="yes" />

UtilsActions/MSIUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <iostream>
88
#include <fstream>
99
#include <sstream>
10+
#include <string>
1011
#include <exception>
1112

1213
using namespace std;

UtilsActions/MSIUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <string>
34
#include <vector>
45
#include <Ntstatus.h>
56
#include <LsaLookup.h>

UtilsActions/UtilsActions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <Ntsecapi.h>
99

10+
#include <string>
1011
#include <sstream>
1112
#include <algorithm>
1213

0 commit comments

Comments
 (0)