Skip to content

Commit f9f3ea9

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

File tree

3 files changed

+63
-8
lines changed

3 files changed

+63
-8
lines changed

build.proj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@
191191
<BuildAction Condition="'$(Configuration)' != 'Release'">build</BuildAction>
192192
<BuildAction Condition="'$(Configuration)' == 'Release'">publish</BuildAction>
193193
</PropertyGroup>
194-
<Exec Command="dotnet $(BuildAction) $(RepoArtifacts)Azure.PowerShell.sln -c $(Configuration)" Condition="$(GenerateDocumentationFile) != 'false'"/>
195-
<Exec Command="dotnet $(BuildAction) $(RepoArtifacts)Azure.PowerShell.sln -c $(Configuration) -p:GenerateDocumentationFile=false" Condition="$(GenerateDocumentationFile) == 'false'"/>
196-
194+
195+
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;.\tools\ExecuteCIStep.ps1 -Build -RepoArtifacts $(RepoArtifacts) -Configuration $(Configuration) -GenerateDocumentationFile $(GenerateDocumentationFile) -BuildAction $(BuildAction)&quot;" />
196+
197197
<!-- Build version controller -->
198198
<Exec Command="dotnet build $(RepoTools)VersionController/VersionController.Netcore.csproj -c $(Configuration)" />
199199

tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/CIFilterTask.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,20 @@ private bool ProcessFileChanged(Dictionary<string, string[]> csprojMap)
397397

398398
FilterTaskResult.PhaseInfo = influencedModuleInfo;
399399

400-
influencedModuleInfo[string.Format("{0}-module", BUILD_PHASE)] = new HashSet<string>(influencedModuleInfo[BUILD_PHASE].Select(GetModuleNameFromPath).Where(x => x != null));
401-
influencedModuleInfo[string.Format("{0}-module", TEST_PHASE)] = new HashSet<string>(influencedModuleInfo[TEST_PHASE].Select(GetModuleNameFromPath).Where(x => x != null));
402400
if (!Directory.Exists(config.ArtifactPipelineInfoFolder))
403401
{
404402
Directory.CreateDirectory(config.ArtifactPipelineInfoFolder);
405403
}
406-
File.WriteAllText(Path.Combine(config.ArtifactPipelineInfoFolder, "CIPlan.json"), JsonConvert.SerializeObject(influencedModuleInfo, Formatting.Indented));
404+
Dictionary<string, HashSet<string>> CIPlan = new Dictionary<string, HashSet<string>>
405+
{
406+
[BUILD_PHASE] = new HashSet<string>(influencedModuleInfo[BUILD_PHASE].Select(GetModuleNameFromPath).Where(x => x != null)),
407+
[ANALYSIS_BREAKING_CHANGE_PHASE] = influencedModuleInfo[ANALYSIS_BREAKING_CHANGE_PHASE],
408+
[ANALYSIS_DEPENDENCY_PHASE] = influencedModuleInfo[ANALYSIS_DEPENDENCY_PHASE],
409+
[ANALYSIS_HELP_PHASE] = influencedModuleInfo[ANALYSIS_HELP_PHASE],
410+
[ANALYSIS_SIGNATURE_PHASE] = influencedModuleInfo[ANALYSIS_SIGNATURE_PHASE],
411+
[TEST_PHASE] = new HashSet<string>(influencedModuleInfo[TEST_PHASE].Select(GetModuleNameFromPath).Where(x => x != null))
412+
};
413+
File.WriteAllText(Path.Combine(config.ArtifactPipelineInfoFolder, "CIPlan.json"), JsonConvert.SerializeObject(CIPlan, Formatting.Indented));
407414

408415
return true;
409416
}

tools/ExecuteCIStep.ps1

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@
1313
# is regenerated.
1414
# ----------------------------------------------------------------------------------
1515

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"
1618
Param(
19+
[Switch]
20+
$Build,
21+
22+
[String]
23+
$BuildAction='build',
24+
25+
[Switch]
26+
$GenerateDocumentationFile,
27+
1728
[Switch]
1829
$Test,
1930

@@ -39,16 +50,53 @@ Param(
3950
$TestFramework='netcoreapp2.2',
4051

4152
[String]
42-
$TestOutputDirectory='artifacts\TestResults',
53+
$TestOutputDirectory='artifacts/TestResults',
4354

4455
[String]
45-
$StaticAnalysisOutputDirectory='artifacts\StaticAnalysisResults',
56+
$StaticAnalysisOutputDirectory='artifacts/StaticAnalysisResults',
4657

4758
[String]
4859
$ModuleList
4960
)
5061
$ErrorActionPreference = 'Stop'
5162

63+
If ($Build)
64+
{
65+
$LogFile = "$RepoArtifacts/Build.Log"
66+
If ($GenerateDocumentationFile)
67+
{
68+
dotnet $BuildAction $RepoArtifacts/Azure.PowerShell.sln -c $Configuration -fl "/flp1:logFile=$LogFile;verbosity=quiet"
69+
}
70+
Else
71+
{
72+
dotnet $BuildAction $RepoArtifacts/Azure.PowerShell.sln -c $Configuration -p:GenerateDocumentationFile=false -fl "/flp1:logFile=$LogFile;verbosity=quiet"
73+
}
74+
$LogContent = Get-Content $LogFile
75+
$BuildResultArray = @()
76+
ForEach ($Line In $LogContent)
77+
{
78+
$Position, $ErrorOrWarningType, $Detail = $Line.Split(": ")
79+
$Detail = Join-String -Separator ": " -InputObject $Detail
80+
If ($Position.Contains("src"))
81+
{
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
95+
}
96+
}
97+
ConvertTo-Json -Depth 10 -InputObject $BuildResultArray | Out-File -FilePath "$RepoArtifacts/PipelineResult/Build.json"
98+
}
99+
52100
If (-Not $PSBoundParameters.ContainsKey("ModuleList"))
53101
{
54102
$CIPlan = Get-Content $RepoArtifacts/PipelineResult/CIPlan.json | ConvertFrom-Json

0 commit comments

Comments
 (0)