-
Couldn't load subscription status.
- Fork 1.4k
Taylor hazlett apipropertiesvalidator #1427
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
Merged
mamurshe
merged 22 commits into
microsoft:dev
from
taylor-hazlett:taylor-hazlett-apipropertiesvalidator
Feb 11, 2022
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
72b29f3
Update swagger_validation.yml
taylor-hazlett ae80b4f
Create apiProperties_validator.yml
taylor-hazlett 32fbd57
Update swagger_validation.yml
taylor-hazlett 53e6f2b
Update apiProperties_validator.yml
taylor-hazlett 4134e59
Update apiProperties_validator.yml
taylor-hazlett b670d2a
Update apiProperties_validator.yml
taylor-hazlett ecda779
Update apiProperties_validator.yml
taylor-hazlett d21efa6
Update apiProperties_validator.yml
taylor-hazlett 56b180f
Update apiProperties_validator.yml
taylor-hazlett 1a664fc
Update apiProperties_validator.yml
taylor-hazlett 39c1d6c
Update apiProperties_validator.yml
taylor-hazlett f70e733
Update apiProperties_validator.yml
taylor-hazlett 57dcbc4
Update apiProperties_validator.yml
taylor-hazlett 884d5f9
Update apiProperties_validator.yml
taylor-hazlett 8bd0a2b
Update apiProperties_validator.yml
taylor-hazlett 496fe93
Update apiProperties_validator.yml
taylor-hazlett 0b4b3b3
Update apiProperties_validator.yml
taylor-hazlett 30e8579
Update apiProperties_validator.yml
taylor-hazlett 3a01ad9
Update apiProperties_validator.yml
taylor-hazlett 94c84cc
Update apiProperties_validator.yml
taylor-hazlett b1d91e9
Update apiProperties_validator.yml
taylor-hazlett 3f1b198
Update apiProperties_validator.yml
taylor-hazlett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
|
|
||
| pool: | ||
| vmImage: "ubuntu-latest" | ||
|
|
||
| steps: | ||
| - pwsh: | ||
| $errorsTotal = 0 | ||
| $warningsTotal = 0 | ||
|
|
||
| # Get the list of files for the given PR | ||
| $currentLocation = Get-Location | ||
| $files = git diff HEAD~1 --name-only | ||
| $apiPropertiesFiles = $files | where {$_ -match '.+?apiProperties.json$'} | ||
|
|
||
| $Headers = @{ | ||
| Authorization = $env:token | ||
| } | ||
|
|
||
| $suppressWarnings = false | ||
|
|
||
| foreach ($file in $apiPropertiesFiles) { | ||
|
|
||
| $newFileContent = Get-Content $file -Raw | ||
|
|
||
| # Validate apiProperties json | ||
| $apiPropertiesValidatorUri = "$($env:apiPropertiesValidator)&suppressWarnings=$suppressWarnings" | ||
| $results = Invoke-RestMethod -Uri $apiPropertiesValidatorUri -Headers $Headers -Method Post -ContentType "application/json; charset=utf-8" -Body @($newFileContent) | ||
|
|
||
| $errors = $results | Where-Object { $_.level -EQ "Critical" -OR $_.Level -EQ "Error" } | ||
| $warnings = $results | Where-Object { $_.level -EQ "Warning" } | ||
|
|
||
| if ($errors) { | ||
| $errorsTotal += $errors.Count | ||
| $errors | foreach { Write-Host "##vso[task.logissue type=error;]$_" } | ||
| } # If Api Properties Error | ||
|
|
||
| if ($warnings -AND -NOT $suppressWarnings) { | ||
| $warningsTotal += $warnings.Count | ||
| $warnings | foreach { Write-Host "##vso[task.logissue type=warning;sourcepath=$file;]$_" } | ||
| } # If Api Properties Warnings | ||
|
|
||
| } # For each file | ||
|
|
||
| if ($errorsTotal -gt 0) { | ||
| Write-Host "##vso[task.complete result=Failed;]Errors encountered." | ||
| } | ||
| elseif ($warningsTotal -gt 0) { | ||
| Write-Host "##vso[task.complete result=SucceededWithIssues;]Warnings encountered." | ||
| } | ||
| else { | ||
| Write-Host "##vso[task.complete result=Succeeded;]No error or warnings encountered." | ||
| } | ||
| env: | ||
| apiPropertiesValidator: "$(apiPropertiesValidatorUrl)" | ||
| token: $(token) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.