Skip to content
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

Merged
merged 7 commits into from
May 7, 2024

Conversation

Copy link

openapi-pipeline-app bot commented May 7, 2024

PR validation pipeline restarted successfully. This comment will be populated with next steps to merge this PR once validation is completed. Please wait ⌛.

Copy link

openapi-pipeline-app bot commented May 7, 2024

Swagger Validation Report

️️✔️BreakingChange succeeded [Detail] [Expand]
There are no breaking changes.
️️✔️Breaking Change(Cross-Version) succeeded [Detail] [Expand]
There are no breaking changes.
️️✔️CredScan succeeded [Detail] [Expand]
There is no credential detected.
️️✔️LintDiff succeeded [Detail] [Expand]
Validation passes for LintDiff.
️️✔️Avocado succeeded [Detail] [Expand]
Validation passes for Avocado.
️️✔️SwaggerAPIView succeeded [Detail] [Expand]
️️✔️TypeSpecAPIView succeeded [Detail] [Expand]
️️✔️ModelValidation succeeded [Detail] [Expand]
Validation passes for ModelValidation.
️️✔️SemanticValidation succeeded [Detail] [Expand]
Validation passes for SemanticValidation.
️️✔️PoliCheck succeeded [Detail] [Expand]
Validation passed for PoliCheck.
️️✔️SpellCheck succeeded [Detail] [Expand]
Validation passes for SpellCheck.
️️✔️Lint(RPaaS) succeeded [Detail] [Expand]
Validation passes for Lint(RPaaS).
️️✔️PR Summary succeeded [Detail] [Expand]
Validation passes for Summary.
️⌛Automated merging requirements met pending [Detail]
Posted by Swagger Pipeline | How to fix these errors?

Copy link

openapi-pipeline-app bot commented May 7, 2024

Swagger Generation Artifacts

️️✔️ApiDocPreview succeeded [Detail] [Expand]
Posted by Swagger Pipeline | How to fix these errors?

Copy link

openapi-pipeline-app bot commented May 7, 2024

PR validation pipeline restarted successfully. If there is ApiView generated, it will be updated in this comment.

@@ -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
Copy link
Member Author

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 than npx and should always be used instead.

Copy link
Member

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

Copy link
Member Author

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.


return $suppressions ? $suppressions[0] : $null;
if ($LASTEXITCODE -ne 0) {
Copy link
Member Author

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. But if get-suppressions fails, either because user didn't run npm ci and tool isn't compiled, or because say suppressions.yaml is malformed and get-suppressions throws, we should fail fast.

if ($suppression) {
$path = $suppression["path"]
$singleVersionPattern = "/(preview|stable)/[A-Za-z0-9._-]+/"
if ($path -notmatch $singleVersionPattern) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crux of PR. Require that paths specified in suppressions.yaml for this tool only map to a single API version. Suppressions for additional versions should require additional entries and reviews.

@mikeharder mikeharder enabled auto-merge (squash) May 7, 2024 06:26
@mikeharder mikeharder disabled auto-merge May 7, 2024 06:47
@mikeharder mikeharder merged commit d678044 into Azure:main May 7, 2024
33 of 35 checks passed
@mikeharder mikeharder deleted the tsr-suppress-specific-versions branch May 7, 2024 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

[TypeSpec Requirement] Only allow suppressions for individual versions
3 participants