From 7c350c4f48ef613d8655bd4ec556828059e507c7 Mon Sep 17 00:00:00 2001 From: twangboy Date: Mon, 4 Nov 2024 14:29:27 -0700 Subject: [PATCH] Don't start windows service in tests --- .github/workflows/test-windows.yml | 31 +++++++++++++++--------------- bootstrap-salt.ps1 | 19 +++++++----------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index ecc332c..aa7f315 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -48,24 +48,23 @@ jobs: - name: Install Pytest run: | - pip install -U pytest + pip install -r tests\requirements.txt + + - name: Get Version + run: | + # We need to get the version here and make it an environment variable + # It is used to install via bootstrap and in the test + # The version is in the instance name + $instance = "${{ matrix.instance }}" + $version = $instance -split "-",2 + if ( $version.Count -gt 1 ) { + $version = $version[1].Replace("-", ".") + } + Write-Output "SaltVersion=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: Bootstrap Salt run: | - . ./bootstrap-salt.ps1 -RunService $false - - - name: Set Environment Variables - run: | - $env:Path = "$env:Path;C:\Program Files\Salt Project\Salt" - $env:Instance = ${{ matrix.instance }} - Write-Output "Path:" - Write-Output $env:Path - Write-Output "Environment Variables" - Get-ChildItem Env: - - - name: Add Salt to Path - run: | - $env:Path = "$env:Path;C:\Program Files\Salt Project\Salt" + . .\bootstrap-salt.ps1 -RunService $false -Version $env:SaltVersion - name: Test Bootstrap run: | @@ -82,4 +81,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: exitstatus-${{ github.job }}-${{ matrix.instance }}-${{ inputs.distro-slug }} - path: exitstatus/ + path: exitstatus/ \ No newline at end of file diff --git a/bootstrap-salt.ps1 b/bootstrap-salt.ps1 index a20b670..1859abc 100644 --- a/bootstrap-salt.ps1 +++ b/bootstrap-salt.ps1 @@ -18,7 +18,7 @@ Specifies a particular version of the installer. .EXAMPLE - ./bootstrap-salt.ps1 -RunService false + ./bootstrap-salt.ps1 -RunService $false Specifies the salt-minion service to stop and be set to manual. Useful for testing locally from the command line with the --local switch @@ -28,7 +28,7 @@ installer values of host name for the minion id and "salt" for the master. .EXAMPLE - ./bootstrap-salt.ps1 -Minion minion-box -Master master-box -Version 3006.7 -RunService false + ./bootstrap-salt.ps1 -Minion minion-box -Master master-box -Version 3006.7 -RunService $false Specifies all the optional parameters in no particular order. .NOTES @@ -56,12 +56,11 @@ param( [String]$Version = "latest", [Parameter(Mandatory=$false, ValueFromPipeline=$True)] - [ValidateSet("true","false")] [Alias("s")] - # Boolean flag to start or stop the minion service. True will start the - # minion service. False will stop the minion service and set it to "manual". + # Boolean flag to start or stop the minion service. $true will start the + # minion service. $false will stop the minion service and set it to "manual". # The installer starts it by default. - [String]$RunService = "true", + [Bool]$RunService = $true, [Parameter(Mandatory=$false, ValueFromPipeline=$True)] [Alias("m")] @@ -331,16 +330,12 @@ Write-Verbose "apiurl: $ApiUrl" Write-Verbose "ConfDir: $ConfDir" Write-Verbose "RootDir: $RootDir" -if ($RunService.ToLower() -eq "true") { +if ($RunService) { Write-Verbose "Windows service will be set to run" [bool]$RunService = $True -} elseif ($RunService.ToLower() -eq "false") { +} else { Write-Verbose "Windows service will be stopped and set to manual" [bool]$RunService = $False -} else { - # Param passed in wasn't clear so defaulting to true. - Write-Verbose "Windows service defaulting to run automatically" - [bool]$RunService = $True } #===============================================================================