-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TypeSpecRequirement] Only allow one version per suppression #29001
Changes from 1 commit
0d5ed94
4c02b60
6635b6d
82dc507
fe1f36a
e531d30
65fef97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,27 @@ function Get-Suppression { | |
|
||
# -NoEnumerate to prevent single-element arrays from being collapsed to a single object | ||
# -AsHashtable is closer to raw JSON than PSCustomObject | ||
$suppressions = npx get-suppressions TypeSpecRequirement $fileInSpecFolder | ConvertFrom-Json -NoEnumerate -AsHashtable | ||
$suppressions = npm exec --no -- get-suppressions TypeSpecRequirement $fileInSpecFolder | ConvertFrom-Json -NoEnumerate -AsHashtable | ||
|
||
return $suppressions ? $suppressions[0] : $null; | ||
if ($LASTEXITCODE -ne 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to crux of PR. But if |
||
LogError "Failure running 'npm exec get-suppressions'" | ||
LogJobFailure | ||
exit 1 | ||
} | ||
|
||
$suppression = $suppressions ? $suppressions[0] : $null | ||
mikeharder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if ($suppression) { | ||
$path = $suppression["path"] | ||
$singleVersionPattern = "/(preview|stable)/[A-Za-z0-9._-]+/" | ||
if ($path -notmatch $singleVersionPattern) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Crux of PR. Require that paths specified in |
||
LogError ("Invalid path '$path'. Path must only include one version per suppression.") | ||
LogJobFailure | ||
exit 1 | ||
} | ||
} | ||
|
||
return $suppression; | ||
mikeharder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
$repoPath = Resolve-Path "$PSScriptRoot/../.." | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to crux of PR.
npm exec --no --
is more predictable in scripts thannpx
and should always be used instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeSpec Requirements pipeline was not calling the npm install step so this was never working after your change on friday. And the last error check you added below started to cause the pipeline to fail which was good because we started to see that failure now.
I've added the npm install step to the pipeline in PR #29008
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expected
$suppressions = npm exec
to throw by default if the command returned a non-zero exit code. I was surprised we need to manually check $LASTEXITCODE.