Skip to content

Commit 12a5faf

Browse files
authored
Merge pull request #1059 from SteveL-MSFT/rust-feed
Update the release pipeline
2 parents 0a65344 + 918c28b commit 12a5faf

File tree

6 files changed

+86
-44
lines changed

6 files changed

+86
-44
lines changed

.cargo/config.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-arg
1919
[source.crates-io]
2020
replace-with = "POWERSHELL"
2121

22-
[target.aarch64-unknown-linux-gnu]
23-
linker = "aarch64-linux-gnu-gcc"
22+
#[target.aarch64-unknown-linux-gnu]
23+
#linker = "aarch64-linux-gnu-gcc"
2424

25-
[target.aarch64-unknown-linux-musl]
26-
linker = "aarch64-linux-musl-gcc"
25+
#[target.aarch64-unknown-linux-musl]
26+
#linker = "aarch64-linux-musl-gcc"

.pipelines/DSC-Official.yml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,25 @@ pr:
77
- onebranch
88
- release/v*
99

10+
parameters:
11+
- name: OfficialBuild
12+
type: boolean
13+
default: false
14+
1015
variables:
11-
BuildConfiguration: 'release'
12-
PackageRoot: '$(System.ArtifactsDirectory)/Packages'
13-
WindowsContainerImage: 'onebranch.azurecr.io/windows/ltsc2022/vse2022:latest'
14-
Codeql.TSAEnabled: true
16+
- name: BuildConfiguration
17+
value: 'release'
18+
- name: PackageRoot
19+
value: '$(System.ArtifactsDirectory)/Packages'
20+
- name: WindowsContainerImage
21+
value: 'onebranch.azurecr.io/windows/ltsc2022/vse2022:latest'
22+
- name: Codeql.TSAEnabled
23+
value: true
24+
- name: templateFile
25+
value: ${{ iif ( parameters.OfficialBuild, 'v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates', 'v2/OneBranch.NonOfficial.CrossPlat.yml@onebranchTemplates' ) }}
26+
- group: DSC-Rust.SDK
27+
- name: officialBuild
28+
value: ${{ parameters.OfficialBuild }}
1529

1630
resources:
1731
repositories:
@@ -21,7 +35,7 @@ resources:
2135
ref: refs/heads/main
2236

2337
extends:
24-
template: v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates
38+
template: ${{ variables.templateFile }}
2539
parameters:
2640
featureFlags:
2741
WindowsHostVersion:
@@ -78,7 +92,7 @@ extends:
7892
- task: AzureCLI@2
7993
displayName: Get Az Token
8094
inputs:
81-
azureSubscription: az-blob-cicd-infra
95+
azureSubscription: PowerShell-CICD-Feed-Access
8296
scriptType: pscore
8397
scriptLocation: inlineScript
8498
inlineScript: |
@@ -105,14 +119,16 @@ extends:
105119
buildName: x86_64-pc-windows-msvc
106120
signSrcPath: '$(signSrcPath)'
107121
PackageRoot: '$(PackageRoot)'
108-
token: '$(AzToken)'
122+
aztoken: '$(AzToken)'
123+
rustSDK: '$(Rust.SDK)'
109124

110125
- job: BuildWin_arm64
111126
dependsOn: SetPackageVersion
112127
variables:
113128
ob_sdl_tsa_configFile: '$(Build.SourcesDirectory)\DSC\.config\tsaoptions.json'
114129
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
115130
signSrcPath: '$(Build.SourcesDirectory)\out'
131+
AzToken: $[ dependencies.SetPackageVersion.outputs['AzToken'] ]
116132
ob_sdl_sbom_enabled: true
117133
ob_signing_setup_enabled: true
118134
ob_sdl_codeql_compiled_enabled: true
@@ -124,7 +140,8 @@ extends:
124140
buildName: aarch64-pc-windows-msvc
125141
signSrcPath: '$(signSrcPath)'
126142
PackageRoot: '$(PackageRoot)'
127-
token: '$(AzToken)'
143+
aztoken: '$(AzToken)'
144+
rustSDK: '$(Rust.SDK)'
128145

