docker/windows: make the powershell scripts more robust

Check the exit codes of various commands and fail
appropriatly upon error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-ci/-/merge_requests/392>
This commit is contained in:
Jordan Petridis 2021-01-27 07:16:23 +02:00
parent 1f0b3938af
commit 8f0481f19a
4 changed files with 84 additions and 9 deletions

View file

@ -1,6 +1,22 @@
$env:DEFAULT_BRANCH='master'
$env:VERSION='v17'
$env:VERSION='v18'
$env:tag ="registry.freedesktop.org/gstreamer/gst-ci/amd64/windows:$env:VERSION-$env:DEFAULT_BRANCH"
echo "Building $env:tag"
Get-Date
Write-Output "Building $env:tag"
docker build --build-arg DEFAULT_BRANCH=$env:DEFAULT_BRANCH -f Dockerfile -t $env:tag .
if (!$?) {
Write-Host "Failed to build docker image $env:tag"
Exit 1
}
# Get-Date
# Write-Output "Pushing $env:tag"
# docker push $env:tag
# if (!$?) {
# Write-Host "Failed to push docker image $env:tag"
# Exit 1
# }
Get-Date
Write-Output "Build Finished"

View file

@ -1,6 +1,20 @@
Write-Host "Installing Choco"
Get-Date
Write-Host "Installing Chocolatey"
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Write-Host "Installing Choco packages"
Import-Module "$env:ProgramData\chocolatey\helpers\chocolateyProfile.psm1"
Update-SessionEnvironment
Write-Host "Installing Chocolatey packages"
choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System'
$cmake_install = $?
choco install -y git --params "/NoAutoCrlf /NoCredentialManager /NoShellHereIntegration /NoGuiHereIntegration /NoShellIntegration"
$git_install = $?
choco install -y python3 git-lfs 7zip
$rest_installs = $?
if (!($cmake_install -and $git_install -and $rest_installs)) {
Write-Host "Failed to install some dependencies from choco"
Exit 1
}

View file

@ -4,29 +4,66 @@ $msvc_2017_url = 'https://aka.ms/vs/15/release/vs_buildtools.exe'
$msys2_url = 'https://github.com/msys2/msys2-installer/releases/download/2021-02-15/msys2-base-x86_64-20210215.tar.xz'
$msys_mingw_get_url = 'https://dotsrc.dl.osdn.net/osdn/mingw/68260/mingw-get-0.6.3-mingw32-pre-20170905-1-bin.tar.xz'
Write-Host "Installing VisualStudio"
Get-Date
Write-Host "Downloading Visual Studio 2017 build tools"
Invoke-WebRequest -Uri $msvc_2017_url -OutFile C:\vs_buildtools.exe
Start-Process C:\vs_buildtools.exe -ArgumentList '--quiet --wait --norestart --nocache --installPath C:\BuildTools --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended' -Wait
Get-Date
Write-Host "Installing Visual Studio 2017"
Start-Process -NoNewWindow -Wait C:\vs_buildtools.exe -ArgumentList '--wait --quiet --norestart --nocache --installPath C:\BuildTools --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended'
if (!$?) {
Write-Host "Failed to install Visual Studio tools"
Exit 1
}
Remove-Item C:\vs_buildtools.exe -Force
Get-Date
Write-Host "Downloading and extracting mingw-get for MSYS"
Invoke-WebRequest -Uri $msys_mingw_get_url -OutFile C:\mingw-get.tar.xz
7z e C:\mingw-get.tar.xz -o"C:\\"
$res1 = $?
7z x C:\mingw-get.tar -o"C:\\MinGW"
$res2 = $?
if (!($res1 -and $res2)) {
Write-Host "Failed to extract mingw-get"
Exit 1
}
Remove-Item C:\mingw-get.tar.xz -Force
Remove-Item C:\mingw-get.tar -Force
Get-Date
Write-Host "Installing MSYS for Cerbero into C:/MinGW using mingw-get"
Start-Process C:\MinGW\bin\mingw-get.exe -ArgumentList 'install msys-base mingw32-base mingw-developer-toolkit' -Wait
Start-Process -Wait C:\MinGW\bin\mingw-get.exe -ArgumentList 'install msys-base mingw32-base mingw-developer-toolkit'
if (!$?) {
Write-Host "Failed to install Msys for cerbero using MinGW"
Exit 1
}
Get-Date
Write-Host "Installing MSYS2 into C:/msys64"
Invoke-WebRequest -Uri $msys2_url -OutFile C:\msys2-x86_64.tar.xz
7z e C:\msys2-x86_64.tar.xz -o"C:\\"
$res1 = $?
7z x C:\msys2-x86_64.tar -o"C:\\"
$res2 = $?
if (!($res1 -and $res2)) {
Write-Host "Failed to extract msys2"
Exit 1
}
Remove-Item C:\msys2-x86_64.tar.xz -Force
Remove-Item C:\msys2-x86_64.tar -Force
Get-Date
Write-Host "Installing Meson"
pip install meson
pip3 install meson
if (!$?) {
Write-Host "Failed to install meson from pip"
Exit 1
}
Write-Host "Complete"
Write-Host "Toolchain Install Complete"

View file

@ -7,9 +7,17 @@
# Download gst-build and all its subprojects
git clone -b $env:DEFAULT_BRANCH https://gitlab.freedesktop.org/gstreamer/gst-build.git C:\gst-build
if (!$?) {
Write-Host "Failed to clone gst-build"
Exit 1
}
# download the subprojects to try and cache them
meson subprojects download --sourcedir C:\gst-build
if (!$?) {
Write-Host "Failed to download the subprojects"
Exit 1
}
# Remove files that will conflict with a fresh clone on the runner side
Remove-Item -Force 'C:/gst-build/subprojects/*.wrap'