Skip to content

Commit 4ef90ab

Browse files
committed
Merge branch 'ps/gitlab-ci-windows' into seen
Wean the Windows builds in GitLab CI procedure away from (unfortunately unreliable) Chocolatey to install dependencies. * ps/gitlab-ci-windows: gitlab-ci: migrate Windows builds away from Chocolatey
2 parents 101d86d + 0e7b51f commit 4ef90ab

2 files changed

Lines changed: 63 additions & 3 deletions

File tree

.gitlab-ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,16 @@ test:mingw64:
168168
TEST_OUTPUT_DIRECTORY: "C:/Git-Test"
169169
tags:
170170
- saas-windows-medium-amd64
171+
cache:
172+
key:
173+
files:
174+
- ci/install-dependencies.ps1
175+
paths:
176+
- .dependencies
171177
before_script:
172178
- *windows_before_script
173-
- choco install -y git meson ninja rust-ms
174-
- Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
175-
- refreshenv
179+
- ./ci/install-dependencies.ps1
180+
- $env:Path = "C:\Meson;C:\Rust\bin;$env:Path"
176181
- New-Item -Path $env:TEST_OUTPUT_DIRECTORY -ItemType Directory
177182

178183
build:msvc-meson:

ci/install-dependencies.ps1

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
param(
2+
[string]$DownloadDirectory = '.dependencies'
3+
)
4+
5+
$ErrorActionPreference = 'Stop'
6+
$ProgressPreference = 'SilentlyContinue'
7+
8+
$GitVersion = '2.54.0.windows.1'
9+
$MesonVersion = '1.11.0'
10+
$RustVersion = '1.96.0'
11+
12+
New-Item -Path $DownloadDirectory -ItemType Directory -Force | Out-Null
13+
New-Item -Path .git/info -ItemType Directory -Force | Out-Null
14+
New-Item -Path .git/info/exclude -ItemType File -Force | Out-Null
15+
Add-Content -Path .git/info/exclude -Value "/$DownloadDirectory"
16+
17+
function Get-Installer {
18+
param(
19+
[Parameter(Mandatory = $true)][string]$Name,
20+
[Parameter(Mandatory = $true)][string]$Url
21+
)
22+
23+
$path = Join-Path $DownloadDirectory $Name
24+
if (-not (Test-Path $path)) {
25+
Write-Host "Downloading $Url"
26+
Invoke-WebRequest $Url -OutFile $path -TimeoutSec 300
27+
}
28+
return $path
29+
}
30+
31+
function Invoke-Installer {
32+
param(
33+
[Parameter(Mandatory = $true)][string]$FilePath,
34+
[Parameter(Mandatory = $true)][string[]]$ArgumentList
35+
)
36+
37+
Write-Host "Running $FilePath $($ArgumentList -join ' ')"
38+
$process = Start-Process -Wait -PassThru -FilePath $FilePath -ArgumentList $ArgumentList
39+
if ($process.ExitCode -ne 0) {
40+
throw "$FilePath failed with exit code $($process.ExitCode)"
41+
}
42+
}
43+
44+
$gitAssetVersion = $GitVersion -replace '\.windows\.\d+$', ''
45+
$gitInstaller = Get-Installer "Git-Installer.exe" `
46+
"https://github.com/git-for-windows/git/releases/download/v$GitVersion/PortableGit-$gitAssetVersion-64-bit.7z.exe"
47+
Invoke-Installer $gitInstaller @('-y', '-o"C:\Program Files\Git"')
48+
49+
$mesonMsi = Get-Installer "meson.msi" `
50+
"https://github.com/mesonbuild/meson/releases/download/$MesonVersion/meson-$MesonVersion-64.msi"
51+
Invoke-Installer msiexec.exe @('/i', $mesonMsi, 'INSTALLDIR=C:\Meson', '/quiet', '/norestart')
52+
53+
$rustMsi = Get-Installer "rust.msi" `
54+
"https://static.rust-lang.org/dist/rust-$RustVersion-x86_64-pc-windows-msvc.msi"
55+
Invoke-Installer msiexec.exe @('/i', $rustMsi, 'INSTALLDIR=C:\Rust', 'ADDLOCAL=Rustc,Cargo,Std', '/quiet', '/norestart')

0 commit comments

Comments
 (0)