Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions eng/pipelines/templates/jobs/ci.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ parameters:
type: number
- name: TestProxy
type: boolean
- name: InstallMsRust
type: boolean
default: false


jobs:
Expand Down Expand Up @@ -49,9 +52,42 @@ jobs:
paths:
- "/*"

- template: /eng/pipelines/templates/steps/use-rust.yml@self
parameters:
Toolchain: $(RustToolchainName)
- ${{ if eq(parameters.InstallMsRust, true) }}:
- pwsh: |
Move-Item $(Build.SourcesDirectory)/eng/templates/rust-toolchain.toml.template $(Build.SourcesDirectory)/rust-toolchain.toml -Force
displayName: 'Configure MS Rust rust-toolchain.toml'

- task: RustInstaller@1
inputs:
toolchainFeed: https://pkgs.dev.azure.com/azure-sdk/internal/_packaging/ms-rust-tools/nuget/v3/index.json
displayName: Install MS Rust toolchain

# TODO: Refactor this into a template used in use-rust.yml
- pwsh: |
$cargoHome = $env:CARGO_HOME
if (-not $cargoHome) { $cargoHome = ([System.IO.Path]::Combine($HOME, '.cargo')) }
New-Item -ItemType Directory -Force -Path $cargoHome | Out-Null

$configPath = ([System.IO.Path]::Combine($cargoHome, 'config.toml'))
Copy-Item `
-Path '$(Build.SourcesDirectory)/eng/templates/config.toml.template' `
-Destination $configPath `
-Force

Write-Host "Wrote cargo config to $configPath"
Get-Content $configPath
Write-Host "##vso[task.setvariable variable=CargoConfigPath]$configPath"
displayName: Configure cargo to use the azure-sdk-for-rust feed

- task: CargoAuthenticate@0
displayName: Authenticate cargo to the azure-sdk-for-rust feed
inputs:
configFile: $(CargoConfigPath)

- ${{ else }}:
- template: /eng/pipelines/templates/steps/use-rust.yml@self
parameters:
Toolchain: $(RustToolchainName)

- template: /eng/pipelines/templates/steps/nuget-config.yml

Expand Down
16 changes: 16 additions & 0 deletions eng/pipelines/templates/stages/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ extends:
- ${{ parameters.AdditionalMatrixConfigs }}
MatrixFilters: ${{ parameters.MatrixFilters }}
MatrixReplace: ${{ parameters.MatrixReplace }}
- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
- template: /eng/pipelines/templates/jobs/ci.tests.yml
parameters:
UsePlatformContainer: false
OSName: linux
# ci.tests.yml splices this into `$[ ... ]`, so it must be an expression
# fragment (not a JSON literal). `format` builds the single-leg matrix JSON
# at runtime with the pool/image variables already resolved. Matrix keys
# become job variables, so RUSTUP_EXE points the eng scripts at msrustup.
Matrix: format('{{"Linux-MSRust":{{"OSVmImage":"{0}","Pool":"{1}","RustToolchainName":"stable","RUSTUP_EXE":"msrustup"}}}}', variables['LINUXVMIMAGE'], variables['LINUXPOOL'])
DependsOn: ''
CloudConfig: Public
ServiceDirectory: ${{ parameters.ServiceDirectory }}
TimeoutInMinutes: ${{ parameters.TestTimeoutInMinutes }}
TestProxy: ${{ parameters.TestProxy }}
InstallMsRust: true

# Run live tests for internal only, not public CI builds. This can be triggered manually via an `/azp run` comment.
- ${{ if and(not(and(eq(parameters.SkipPrValidation, true), eq(variables['Build.Reason'], 'Manual'))), eq(variables['System.TeamProject'], 'internal'), eq(parameters.RunLiveTests, 'true')) }}:
Expand Down
23 changes: 21 additions & 2 deletions eng/scripts/shared/Cargo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,34 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

function Get-RustupExecutable() {
# msrustup manages MS Rust toolchains outside of rustup's registry, so rustup
# cannot resolve a custom channel like 'ms-prod-1.95' from rust-toolchain.toml.
# Jobs using MS Rust set RUSTUP_EXE to 'msrustup' to route toolchain queries there.
if ($env:RUSTUP_EXE) {
return $env:RUSTUP_EXE
}

return 'rustup'
}

function Get-ActiveRustToolchain(
[string]$ExecutePath
) {
$activeToolchain = (Invoke-LoggedCommand "rustup show active-toolchain" -ExecutePath $ExecutePath | Select-Object -First 1).Trim()
$rustup = Get-RustupExecutable
$output = Invoke-LoggedCommand "$rustup show active-toolchain" -ExecutePath $ExecutePath

# msrustup prefixes its output with INFO lines, so take the first line that
# actually names a toolchain.
$activeToolchain = $output
| Where-Object { $_ -match '\S' -and $_ -notmatch '^\s*(INFO|WARN)\b' }
| Select-Object -First 1

if (!$activeToolchain) {
throw "Failed to determine the active Rust toolchain."
}

return ($activeToolchain -split '\s+')[0]
return ($activeToolchain.Trim() -split '\s+')[0]
}

function Get-ResolvedRustToolchain(
Expand Down
12 changes: 12 additions & 0 deletions eng/templates/rust-toolchain.toml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[toolchain]
channel = "ms-prod-1.95"
# msrustup resolves `components` as host components only. The host `rust-std` ships
# with the toolchain, and additional target std libs go in `targets`, so listing
# "rust-std" here fails with US.host_component_not_found.
components = [
"rustc",
"rustfmt",
"cargo",
"clippy",
"rust-analyzer",
]
Loading