Skip to content

Commit 1bb5e2e

Browse files
authored
Add manual approval before yanking test pipeline crates (Azure#2355)
1 parent d17fc3e commit 1bb5e2e

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,24 @@ stages:
153153
BaseBranchName: main
154154

155155
- ${{ if eq(parameters.TestPipeline, true) }}:
156+
- job: ManualApproval
157+
displayName: "Manual approval"
158+
dependsOn: PublishPackage
159+
condition: ne(variables['Skip.PublishPackage'], 'true')
160+
pool: server
161+
timeoutInMinutes: 120 # 2 hours
162+
steps:
163+
- task: ManualValidation@1
164+
timeoutInMinutes: 60 # 1 hour
165+
inputs:
166+
notifyUsers: '' # Required, but empty string allowed
167+
allowApproversToApproveTheirOwnRuns: true
168+
instructions: "Approve yank of ${{ artifact.name }}"
169+
onTimeout: 'resume'
170+
156171
- job: YankCrates
157172
displayName: "Yank Crates"
158-
dependsOn: PublishPackage
173+
dependsOn: ManualApproval
159174
condition: and(succeeded(), ne(variables['Skip.PublishPackage'], 'true'))
160175
steps:
161176
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml

eng/scripts/Yank-Crates.ps1

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,20 @@ foreach ($crateName in $crateNames) {
1414
$crate = Get-Content "$PackageInfoDirectory/$crateName.json" -Raw | ConvertFrom-Json
1515
$crateVersion = $crate.Version
1616

17-
Write-Host "Yanking crate: '$crateName@$crateVersion'"
17+
Write-Host "> cargo yank $crateName --version $crateVersion"
18+
cargo yank $crateName --version $crateVersion 2>&1 | Tee-Object -Variable output
1819

19-
Write-Host "cargo yank $crateName --version $crateVersion"
20-
cargo yank $crateName --version $crateVersion
21-
22-
if (!$?) {
23-
Write-Host "Failed to yank crate: '$crateName@$crateVersion'"
24-
$hasErrors = $true
20+
if ($LASTEXITCODE -ne 0) {
21+
if ($output -match 'status 404 Not Found') {
22+
Write-Host "Crate '$crateName@$crateVersion' not found. Skipping yank."
23+
}
24+
else {
25+
Write-Host "Error yanking crate: '$crateName@$crateVersion'"
26+
$hasErrors = $true
27+
}
28+
}
29+
else {
30+
Write-Host "Successfully yanked crate: '$crateName@$crateVersion'"
2531
}
2632
}
2733

0 commit comments

Comments
 (0)