14
14
# ----------------------------------------------------------------------------------
15
15
16
16
# 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"
18
18
Param (
19
19
[Switch ]
20
20
$Build ,
56
56
$StaticAnalysisOutputDirectory = ' artifacts/StaticAnalysisResults' ,
57
57
58
58
[String ]
59
- $ModuleList
59
+ $TargetModule
60
60
)
61
61
$ErrorActionPreference = ' Stop'
62
62
@@ -71,90 +71,99 @@ If ($Build)
71
71
{
72
72
dotnet $BuildAction $RepoArtifacts / Azure.PowerShell.sln - c $Configuration - p:GenerateDocumentationFile= false - fl " /flp1:logFile=$LogFile ;verbosity=quiet"
73
73
}
74
- $LogContent = Get-Content $LogFile
75
- $BuildResultArray = @ ()
76
- ForEach ($Line In $LogContent )
74
+ If (Test-Path - Path " $RepoArtifacts /PipelineResult" )
77
75
{
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 )
81
79
{
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
+ }
95
98
}
99
+ ConvertTo-Json - Depth 10 - InputObject $BuildResultArray | Out-File - FilePath " $RepoArtifacts /PipelineResult/Build.json"
96
100
}
97
- ConvertTo-Json - Depth 10 - InputObject $BuildResultArray | Out-File - FilePath " $RepoArtifacts /PipelineResult/Build.json "
101
+ Return
98
102
}
99
103
100
- If (-Not $PSBoundParameters.ContainsKey (" ModuleList " ))
104
+ If (-Not $PSBoundParameters.ContainsKey (" TargetModule " ))
101
105
{
102
106
$CIPlan = Get-Content $RepoArtifacts / PipelineResult/ CIPlan.json | ConvertFrom-Json
103
107
}
104
108
105
109
If ($Test -And $CIPlan.test.Length -Ne 0 )
106
110
{
107
111
dotnet test $RepoArtifacts / Azure.PowerShell.sln -- filter " AcceptanceType=CheckIn&RunType!=DesktopOnly" -- configuration $Configuration -- framework $TestFramework -- logger trx -- results- directory $TestOutputDirectory
112
+ Return
108
113
}
109
114
110
115
If ($StaticAnalysisBreakingChange )
111
116
{
112
- If ($PSBoundParameters.ContainsKey (" ModuleList " ))
117
+ If ($PSBoundParameters.ContainsKey (" TargetModule " ))
113
118
{
114
- $BreakingChangeCheckModuleList = $ModuleList
119
+ $BreakingChangeCheckModuleList = $TargetModule
115
120
}
116
121
Else
117
122
{
118
123
$BreakingChangeCheckModuleList = Join-String - Separator ' ;' - InputObject $CIPlan .' breaking-change'
119
124
}
120
125
dotnet $RepoArtifacts / StaticAnalysis/ StaticAnalysis.Netcore.dll - p $RepoArtifacts / $Configuration - r $StaticAnalysisOutputDirectory -- analyzers breaking- change - u - m $BreakingChangeCheckModuleList
126
+ Return
121
127
}
122
128
123
129
If ($StaticAnalysisDependency )
124
130
{
125
- If ($PSBoundParameters.ContainsKey (" ModuleList " ))
131
+ If ($PSBoundParameters.ContainsKey (" TargetModule " ))
126
132
{
127
- $DependencyCheckModuleList = $ModuleList
133
+ $DependencyCheckModuleList = $TargetModule
128
134
}
129
135
Else
130
136
{
131
137
$DependencyCheckModuleList = Join-String - Separator ' ;' - InputObject $CIPlan.dependency
132
138
}
133
139
dotnet $RepoArtifacts / StaticAnalysis/ StaticAnalysis.Netcore.dll - p $RepoArtifacts / $Configuration - r $StaticAnalysisOutputDirectory -- analyzers dependency - u - m $DependencyCheckModuleList
140
+ Return
134
141
}
135
142
136
143
If ($StaticAnalysisSignature )
137
144
{
138
- If ($PSBoundParameters.ContainsKey (" ModuleList " ))
145
+ If ($PSBoundParameters.ContainsKey (" TargetModule " ))
139
146
{
140
- $SignatureCheckModuleList = $ModuleList
147
+ $SignatureCheckModuleList = $TargetModule
141
148
}
142
149
Else
143
150
{
144
151
$SignatureCheckModuleList = Join-String - Separator ' ;' - InputObject $CIPlan.signature
145
152
}
146
153
dotnet $RepoArtifacts / StaticAnalysis/ StaticAnalysis.Netcore.dll - p $RepoArtifacts / $Configuration - r $StaticAnalysisOutputDirectory -- analyzers signature - u - m $SignatureCheckModuleList
154
+ Return
147
155
}
148
156
149
157
If ($StaticAnalysisHelp )
150
158
{
151
- If ($PSBoundParameters.ContainsKey (" ModuleList " ))
159
+ If ($PSBoundParameters.ContainsKey (" TargetModule " ))
152
160
{
153
- $HelpCheckModuleList = $ModuleList
161
+ $HelpCheckModuleList = $TargetModule
154
162
}
155
163
Else
156
164
{
157
165
$HelpCheckModuleList = Join-String - Separator ' ;' - InputObject $CIPlan.help
158
166
}
159
167
dotnet $RepoArtifacts / StaticAnalysis/ StaticAnalysis.Netcore.dll - p $RepoArtifacts / $Configuration - r $StaticAnalysisOutputDirectory -- analyzers help - u - m $HelpCheckModuleList
168
+ Return
160
169
}
0 commit comments