Skip to content

Commit

Permalink
[CI] bump gvm version and use the binary (#24571)
Browse files Browse the repository at this point in the history
(cherry picked from commit 34e5c09)

# Conflicts:
#	.ci/scripts/install-go.sh
#	.ci/scripts/install-tools.bat
#	Vagrantfile
  • Loading branch information
v1v authored and mergify-bot committed Oct 27, 2021
1 parent 91a3029 commit 5c43873
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .ci/scripts/install-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ fi
echo "UNMET DEP: Installing Go"
mkdir -p "${HOME}/bin"

<<<<<<< HEAD
curl -sSLo "${GVM_CMD}" "https://github.com/andrewkroh/gvm/releases/download/v0.2.1/gvm-${ARCH}-amd64"
=======
curl -sSLo "${GVM_CMD}" "https://github.com/andrewkroh/gvm/releases/download/v0.3.0/gvm-${OS}-${GVM_ARCH_SUFFIX}"
>>>>>>> 34e5c09bd ([CI] bump gvm version and use the binary (#24571))
chmod +x "${GVM_CMD}"

gvm ${GO_VERSION}|cut -d ' ' -f 2|tr -d '\"' > ${PROPERTIES_FILE}
${GVM_CMD} "${GO_VERSION}" |cut -d ' ' -f 2|tr -d '\"' > ${PROPERTIES_FILE}

eval $(gvm ${GO_VERSION})
eval "$("${GVM_CMD}" "${GO_VERSION}")"
32 changes: 32 additions & 0 deletions .ci/scripts/install-tools.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,39 @@ IF ERRORLEVEL 1 (
choco install curl -y --no-progress --skipdownloadcache
)
mkdir %WORKSPACE%\bin
<<<<<<< HEAD
where /q gvm
=======

IF EXIST "%PROGRAMFILES(X86)%" (
REM Force the gvm installation.
SET GVM_BIN=gvm.exe
curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.3.0/gvm-windows-amd64.exe
IF ERRORLEVEL 1 (
REM gvm installation has failed.
exit /b 1
)
) ELSE (
REM Windows 7 workers got a broken gvm installation.
curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.3.0/gvm-windows-386.exe
IF ERRORLEVEL 1 (
REM gvm installation has failed.
exit /b 1
)
)

SET GVM_BIN=gvm.exe
WHERE /q %GVM_BIN%
%GVM_BIN% version

REM Install the given go version
%GVM_BIN% --debug install %GO_VERSION%

REM Configure the given go version
FOR /f "tokens=*" %%i IN ('"%GVM_BIN%" use %GO_VERSION% --format=batch') DO %%i

go env
>>>>>>> 34e5c09bd ([CI] bump gvm version and use the binary (#24571))
IF ERRORLEVEL 1 (
curl -sL -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.1/gvm-windows-amd64.exe
)
Expand Down
77 changes: 77 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ GO_VERSION = File.read(File.join(File.dirname(__FILE__), ".go-version")).strip

# Provisioning for Windows PowerShell
$winPsProvision = <<SCRIPT
<<<<<<< HEAD
echo 'Creating github.com\elastic in the GOPATH'
New-Item -itemtype directory -path "C:\\Gopath\\src\\github.com\\elastic" -force
echo "Symlinking C:\\Vagrant to C:\\Gopath\\src\\github.com\\elastic"
Expand Down Expand Up @@ -57,6 +58,78 @@ echo "Disable automatic updates"
$AUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
$AUSettings.NotificationLevel = 1
$AUSettings.Save()
=======
$gopath_beats = "C:\\Gopath\\src\\github.com\\elastic\\beats"
if (-Not (Test-Path $gopath_beats)) {
echo 'Creating github.com\\elastic in the GOPATH'
New-Item -itemtype directory -path "C:\\Gopath\\src\\github.com\\elastic" -force
echo "Symlinking C:\\Vagrant to C:\\Gopath\\src\\github.com\\elastic"
cmd /c mklink /d $gopath_beats \\\\vboxsvr\\vagrant
}
if (-Not (Get-Command "gvm" -ErrorAction SilentlyContinue)) {
echo "Installing gvm to manage go version"
[Net.ServicePointManager]::SecurityProtocol = "tls12"
Invoke-WebRequest -URI https://github.com/andrewkroh/gvm/releases/download/v0.3.0/gvm-windows-amd64.exe -Outfile C:\\Windows\\System32\\gvm.exe
C:\\Windows\\System32\\gvm.exe --format=powershell #{GO_VERSION} | Invoke-Expression
go version
echo "Configure Go environment variables"
[System.Environment]::SetEnvironmentVariable("GOPATH", "C:\\Gopath", [System.EnvironmentVariableTarget]::Machine)
[System.Environment]::SetEnvironmentVariable("GOROOT", "C:\\Users\\vagrant\\.gvm\\versions\\go#{GO_VERSION}.windows.amd64", [System.EnvironmentVariableTarget]::Machine)
[System.Environment]::SetEnvironmentVariable("PATH", "%GOROOT%\\bin;$env:PATH;C:\\Gopath\\bin", [System.EnvironmentVariableTarget]::Machine)
}
$shell_link = "$Home\\Desktop\\Beats Shell.lnk"
if (-Not (Test-Path $shell_link)) {
echo "Creating Beats Shell desktop shortcut"
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($shell_link)
$Shortcut.TargetPath = "powershell.exe"
$Shortcut.Arguments = "-noexit -command '$gopath_beats'"
$Shortcut.WorkingDirectory = $gopath_beats
$Shortcut.Save()
}
Try {
echo "Disabling automatic updates"
$AUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
$AUSettings.NotificationLevel = 1
$AUSettings.Save()
} Catch {
echo "Failed to disable automatic updates."
}
if (-Not (Get-Command "choco" -ErrorAction SilentlyContinue)) {
Set-ExecutionPolicy Bypass -Scope Process -Force
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
choco feature disable -n=showDownloadProgress
if (-Not (Get-Command "python" -ErrorAction SilentlyContinue)) {
echo "Installing python 3"
choco install python -y -r --version 3.8.2
refreshenv
$env:PATH = "$env:PATH;C:\\Python38;C:\\Python38\\Scripts"
}
echo "Updating pip"
python -m pip install --upgrade pip 2>&1 | %{ "$_" }
if (-Not (Get-Command "git" -ErrorAction SilentlyContinue)) {
echo "Installing git"
choco install git -y -r
}
if (-Not (Get-Command "gcc" -ErrorAction SilentlyContinue)) {
echo "Installing mingw (gcc)"
choco install mingw -y -r
}
echo "Setting PYTHON_ENV in VM to point to C:\\beats-python-env."
[System.Environment]::SetEnvironmentVariable("PYTHON_ENV", "C:\\beats-python-env", [System.EnvironmentVariableTarget]::Machine)
>>>>>>> 34e5c09bd ([CI] bump gvm version and use the binary (#24571))
SCRIPT

# Provisioning for Unix/Linux
Expand All @@ -73,7 +146,11 @@ def linuxGvmProvision(arch="amd64")
return <<SCRIPT
mkdir -p ~/bin
if [ ! -e "~/bin/gvm" ]; then
<<<<<<< HEAD
curl -sL -o ~/bin/gvm https://github.com/andrewkroh/gvm/releases/download/v0.1.0/gvm-linux-#{arch}
=======
curl -sL -o ~/bin/gvm https://github.com/andrewkroh/gvm/releases/download/v0.3.0/gvm-linux-#{arch}
>>>>>>> 34e5c09bd ([CI] bump gvm version and use the binary (#24571))
chmod +x ~/bin/gvm
~/bin/gvm #{GO_VERSION}
echo 'export GOPATH=$HOME/go' >> ~/.bash_profile
Expand Down

0 comments on commit 5c43873

Please sign in to comment.