Windows tests on self-hosted runners (#29764)
Windows self-hosted runners Release Notes: - N/A --------- Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-authored-by: Junkui Zhang <364772080@qq.com>
This commit is contained in:
parent
701fa4daa8
commit
1f457169ba
5 changed files with 105 additions and 99 deletions
22
script/clear-target-dir-if-larger-than.ps1
Normal file
22
script/clear-target-dir-if-larger-than.ps1
Normal file
|
@ -0,0 +1,22 @@
|
|||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[int]$MAX_SIZE_IN_GB
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$PSNativeCommandUseErrorActionPreference = $true
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
|
||||
if (-Not (Test-Path -Path "target")) {
|
||||
Write-Host "target directory does not exist yet"
|
||||
exit 0
|
||||
}
|
||||
|
||||
$current_size_gb = (Get-ChildItem -Recurse -Force -File -Path "target" | Measure-Object -Property Length -Sum).Sum / 1GB
|
||||
|
||||
Write-Host "target directory size: ${current_size_gb}GB. max size: ${MAX_SIZE_IN_GB}GB"
|
||||
|
||||
if ($current_size_gb -gt $MAX_SIZE_IN_GB) {
|
||||
Write-Host "clearing target directory"
|
||||
Remove-Item -Recurse -Force -Path "target\*"
|
||||
}
|
|
@ -1,21 +1,32 @@
|
|||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Write-Host "Your PATH entries:"
|
||||
$env:Path -split ";" | ForEach-Object { Write-Host " $_" }
|
||||
|
||||
$needAddWorkspace = $false
|
||||
if ($args -notcontains "-p" -and $args -notcontains "--package") {
|
||||
if ($args -notcontains "-p" -and $args -notcontains "--package")
|
||||
{
|
||||
$needAddWorkspace = $true
|
||||
}
|
||||
|
||||
# https://stackoverflow.com/questions/41324882/how-to-run-a-powershell-script-with-verbose-output/70020655#70020655
|
||||
Set-PSDebug -Trace 2
|
||||
# Set-PSDebug -Trace 2
|
||||
|
||||
$Cargo = $env:CARGO
|
||||
if (-not $Cargo) {
|
||||
if ($env:CARGO)
|
||||
{
|
||||
$Cargo = $env:CARGO
|
||||
} elseif (Get-Command "cargo" -ErrorAction SilentlyContinue)
|
||||
{
|
||||
$Cargo = "cargo"
|
||||
} else
|
||||
{
|
||||
Write-Error "Could not find cargo in path." -ErrorAction Stop
|
||||
}
|
||||
|
||||
if ($needAddWorkspace) {
|
||||
if ($needAddWorkspace)
|
||||
{
|
||||
& $Cargo clippy @args --workspace --release --all-targets --all-features -- --deny warnings
|
||||
}
|
||||
else {
|
||||
} else
|
||||
{
|
||||
& $Cargo clippy @args --release --all-targets --all-features -- --deny warnings
|
||||
}
|
||||
|
|
39
script/install-rustup.ps1
Normal file
39
script/install-rustup.ps1
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Checks if cargo is in the user's path or in default install path
|
||||
# If not, download with rustup-installer (which respects CARGO_HOME / RUSTUP_HOME)
|
||||
|
||||
# Like 'set -e' in bash
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$cargoHome = if ($env:CARGO_HOME) { $env:CARGO_HOME } else { "$env:USERPROFILE\.cargo" }
|
||||
$rustupPath = "$cargoHome\bin\rustup.exe"
|
||||
$cargoPath = "$cargoHome\bin\cargo.exe"
|
||||
|
||||
# Check if cargo is already available in path
|
||||
if (Get-Command cargo -ErrorAction SilentlyContinue)
|
||||
{
|
||||
cargo --version
|
||||
exit
|
||||
}
|
||||
# Check if rustup and cargo are available in CARGO_HOME
|
||||
elseif (-not ((Test-Path $rustupPath) -and (Test-Path $cargoPath))) {
|
||||
Write-Output "Rustup or Cargo not found in $cargoHome, installing..."
|
||||
|
||||
$tempDir = [System.IO.Path]::GetTempPath()
|
||||
|
||||
# Download and install rustup
|
||||
$RustupInitPath = "$tempDir\rustup-init.exe"
|
||||
Write-Output "Downloading rustup installer..."
|
||||
Invoke-WebRequest `
|
||||
-OutFile $RustupInitPath `
|
||||
-Uri https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe
|
||||
|
||||
Write-Output "Installing rustup..."
|
||||
& $RustupInitPath -y --default-toolchain none
|
||||
Remove-Item -Force $RustupInitPath
|
||||
|
||||
Write-Output "Rust installation complete."
|
||||
# This is necessary
|
||||
}
|
||||
|
||||
& $rustupPath --version
|
||||
& $cargoPath --version
|
Loading…
Add table
Add a link
Reference in a new issue