From 3d6bfa3f5582d03df18b12dd565ea404f15e6099 Mon Sep 17 00:00:00 2001 From: Nashwan Azhari Date: Tue, 16 Nov 2021 17:08:02 +0200 Subject: [PATCH 1/2] Standardize cmdlet capitalization in Windows CI scripts. This patch standardizes the capitalization of PowerShell commandlets in the Windows CI setup script in accordance with general PowerShell best practices. Signed-off-by: Nashwan Azhari --- script/setup/prepare_env_windows.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/script/setup/prepare_env_windows.ps1 b/script/setup/prepare_env_windows.ps1 index d1b465e7f..2d89e07c1 100644 --- a/script/setup/prepare_env_windows.ps1 +++ b/script/setup/prepare_env_windows.ps1 @@ -2,17 +2,17 @@ $PACKAGES= @{ mingw = "10.2.0"; git = ""; golang = "1.17.3"; make = ""; nssm = "" } -write-host "Downloading chocolatey package" +Write-Host "Downloading chocolatey package" curl.exe -L "https://packages.chocolatey.org/chocolatey.0.10.15.nupkg" -o 'c:\choco.zip' Expand-Archive "c:\choco.zip" -DestinationPath "c:\choco" -write-host "Installing choco" +Write-Host "Installing choco" & "c:\choco\tools\chocolateyInstall.ps1" -write-host "Set choco.exe path." +Write-Host "Set choco.exe path." $env:PATH+=";C:\ProgramData\chocolatey\bin" -write-host "Install necessary packages" +Write-Host "Install necessary packages" foreach ($package in $PACKAGES.Keys) { $command = "choco.exe install $package --yes" @@ -23,12 +23,12 @@ foreach ($package in $PACKAGES.Keys) { Invoke-Expression $command } -write-host "Set up environment." +Write-Host "Set up environment." $path = ";c:\Program Files\Git\bin;c:\Program Files\Go\bin;c:\Users\azureuser\go\bin;c:\containerd\bin" $env:PATH+=$path -write-host $env:PATH +Write-Host $env:PATH [Environment]::SetEnvironmentVariable("PATH", $env:PATH, 'User') From 444ef2f6d772085d6da9fe7bacecab3a714b334e Mon Sep 17 00:00:00 2001 From: Nashwan Azhari Date: Tue, 16 Nov 2021 17:13:02 +0200 Subject: [PATCH 2/2] Generalize Windows CI setup script for any user. The current Windows CI setup script assumes it will always be run under the `azureuser` username. While this username is defined in the Windows CI GitHub action, the current version of the script both exposes us to a future risk of breaking should the CI action be changed, and is also unfriendly to `curl | sh`-ing it for quick test environment setups. This patch makes the Windows CI setup script work with any username provided they have administrative privileges. Signed-off-by: Nashwan Azhari --- script/setup/prepare_env_windows.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/script/setup/prepare_env_windows.ps1 b/script/setup/prepare_env_windows.ps1 index 2d89e07c1..254305921 100644 --- a/script/setup/prepare_env_windows.ps1 +++ b/script/setup/prepare_env_windows.ps1 @@ -25,7 +25,8 @@ foreach ($package in $PACKAGES.Keys) { Write-Host "Set up environment." -$path = ";c:\Program Files\Git\bin;c:\Program Files\Go\bin;c:\Users\azureuser\go\bin;c:\containerd\bin" +$userGoBin = "${env:HOME}\go\bin" +$path = ";c:\Program Files\Git\bin;c:\Program Files\Go\bin;${userGoBin};c:\containerd\bin" $env:PATH+=$path Write-Host $env:PATH @@ -42,4 +43,4 @@ go get -u github.com/jstemmer/go-junit-report $CRICTL_DOWNLOAD_URL="https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.21.0/crictl-v1.21.0-windows-amd64.tar.gz" curl.exe -L $CRICTL_DOWNLOAD_URL -o c:\crictl.tar.gz tar -xvf c:\crictl.tar.gz -mv crictl.exe c:\Users\azureuser\go\bin\crictl.exe # Move crictl somewhere in path +mv crictl.exe "${userGoBin}\crictl.exe" # Move crictl somewhere in path