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

Add logic of collect the error and warning in build step #19870

Merged
merged 4 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@
<BuildAction Condition="'$(Configuration)' != 'Release'">build</BuildAction>
<BuildAction Condition="'$(Configuration)' == 'Release'">publish</BuildAction>
</PropertyGroup>
<Exec Command="dotnet $(BuildAction) $(RepoArtifacts)Azure.PowerShell.sln -c $(Configuration)" Condition="$(GenerateDocumentationFile) != 'false'"/>
<Exec Command="dotnet $(BuildAction) $(RepoArtifacts)Azure.PowerShell.sln -c $(Configuration) -p:GenerateDocumentationFile=false" Condition="$(GenerateDocumentationFile) == 'false'"/>


<Exec Command="$(PowerShellCoreCommandPrefix) &quot;.\tools\ExecuteCIStep.ps1 -Build -RepoArtifacts $(RepoArtifacts) -Configuration $(Configuration) -GenerateDocumentationFile $(GenerateDocumentationFile) -BuildAction $(BuildAction)&quot;" />
<!-- Build version controller -->
<Exec Command="dotnet build $(RepoTools)VersionController/VersionController.Netcore.csproj -c $(Configuration)" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,20 @@ private bool ProcessFileChanged(Dictionary<string, string[]> csprojMap)

FilterTaskResult.PhaseInfo = influencedModuleInfo;

influencedModuleInfo[string.Format("{0}-module", BUILD_PHASE)] = new HashSet<string>(influencedModuleInfo[BUILD_PHASE].Select(GetModuleNameFromPath).Where(x => x != null));
influencedModuleInfo[string.Format("{0}-module", TEST_PHASE)] = new HashSet<string>(influencedModuleInfo[TEST_PHASE].Select(GetModuleNameFromPath).Where(x => x != null));
if (!Directory.Exists(config.ArtifactPipelineInfoFolder))
{
Directory.CreateDirectory(config.ArtifactPipelineInfoFolder);
}
File.WriteAllText(Path.Combine(config.ArtifactPipelineInfoFolder, "CIPlan.json"), JsonConvert.SerializeObject(influencedModuleInfo, Formatting.Indented));
Dictionary<string, HashSet<string>> CIPlan = new Dictionary<string, HashSet<string>>
{
[BUILD_PHASE] = new HashSet<string>(influencedModuleInfo[BUILD_PHASE].Select(GetModuleNameFromPath).Where(x => x != null)),
[ANALYSIS_BREAKING_CHANGE_PHASE] = influencedModuleInfo[ANALYSIS_BREAKING_CHANGE_PHASE],
[ANALYSIS_DEPENDENCY_PHASE] = influencedModuleInfo[ANALYSIS_DEPENDENCY_PHASE],
[ANALYSIS_HELP_PHASE] = influencedModuleInfo[ANALYSIS_HELP_PHASE],
[ANALYSIS_SIGNATURE_PHASE] = influencedModuleInfo[ANALYSIS_SIGNATURE_PHASE],
[TEST_PHASE] = new HashSet<string>(influencedModuleInfo[TEST_PHASE].Select(GetModuleNameFromPath).Where(x => x != null))
};
File.WriteAllText(Path.Combine(config.ArtifactPipelineInfoFolder, "CIPlan.json"), JsonConvert.SerializeObject(CIPlan, Formatting.Indented));

return true;
}
Expand Down
52 changes: 50 additions & 2 deletions tools/ExecuteCIStep.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@
# is regenerated.
# ----------------------------------------------------------------------------------

# Usage: 1. This script can be called by build.proj used in CI pipeline
# 2. Can be used to do static analysis in local env. Such as: .\tools\ExecuteCIStep.ps1 -StaticAnalysisSignature -ModuleList "Accounts;Compute"
Param(
[Switch]
$Build,

[String]
$BuildAction='build',

[Switch]
$GenerateDocumentationFile,

[Switch]
$Test,

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

[String]
$TestOutputDirectory='artifacts\TestResults',
$TestOutputDirectory='artifacts/TestResults',

[String]
$StaticAnalysisOutputDirectory='artifacts\StaticAnalysisResults',
$StaticAnalysisOutputDirectory='artifacts/StaticAnalysisResults',

[String]
$ModuleList
)
$ErrorActionPreference = 'Stop'

If ($Build)
{
$LogFile = "$RepoArtifacts/Build.Log"
If ($GenerateDocumentationFile)
{
dotnet $BuildAction $RepoArtifacts/Azure.PowerShell.sln -c $Configuration -fl "/flp1:logFile=$LogFile;verbosity=quiet"
}
Else
{
dotnet $BuildAction $RepoArtifacts/Azure.PowerShell.sln -c $Configuration -p:GenerateDocumentationFile=false -fl "/flp1:logFile=$LogFile;verbosity=quiet"
}
$LogContent = Get-Content $LogFile
$BuildResultArray = @()
ForEach ($Line In $LogContent)
{
$Position, $ErrorOrWarningType, $Detail = $Line.Split(": ")
$Detail = Join-String -Separator ": " -InputObject $Detail
If ($Position.Contains("src"))
{
$ModuleName = $Position.Replace("\", "/").Split("src/")[1].Split('/')[0]
}
Else
{
$ModuleName = "dotnet"
}
$Type, $Code = $ErrorOrWarningType.Split(" ")
$BuildResultArray += @{
"Position" = $Position;
"Module" = $ModuleName;
"Type" = $Type;
"Code" = $Code;
"Detail" = $Detail
}
}
ConvertTo-Json -Depth 10 -InputObject $BuildResultArray | Out-File -FilePath "$RepoArtifacts/PipelineResult/Build.json"
}

If (-Not $PSBoundParameters.ContainsKey("ModuleList"))
{
$CIPlan = Get-Content $RepoArtifacts/PipelineResult/CIPlan.json | ConvertFrom-Json
Expand Down