Skip to content

Commit 1fe9080

Browse files
authored
Don't nest the output package folders (Azure#2151)
* Don't nest the output package folders * Add json parsing to the cargo read-manifest call * Remove Invoke-LoggedCommand from cargo owners call * Regex escape the package path pattern
1 parent 0ef208b commit 1fe9080

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

eng/pipelines/templates/stages/archetype-rust-release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,14 @@ stages:
9393

9494
- task: PowerShell@2
9595
displayName: Publish Crate
96+
env:
97+
CARGO_REGISTRY_TOKEN: $(azure-sdk-cratesio-token)
9698
inputs:
9799
targetType: filePath
98100
filePath: $(Build.SourcesDirectory)/eng/scripts/Publish-Crates.ps1
99101
arguments: >
100102
-PackagesPath '$(Pipeline.Workspace)/drop'
101103
-CrateNames '${{artifact.name}}'
102-
-Token $(azure-sdk-cratesio-token)
103104
-AdditionalOwners 'heaths','hallipr'
104105
105106
# - job: CreateApiReview
@@ -158,10 +159,11 @@ stages:
158159

159160
- task: PowerShell@2
160161
displayName: Yank Crates
162+
env:
163+
CARGO_REGISTRY_TOKEN: $(azure-sdk-cratesio-token)
161164
inputs:
162165
targetType: filePath
163166
filePath: $(Build.SourcesDirectory)/eng/scripts/Yank-Crates.ps1
164167
arguments:
165168
-CrateNames '${{artifact.name}}'
166-
-PackagesPath '$(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}'
167-
-Token $(azure-sdk-cratesio-token)
169+
-PackageInfoDirectory '$(Pipeline.Workspace)/${{parameters.PipelineArtifactName}}/PackageInfo'

eng/scripts/Language-Settings.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ function Get-rust-AdditionalValidationPackagesFromPackageSet ($packagesWithChang
125125
[array]$serviceFiles = ($diff.ChangedFiles + $diff.DeletedFiles) | ForEach-Object { $_ -replace '\\', '/' } | Where-Object { $_ -match "^sdk/.+/" }
126126
# remove files that target any specific package
127127
foreach ($package in $allPackageProperties) {
128-
$serviceFiles = $serviceFiles | Where-Object { "$RepoRoot/$_" -notmatch "^$($package.DirectoryPath)/" }
128+
$packagePathPattern = "^$( [Regex]::Escape($package.DirectoryPath.Replace('\', '/')) )/"
129+
$serviceFiles = $serviceFiles | Where-Object { "$RepoRoot/$_".Replace('\', '/') -notmatch $packagePathPattern }
129130
}
130131

131132
$affectedServiceDirectories = $serviceFiles | ForEach-Object { $_ -replace '^sdk/(.+?)/.*', '$1' } | Sort-Object -Unique
@@ -144,7 +145,7 @@ function Get-rust-AdditionalValidationPackagesFromPackageSet ($packagesWithChang
144145

145146
function Get-rust-PackageInfoFromPackageFile([IO.FileInfo]$pkg, [string]$workingDirectory) {
146147
#$pkg will be a FileInfo object for the Cargo.toml file in a package artifact directory
147-
$package = cargo read-manifest --manifest-path $pkg.FullName
148+
$package = cargo read-manifest --manifest-path $pkg.FullName | ConvertFrom-Json
148149

149150
$packageName = $package.name
150151
$packageVersion = $package.version

eng/scripts/Pack-Crates.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function Get-PackagesToBuild() {
119119

120120
function Initialize-VendorDirectory() {
121121
$path = "$RepoRoot/target/vendor"
122-
Invoke-LoggedCommand "cargo vendor $path" | Out-Host
122+
Invoke-LoggedCommand "cargo vendor $path" -GroupOutput | Out-Host
123123
return $path
124124
}
125125

@@ -206,7 +206,7 @@ try {
206206

207207
Write-Host "Copying package '$packageName' to '$packageOutputPath'"
208208
New-Item -ItemType Directory -Path $packageOutputPath -Force | Out-Null
209-
Copy-Item -Path $targetPackagePath -Destination $packageOutputPath -Recurse -Exclude "Cargo.toml.orig"
209+
Copy-Item -Path $targetPackagePath/* -Destination $packageOutputPath -Recurse -Exclude "Cargo.toml.orig"
210210
}
211211
}
212212

eng/scripts/Publish-Crates.ps1

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
param(
55
[string]$PackagesPath,
66
[string[]]$CrateNames,
7-
[string[]]$AdditionalOwners,
8-
[string]$Token
7+
[string[]]$AdditionalOwners
98
)
109

1110
$ErrorActionPreference = 'Stop'
@@ -15,18 +14,18 @@ foreach ($crateName in $CrateNames) {
1514
Write-Host "Publishing packae: '$crateName'"
1615
$manifestPath = "$PackagesPath/$crateName/Cargo.toml"
1716
# https://doc.rust-lang.org/cargo/reference/registry-web-api.html#publish
18-
Write-Host "> cargo publish --manifest-path `"$manifestPath`" --token <TOKEN>"
19-
cargo publish --manifest-path $manifestPath --token $Token
17+
Write-Host "> cargo publish --manifest-path `"$manifestPath`""
18+
cargo publish --manifest-path $manifestPath
2019
if (!$?) {
2120
Write-Error "Failed to publish package: '$crateName'"
2221
exit 1
2322
}
2423

25-
$existingOwners = (Invoke-LoggedCommand cargo owner --list $crateName) -replace " \(.*", ""
24+
$existingOwners = (cargo owner --list $crateName) -replace " \(.*", ""
2625
$missingOwners = $AdditionalOwners | Where-Object { $existingOwners -notcontains $_ }
2726

2827
foreach ($owner in $missingOwners) {
29-
Write-Host "> cargo owner --add $owner $crateName --token <TOKEN>"
30-
cargo owner --add $owner $crateName --token $Token
28+
Write-Host "> cargo owner --add $owner $crateName"
29+
cargo owner --add $owner $crateName
3130
}
3231
}

eng/scripts/Yank-Crates.ps1

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
#Requires -Version 7.0
44
param(
55
[string]$PackageInfoDirectory,
6-
[string[]]$CrateNames,
7-
[string]$Token
6+
[string[]]$CrateNames
87
)
98

109
$ErrorActionPreference = 'Stop'
@@ -17,8 +16,8 @@ foreach ($crateName in $crateNames) {
1716

1817
Write-Host "Yanking crate: '$crateName@$crateVersion'"
1918

20-
Write-Host "cargo yank $crateName --version $crateVersion --token <TOKEN>"
21-
cargo yank $crateName --version $crateVersion --token $Token
19+
Write-Host "cargo yank $crateName --version $crateVersion"
20+
cargo yank $crateName --version $crateVersion
2221

2322
if (!$?) {
2423
Write-Host "Failed to yank crate: '$crateName@$crateVersion'"

0 commit comments

Comments
 (0)