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] Add tests #29639

Merged
merged 30 commits into from
Jul 2, 2024
Merged

Conversation

mikeharder
Copy link
Member

@mikeharder mikeharder commented Jun 29, 2024

Copy link

openapi-pipeline-app bot commented Jun 29, 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 Jun 29, 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: 5 Errors, 0 Warnings failed [Detail]
Rule Message
MISSING_README Can not find readme.md in the folder. If no readme.md file, it will block SDK generation.
folder: resource-manager/Microsoft.HandWritten/preview/2024-01-01-preview
MISSING_README Can not find readme.md in the folder. If no readme.md file, it will block SDK generation.
folder: resource-manager/Microsoft.NoTspConfig/preview/2024-01-01-preview
MISSING_README Can not find readme.md in the folder. If no readme.md file, it will block SDK generation.
folder: resource-manager/Microsoft.ParseError/preview/2024-01-01-preview
MISSING_README Can not find readme.md in the folder. If no readme.md file, it will block SDK generation.
folder: resource-manager/Microsoft.Suppression/preview/2024-01-01-preview
MISSING_README Can not find readme.md in the folder. If no readme.md file, it will block SDK generation.
folder: resource-manager/Microsoft.TypeSpecGenerated/preview/2024-01-01-preview
️❌SwaggerAPIView: 1 Errors, 0 Warnings failed [Detail]
Rule Message
Failed to generate swagger APIView. The readme file format is invalid and the tag is not defined. Use the provided readme template for guidance readme template. For more details, please check the detail log. "How to fix":"Check the readme file and make sure the readme file format is valid and the tag is defined. Use the provided readme template"
️️✔️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 Jun 29, 2024

Swagger Generation Artifacts

️❌ApiDocPreview: 1 Errors, 0 Warnings failed [Detail]
Rule Message
RestBuild error "logUrl":"https://apidrop.visualstudio.com/Content%20CI/_build/results?buildId=436900&view=logs&j=fd490c07-0b22-5182-fac9-6d67fe1e939b",
"detail":"Run.ps1 failed with exit code 1 "
️🔄 $(sdkName) inProgress [Detail]
Posted by Swagger Pipeline | How to fix these errors?

Copy link

openapi-pipeline-app bot commented Jun 29, 2024

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

@mikeharder mikeharder self-assigned this Jun 29, 2024
@mikeharder mikeharder marked this pull request as ready for review July 2, 2024 00:59
@@ -59,7 +63,7 @@ $repoPath = Resolve-Path "$PSScriptRoot/../.."
$pathsWithErrors = @()

$filesToCheck = $CheckAllUnder ?
(Get-ChildItem -Path $CheckAllUnder -Recurse -File | Resolve-Path -Relative | ForEach-Object { $_ -replace '\\', '/' }) :
(Get-ChildItem -Path $CheckAllUnder -Recurse -File | Resolve-Path -Relative -RelativeBasePath $repoPath | ForEach-Object { $_ -replace '\\', '/' }) :
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixes bug when testing files outside root "specification" folder

| Where-Object { $_.Name -eq "tspconfig.yaml" })
if ($file -match "^.*specification/[^/]+/") {
$rpFolder = $Matches[0];
$tspConfigs = @(Get-ChildItem -Path $rpFolder -Recurse -File | Where-Object { $_.Name -eq "tspconfig.yaml" })
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixes bug when testing files outside root "specification" folder

@@ -176,12 +179,12 @@ else {
if ($responseStatus -eq 200) {
LogInfo " Branch 'main' contains path '$servicePath/stable', so spec already exists and is not required to use TypeSpec"
}
elseif ($response.StatusCode -eq 404) {
elseif ($responseStatus -eq 404) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Bug fix (unlikely to hit in practice)

@mikeharder mikeharder merged commit 87a08b9 into Azure:main Jul 2, 2024
24 of 32 checks passed
@mikeharder mikeharder deleted the tsr-unit-tests branch July 2, 2024 01:25
@@ -15,7 +15,7 @@ function LogWarning {
Write-Host ("##vso[task.LogIssue type=warning;]$args" -replace "`n", "%0D%0A")
}
elseif (Test-SupportsGitHubLogging) {
Write-Host ("::warning::$args" -replace "`n", "%0D%0A")
Write-Warning ("::warning::$args" -replace "`n", "%0D%0A")
Copy link
Member

Choose a reason for hiding this comment

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

What does this give us? Doesn't GH just interpret these logging messages and not display them?

Copy link
Member Author

@mikeharder mikeharder Jul 2, 2024

Choose a reason for hiding this comment

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

At least for GH, it seemed more correct to use both the intended pwsh Write-* method, along with including the GH-specific logging strings.

Write-Warning might write to stdout instead of stderr, so it might not matter in practice. What did matter in practice was using Write-Error instead of Write-Host, to ensure errors are always written to stderr.

Example:

test.concurrent("No tspconfig.yaml", async ({ expect }) => {
const { stderr, exitCode } = await checkAllUnder("specification/no-tspconfig");
expect(stderr).toContain("no files named 'tspconfig.yaml'");
expect(exitCode).toBe(1);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[TypeSpecRequirement] Add end-to-end test
3 participants