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

Gen code verify #22085

Merged
merged 11 commits into from
Jun 15, 2023
28 changes: 14 additions & 14 deletions .azure-pipelines/windows-powershell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ jobs:
testFramework: ${{ variables.TestFramework }}
powerShellPlatform: ${{ variables.PowerShellPlatform }}

- job: Test
displayName: Test
dependsOn: Build
condition: and(eq(variables.IsGenerateBased, false), succeeded())
timeoutInMinutes: 180
pool: ${{ variables.AgentPoolName }}
# - job: Test
# displayName: Test
# dependsOn: Build
# condition: and(eq(variables.IsGenerateBased, false), succeeded())
# timeoutInMinutes: 180
# pool: ${{ variables.AgentPoolName }}

steps:
- template: util/test-steps.yml
parameters:
osName: ${{ variables.WindowsName }}
testFramework: ${{ variables.TestFramework }}
testTarget: ${{ variables.TestTarget }}
configuration: ${{ variables.Configuration }}
powerShellPlatform: ${{ variables.PowerShellPlatform }}
# steps:
# - template: util/test-steps.yml
# parameters:
# osName: ${{ variables.WindowsName }}
# testFramework: ${{ variables.TestFramework }}
# testTarget: ${{ variables.TestTarget }}
# configuration: ${{ variables.Configuration }}
# powerShellPlatform: ${{ variables.PowerShellPlatform }}
3 changes: 2 additions & 1 deletion tools/ExecuteCIStep.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@ If ($StaticAnalysisVerifyGenSdk)
If ("" -Ne $VerifyGenSdkModuleList)
{
Write-Host "Running static analysis to verify generated sdk..."
.($PSScriptRoot + "/StaticAnalysis/GeneratedSdkAnalyzer/SDKGeneratedCodeVerify.ps1")
. .($PSScriptRoot + "/StaticAnalysis/GeneratedSdkAnalyzer/SDKGeneratedCodeVerify.ps1")

# dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers verify-generated-sdk -u -m $VerifyGenSdkModuleList
}
Return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ param (
# All errors should be logged using this function, as it tracks the errors in
# the $errors array, which is used in the finally block of the script to determine
# the return code.
[string[]] $errors = @()

function LogError([string]$message) {
Write-Host -f Red "error: $message"
$script:errors += $message
Expand All @@ -16,8 +18,10 @@ $ErrorActionPreference = 'Stop'
# $Env:NODE_OPTIONS = "--max-old-space-size=8192"
Set-StrictMode -Version 1

# . (Join-Path $PSScriptRoot\..\common\scripts common.ps1)
# When the input $MarkdownPaths is the path of txt file contained markdown paths
try{
# . (Join-Path $PSScriptRoot\..\common\scripts common.ps1)
# When the input $MarkdownPaths is the path of txt file contained markdown paths

if ((Test-Path $FilesChangedPaths -PathType Leaf) -and $FilesChangedPaths.EndsWith(".txt")) {
$FilesChanged = Get-Content $FilesChangedPaths | Where-Object { ($_ -match "^src\\.*\.Sdk\\.*Generated.*")}# -and (Test-Path $_) }
# Write-Host "FilesChanged:" $FilesChanged
Expand All @@ -30,9 +34,54 @@ Set-StrictMode -Version 1
}
# When the input $MarkdownPaths is the path of a folder
else {
Write-Error "Only accept .txt files as input."
}
foreach ($_ in $ChangedModules) {
# Direct to the Sdk directory
$module = ($_ -split "\/|\\")[1]
Write-Host "Directing to " + $PSScriptRoot + "../" + $_
cd $PSScriptRoot + "../" + $_

# Regenerate the Sdk under Generated folder
Write-Host "Re-generating SDK under Generated folder for $module..."
if( Test-Path -Path "README.md" -PathType Leaf){
autorest --reset
autorest --use:@microsoft.azure/[email protected]
autorest.cmd README.md --version=v2
}
else {
LogError "No README file detected."
}

# See if the code is completely the same as we generated
$changes = git status --porcelain
if (!$changes -eq $null){
LogError `
"Generated code for $module is not up to date.`
You may need to rebase on the latest main, `
re-generate code accroding to README.md file under $_`
"
}
}
}
finally {
Write-Host ""
Write-Host "Summary:"
Write-Host ""
Write-Host " $($errors.Length) error(s)"
Write-Host ""

foreach ($err in $errors) {
Write-Host -f Red "error : $err"
}

if ($errors) {
exit 1
}
}
LogError "Only accept .txt files."
}
foreach ($_ in $ChangedModules) {
# Filter the .md of overview in "\help\"
Write-Host $_
}
}