mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 22:05:17 +00:00
[Windows] Implement new directories hierarchy (#8616)
This commit is contained in:
committed by
GitHub
parent
84a7deae24
commit
d1f2c9a3be
43
images/windows/scripts/build/Install-Rust.ps1
Normal file
43
images/windows/scripts/build/Install-Rust.ps1
Normal file
@@ -0,0 +1,43 @@
|
||||
################################################################################
|
||||
## File: Install-Rust.ps1
|
||||
## Desc: Install Rust for Windows
|
||||
## Supply chain security: checksum validation for bootstrap, managed by rustup for workloads
|
||||
################################################################################
|
||||
|
||||
# Rust Env
|
||||
$env:RUSTUP_HOME = "C:\Users\Default\.rustup"
|
||||
$env:CARGO_HOME = "C:\Users\Default\.cargo"
|
||||
|
||||
# Download the latest rustup-init.exe for Windows x64
|
||||
# See https://rustup.rs/#
|
||||
$rustupPath = Start-DownloadWithRetry -Url "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe" -Name "rustup-init.exe"
|
||||
|
||||
#region Supply chain security
|
||||
$localFileHash = (Get-FileHash -Path (Join-Path ${env:TEMP} 'rustup-init.exe') -Algorithm SHA256).Hash
|
||||
$distributorFileHash = (Invoke-RestMethod -Uri 'https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe.sha256').Trim()
|
||||
|
||||
Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash
|
||||
#endregion
|
||||
|
||||
# Install Rust by running rustup-init.exe (disabling the confirmation prompt with -y)
|
||||
& $rustupPath -y --default-toolchain=stable --profile=minimal
|
||||
|
||||
# Add %USERPROFILE%\.cargo\bin to USER PATH
|
||||
Add-DefaultPathItem "%USERPROFILE%\.cargo\bin"
|
||||
# Add Rust binaries to the path
|
||||
$env:Path += ";$env:CARGO_HOME\bin"
|
||||
|
||||
# Add i686 target for building 32-bit binaries
|
||||
rustup target add i686-pc-windows-msvc
|
||||
|
||||
# Add target for building mingw-w64 binaries
|
||||
rustup target add x86_64-pc-windows-gnu
|
||||
|
||||
# Install common tools
|
||||
rustup component add rustfmt clippy
|
||||
cargo install --locked bindgen-cli cbindgen cargo-audit cargo-outdated
|
||||
|
||||
# Cleanup Cargo crates cache
|
||||
Remove-Item "${env:CARGO_HOME}\registry\*" -Recurse -Force
|
||||
|
||||
Invoke-PesterTests -TestFile "Rust"
|
||||
Reference in New Issue
Block a user