Skip to content

Commit ac1e417

Browse files
azure-powershell-botazurepowershell
andauthored
Sync tools folder from main branch to generation branch (#19934)
Co-authored-by: azurepowershell <[email protected]>
1 parent f9f3ea9 commit ac1e417

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

tools/ExecuteCIStep.ps1

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# ----------------------------------------------------------------------------------
1515

1616
# Usage: 1. This script can be called by build.proj used in CI pipeline
17-
# 2. Can be used to do static analysis in local env. Such as: .\tools\ExecuteCIStep.ps1 -StaticAnalysisSignature -ModuleList "Accounts;Compute"
17+
# 2. Can be used to do static analysis in local env. Such as: .\tools\ExecuteCIStep.ps1 -StaticAnalysisSignature -TargetModule "Accounts;Compute"
1818
Param(
1919
[Switch]
2020
$Build,
@@ -56,7 +56,7 @@ Param(
5656
$StaticAnalysisOutputDirectory='artifacts/StaticAnalysisResults',
5757

5858
[String]
59-
$ModuleList
59+
$TargetModule
6060
)
6161
$ErrorActionPreference = 'Stop'
6262

@@ -71,90 +71,99 @@ If ($Build)
7171
{
7272
dotnet $BuildAction $RepoArtifacts/Azure.PowerShell.sln -c $Configuration -p:GenerateDocumentationFile=false -fl "/flp1:logFile=$LogFile;verbosity=quiet"
7373
}
74-
$LogContent = Get-Content $LogFile
75-
$BuildResultArray = @()
76-
ForEach ($Line In $LogContent)
74+
If (Test-Path -Path "$RepoArtifacts/PipelineResult")
7775
{
78-
$Position, $ErrorOrWarningType, $Detail = $Line.Split(": ")
79-
$Detail = Join-String -Separator ": " -InputObject $Detail
80-
If ($Position.Contains("src"))
76+
$LogContent = Get-Content $LogFile
77+
$BuildResultArray = @()
78+
ForEach ($Line In $LogContent)
8179
{
82-
$ModuleName = $Position.Replace("\", "/").Split("src/")[1].Split('/')[0]
83-
}
84-
Else
85-
{
86-
$ModuleName = "dotnet"
87-
}
88-
$Type, $Code = $ErrorOrWarningType.Split(" ")
89-
$BuildResultArray += @{
90-
"Position" = $Position;
91-
"Module" = $ModuleName;
92-
"Type" = $Type;
93-
"Code" = $Code;
94-
"Detail" = $Detail
80+
$Position, $ErrorOrWarningType, $Detail = $Line.Split(": ")
81+
$Detail = Join-String -Separator ": " -InputObject $Detail
82+
If ($Position.Contains("src"))
83+
{
84+
$ModuleName = $Position.Replace("\", "/").Split("src/")[1].Split('/')[0]
85+
}
86+
Else
87+
{
88+
$ModuleName = "dotnet"
89+
}
90+
$Type, $Code = $ErrorOrWarningType.Split(" ")
91+
$BuildResultArray += @{
92+
"Position" = $Position;
93+
"Module" = $ModuleName;
94+
"Type" = $Type;
95+
"Code" = $Code;
96+
"Detail" = $Detail
97+
}
9598
}
99+
ConvertTo-Json -Depth 10 -InputObject $BuildResultArray | Out-File -FilePath "$RepoArtifacts/PipelineResult/Build.json"
96100
}
97-
ConvertTo-Json -Depth 10 -InputObject $BuildResultArray | Out-File -FilePath "$RepoArtifacts/PipelineResult/Build.json"
101+
Return
98102
}
99103

100-
If (-Not $PSBoundParameters.ContainsKey("ModuleList"))
104+
If (-Not $PSBoundParameters.ContainsKey("TargetModule"))
101105
{
102106
$CIPlan = Get-Content $RepoArtifacts/PipelineResult/CIPlan.json | ConvertFrom-Json
103107
}
104108

105109
If ($Test -And $CIPlan.test.Length -Ne 0)
106110
{
107111
dotnet test $RepoArtifacts/Azure.PowerShell.sln --filter "AcceptanceType=CheckIn&RunType!=DesktopOnly" --configuration $Configuration --framework $TestFramework --logger trx --results-directory $TestOutputDirectory
112+
Return
108113
}
109114

110115
If ($StaticAnalysisBreakingChange)
111116
{
112-
If ($PSBoundParameters.ContainsKey("ModuleList"))
117+
If ($PSBoundParameters.ContainsKey("TargetModule"))
113118
{
114-
$BreakingChangeCheckModuleList = $ModuleList
119+
$BreakingChangeCheckModuleList = $TargetModule
115120
}
116121
Else
117122
{
118123
$BreakingChangeCheckModuleList = Join-String -Separator ';' -InputObject $CIPlan.'breaking-change'
119124
}
120125
dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers breaking-change -u -m $BreakingChangeCheckModuleList
126+
Return
121127
}
122128

123129
If ($StaticAnalysisDependency)
124130
{
125-
If ($PSBoundParameters.ContainsKey("ModuleList"))
131+
If ($PSBoundParameters.ContainsKey("TargetModule"))
126132
{
127-
$DependencyCheckModuleList = $ModuleList
133+
$DependencyCheckModuleList = $TargetModule
128134
}
129135
Else
130136
{
131137
$DependencyCheckModuleList = Join-String -Separator ';' -InputObject $CIPlan.dependency
132138
}
133139
dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers dependency -u -m $DependencyCheckModuleList
140+
Return
134141
}
135142

136143
If ($StaticAnalysisSignature)
137144
{
138-
If ($PSBoundParameters.ContainsKey("ModuleList"))
145+
If ($PSBoundParameters.ContainsKey("TargetModule"))
139146
{
140-
$SignatureCheckModuleList = $ModuleList
147+
$SignatureCheckModuleList = $TargetModule
141148
}
142149
Else
143150
{
144151
$SignatureCheckModuleList = Join-String -Separator ';' -InputObject $CIPlan.signature
145152
}
146153
dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers signature -u -m $SignatureCheckModuleList
154+
Return
147155
}
148156

149157
If ($StaticAnalysisHelp)
150158
{
151-
If ($PSBoundParameters.ContainsKey("ModuleList"))
159+
If ($PSBoundParameters.ContainsKey("TargetModule"))
152160
{
153-
$HelpCheckModuleList = $ModuleList
161+
$HelpCheckModuleList = $TargetModule
154162
}
155163
Else
156164
{
157165
$HelpCheckModuleList = Join-String -Separator ';' -InputObject $CIPlan.help
158166
}
159167
dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers help -u -m $HelpCheckModuleList
168+
Return
160169
}

0 commit comments

Comments
 (0)