diff --git a/build.proj b/build.proj index d776a3401491..f71ce3a39c7e 100644 --- a/build.proj +++ b/build.proj @@ -191,9 +191,9 @@ build publish - - - + + + diff --git a/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/CIFilterTask.cs b/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/CIFilterTask.cs index 70eb2c2d8a4d..0f1e48ed1b6e 100644 --- a/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/CIFilterTask.cs +++ b/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/CIFilterTask.cs @@ -397,13 +397,20 @@ private bool ProcessFileChanged(Dictionary csprojMap) FilterTaskResult.PhaseInfo = influencedModuleInfo; - influencedModuleInfo[string.Format("{0}-module", BUILD_PHASE)] = new HashSet(influencedModuleInfo[BUILD_PHASE].Select(GetModuleNameFromPath).Where(x => x != null)); - influencedModuleInfo[string.Format("{0}-module", TEST_PHASE)] = new HashSet(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> CIPlan = new Dictionary> + { + [BUILD_PHASE] = new HashSet(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(influencedModuleInfo[TEST_PHASE].Select(GetModuleNameFromPath).Where(x => x != null)) + }; + File.WriteAllText(Path.Combine(config.ArtifactPipelineInfoFolder, "CIPlan.json"), JsonConvert.SerializeObject(CIPlan, Formatting.Indented)); return true; } diff --git a/tools/ExecuteCIStep.ps1 b/tools/ExecuteCIStep.ps1 index 4f9ae61278d3..12adf7bc7efb 100644 --- a/tools/ExecuteCIStep.ps1 +++ b/tools/ExecuteCIStep.ps1 @@ -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, @@ -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