129146
- job: CreateMsixBundle
130147
dependsOn:
@@ -162,6 +179,7 @@ extends:
162179
condition: succeeded()
163180
164181
- job: SignMsixBundle
182+
condition: and(succeeded(), eq(variables.officialBuild, true))
165183
dependsOn: CreateMsixBundle
166184
variables:
167185
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
@@ -208,15 +226,15 @@ extends:
208226
- task: RustInstaller@1
209227
inputs:
210228
rustVersion: ms-stable
211-
toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
229+
toolchainFeed: $(Rust.SDK)
212230
additionalTargets: x86_64-unknown-linux-musl
213231
displayName: Install Rust
214232
env:
215233
ob_restore_phase: true
216234
- pwsh: |
217235
apt update
218236
apt -y install musl-tools
219-
$header = "Bearer $accessToken"
237+
$header = "Bearer $(AzToken)"
220238
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
221239
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
222240
./build.ps1 -Release -Architecture x86_64-unknown-linux-musl
@@ -243,15 +261,15 @@ extends:
243261
- task: RustInstaller@1
244262
inputs:
245263
rustVersion: ms-stable
246-
toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
264+
toolchainFeed: $(Rust.SDK)
247265
additionalTargets: aarch64-unknown-linux-musl
248266
displayName: Install Rust
249267
env:
250268
ob_restore_phase: true
251269
- task: AzureCLI@2
252270
displayName: Azure CLI
253271
inputs:
254-
azureSubscription: az-blob-cicd-infra
272+
azureSubscription: PowerShell-CICD-Feed-Access
255273
scriptType: pscore
256274
scriptLocation: inlineScript
257275
inlineScript: |
@@ -264,14 +282,15 @@ extends:
264282
apt -y install clang
265283
apt -y install llvm
266284
apt -y install musl-tools
267-
apt -y install gcc-multilib
285+
apt -y install musl-gcc
286+
#apt -y install gcc-multilib
268287
apt -y install libssl-dev
269288
apt -y install pkg-config
270289
msrustup default stable-aarch64-unknown-linux-musl
271290
if ((openssl version -d) -match 'OPENSSLDIR: "(?<dir>.*?)"') {
272291
$env:OPENSSL_LIB_DIR = $matches['dir']
273292
}
274-
$header = "Bearer $accessToken"
293+
$header = "Bearer $(AzToken)"
275294
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
276295
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
277296
./build.ps1 -Release -Architecture aarch64-unknown-linux-musl
@@ -302,23 +321,24 @@ extends:
302321
- task: RustInstaller@1
303322
inputs:
304323
rustVersion: ms-stable
305-
toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
324+
toolchainFeed: $(Rust.SDK)
306325
additionalTargets: $(buildName)
307326
displayName: Install Rust
308327
env:
309328
ob_restore_phase: true
310329
- task: AzureCLI@2
311330
displayName: Azure CLI
312331
inputs:
313-
azureSubscription: az-blob-cicd-infra
332+
azureSubscription: PowerShell-CICD-Feed-Access
314333
scriptType: pscore
315334
scriptLocation: inlineScript
316335
inlineScript: |
317336
az account show
318337
- pwsh: |
319-
$header = "Bearer $accessToken"
338+
$header = "Bearer $(AzToken)"
320339
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
321340
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
341+
Write-Verbose -Verbose "Building for $(buildName)"
322342
./build.ps1 -Release -Architecture $(buildName)
323343
./build.ps1 -PackageType tgz -Architecture $(buildName) -Release
324344
Copy-Item ./bin/*.tar.gz "$(ob_outputDirectory)"

.pipelines/DSC-Windows.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ parameters:
88
- name: BuildConfiguration
99
type: string
1010
default: Release
11-
- name: token
11+
- name: aztoken
12+
type: string
13+
- name: RustSDK
1214
type: string
1315

1416
steps:
@@ -31,13 +33,13 @@ steps:
3133
- task: RustInstaller@1
3234
inputs:
3335
rustVersion: ms-stable
34-
toolchainFeed: https://pkgs.dev.azure.com/mscodehub/Rust/_packaging/Rust/nuget/v3/index.json
36+
toolchainFeed: ${{ parameters.RustSDK }}
3537
additionalTargets: ${{ parameters.buildName }}
3638
displayName: Install Rust
3739
env:
3840
ob_restore_phase: true
3941
- pwsh: |
40-
$header = "Bearer ${ parameters.token }"
42+
$header = "Bearer ${{ parameters.aztoken }}"
4143
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
4244
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
4345
Set-Location "$(Build.SourcesDirectory)/DSC"
@@ -47,6 +49,7 @@ steps:
4749
}
4850
$env:PATH += ";$LLVMBIN"
4951
write-verbose -verbose (gcm clang.exe | out-string)
52+
Write-Verbose -Verbose "Building for ${{ parameters.buildName }}"
5053
./build.ps1 -Release -Architecture ${{ parameters.buildName }} -SkipLinkCheck
5154
displayName: 'Build ${{ parameters.buildName }}'
5255
env:

build.ps1

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ param(
2525

2626
$env:RUSTC_LOG=$null
2727
$env:RUSTFLAGS='-Dwarnings'
28+
$usingADO = ($null -ne $env:TF_BUILD)
2829

2930
trap {
3031
Write-Error "An error occurred: $($_ | Out-String)"
@@ -155,6 +156,7 @@ function Find-LinkExe {
155156

156157
$channel = 'stable'
157158
if ($null -ne (Get-Command msrustup -CommandType Application -ErrorAction Ignore)) {
159+
Write-Verbose -Verbose "Using msrustup"
158160
$rustup = 'msrustup'
159161
$channel = 'ms-stable'
160162
if ($architecture -eq 'current') {
@@ -170,7 +172,7 @@ if ($null -ne $packageType) {
170172
$SkipBuild = $true
171173
} else {
172174
## Test if Rust is installed
173-
if (!(Get-Command 'cargo' -ErrorAction Ignore)) {
175+
if (!$usingADO -and !(Get-Command 'cargo' -ErrorAction Ignore)) {
174176
Write-Verbose -Verbose "Rust not found, installing..."
175177
if (!$IsWindows) {
176178
curl https://sh.rustup.rs -sSf | sh -s -- -y
@@ -183,15 +185,22 @@ if ($null -ne $packageType) {
183185
$env:PATH += ";$env:USERPROFILE\.cargo\bin"
184186
Remove-Item temp:/rustup-init.exe -ErrorAction Ignore
185187
}
188+
if ($LASTEXITCODE -ne 0) {
189+
throw "Failed to install Rust"
190+
}
186191
}
187-
else {
192+
elseif (!$usingADO) {
188193
Write-Verbose -Verbose "Rust found, updating..."
189194
& $rustup update
190195
}
191196

192-
$BuildToolsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC"
197+
if ($IsWindows) {
198+
$BuildToolsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC"
199+
}
193200

194-
& $rustup default stable
201+
if (!$usingADO) {
202+
& $rustup default stable
203+
}
195204

196205
## Test if Node is installed
197206
## Skipping upgrade as users may have a specific version they want to use
@@ -212,6 +221,18 @@ if ($null -ne $packageType) {
212221
Write-Warning "winget not found, please install Node.js manually"
213222
}
214223
}
224+
if ($LASTEXITCODE -ne 0) {
225+
throw "Failed to install Node.js"
226+
}
227+
}
228+
229+
## Test if tree-sitter is installed
230+
if ($null -eq (Get-Command tree-sitter -ErrorAction Ignore)) {
231+
Write-Verbose -Verbose "tree-sitter not found, installing..."
232+
cargo install tree-sitter-cli --config .cargo/config.toml
233+
if ($LASTEXITCODE -ne 0) {
234+
throw "Failed to install tree-sitter-cli"
235+
}
215236
}
216237
}
217238

@@ -260,7 +281,7 @@ else {
260281
}
261282

262283
if (!$SkipBuild) {
263-
if ($architecture -ne 'Current') {
284+
if ($architecture -ne 'Current' -and !$usingADO) {
264285
& $rustup target add --toolchain $channel $architecture
265286
}
266287

@@ -309,6 +330,7 @@ if (!$SkipBuild) {
309330

310331
# projects are in dependency order
311332
$projects = @(
333+
".",
312334
"tree-sitter-dscexpression",
313335
"tree-sitter-ssh-server-config",
314336
"security_context_lib",
@@ -345,9 +367,10 @@ if (!$SkipBuild) {
345367
$failed = $false
346368
foreach ($project in $projects) {
347369
## Build format_json
348-
Write-Host -ForegroundColor Cyan "Building $project ... for $architecture"
370+
Write-Host -ForegroundColor Cyan "Building '$project' for $architecture"
349371
try {
350372
Push-Location "$PSScriptRoot/$project" -ErrorAction Stop
373+
Write-Verbose -Verbose "Current directory is $(Get-Location)"
351374

352375
# check if the project is either tree-sitter-dscexpression or tree-sitter-ssh-server-config
353376
if (($project -eq 'tree-sitter-dscexpression') -or ($project -eq 'tree-sitter-ssh-server-config')) {
@@ -357,12 +380,13 @@ if (!$SkipBuild) {
357380
else {
358381
if ($Audit) {
359382
if ($null -eq (Get-Command cargo-audit -ErrorAction Ignore)) {
360-
cargo install cargo-audit --features=fix
383+
cargo install cargo-audit --features=fix --config .cargo/config.toml
361384
}
362385

363386
cargo audit fix
364387
}
365388

389+
Write-Verbose -Verbose "Running build.ps1 for $project"
366390
./build.ps1
367391
}
368392
}
@@ -389,7 +413,7 @@ if (!$SkipBuild) {
389413
else {
390414
if ($Audit) {
391415
if ($null -eq (Get-Command cargo-audit -ErrorAction Ignore)) {
392-
cargo install cargo-audit --features=fix
416+
cargo install cargo-audit --features=fix --config .cargo/config.toml
393417
}
394418

395419
cargo audit fix
@@ -399,12 +423,14 @@ if (!$SkipBuild) {
399423
cargo clean
400424
}
401425

426+
Write-Verbose -Verbose "Building $project"
402427
cargo build @flags
403428
}
404429
}
405430
}
406431

407-
if ($LASTEXITCODE -ne 0) {
432+
if ($null -ne $LASTEXITCODE -and $LASTEXITCODE -ne 0) {
433+
Write-Error "Last exit code is $LASTEXITCODE, build failed for '$project'"
408434
$failed = $true
409435
break
410436
}
@@ -453,7 +479,10 @@ if (!$SkipBuild) {
453479
}
454480
}
455481
}
456-
482+
} catch {
483+
Write-Error "Failed to build $project : $($_ | Out-String)"
484+
$failed = $true
485+
break
457486
} finally {
458487
Pop-Location
459488
}
@@ -499,8 +528,6 @@ if (!$Clippy -and !$SkipBuild) {
499528

500529
if ($Test) {
501530
$failed = $false
502-
503-
$usingADO = ($null -ne $env:TF_BUILD)
504531
$repository = 'PSGallery'
505532

506533
if ($usingADO) {

tree-sitter-dscexpression/build.ps1

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ function Invoke-NativeCommand($cmd) {
1414

1515
$env:TREE_SITTER_VERBOSE=1
1616

17-
if ($null -eq (Get-Command tree-sitter -ErrorAction Ignore)) {
18-
cargo install tree-sitter-cli
19-
}
20-
2117
Invoke-NativeCommand 'tree-sitter init --update'
2218
Invoke-NativeCommand 'tree-sitter generate --build'
2319
Invoke-NativeCommand 'tree-sitter test'

tree-sitter-ssh-server-config/build.ps1

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ function Invoke-NativeCommand($cmd) {
99

1010
$env:TREE_SITTER_VERBOSE=1
1111

12-
if ($null -eq (Get-Command tree-sitter -ErrorAction Ignore)) {
13-
cargo install tree-sitter-cli
14-
}
15-
1612
Invoke-NativeCommand 'tree-sitter init --update'
1713
Invoke-NativeCommand 'tree-sitter generate --build'
1814
Invoke-NativeCommand 'tree-sitter test'

0 commit comments

Comments
 (0)