diff --git a/build.proj b/build.proj index 240e20daa291..588c191a9f8a 100644 --- a/build.proj +++ b/build.proj @@ -18,6 +18,8 @@ /p:Scope 'Subfolder under src': An individual cmdlet module By default, it builds everything + /p:TargetModule + Just focus on one module and its dependency such as Az.Account. Module name doesn't need to lead with Az. /p:SkipHelp=True Skips help generation, mainly for local builds to save time. --> @@ -118,7 +120,7 @@ - + @@ -127,7 +129,7 @@ - + @@ -237,8 +239,8 @@ - - + + @@ -246,7 +248,7 @@ - + diff --git a/src/StackHCI/Properties/AssemblyInfo.cs b/src/StackHCI/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..2227b527436a --- /dev/null +++ b/src/StackHCI/Properties/AssemblyInfo.cs @@ -0,0 +1,28 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Microsoft Azure Powershell - StackHCI")] +[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)] +[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)] +[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)] + +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] +[assembly: Guid("8853A329-2E41-4A6A-808B-9D1170A5BBB4")] +[assembly: AssemblyVersion("0.2.0")] +[assembly: AssemblyFileVersion("0.2.0")] \ No newline at end of file diff --git a/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilesChangedTask.cs b/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilesChangedTask.cs index 7ff4435dadf9..f4e9ab4fa0d3 100644 --- a/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilesChangedTask.cs +++ b/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilesChangedTask.cs @@ -44,7 +44,7 @@ public class FilesChangedTask : Task public string PullRequestNumber { get; set; } /// - /// Gets or set the TargetModule, e.g. Az.Storage + /// Gets or set the TargetModule, e.g. Storage /// public string TargetModule { get; set; } @@ -137,11 +137,6 @@ public override bool Execute() FilesChanged = filesChanged.ToArray(); } - else if(!string.IsNullOrEmpty(TargetModule)) - { - //Add one FAKE changed file for TargetModule, so TargetModule will be included for FilterTask - FilesChanged = new string[] { $"src/{TargetModule}/changeLog.md" }; - } else { FilesChanged = new string[] { }; diff --git a/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilterTask.cs b/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilterTask.cs index 48048f79f854..b2e4afe1d0fd 100644 --- a/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilterTask.cs +++ b/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilterTask.cs @@ -40,6 +40,11 @@ public class FilterTask : Task [Required] public string MapFilePath { get; set; } + /// + /// Gets or set the TargetModule, e.g. Storage + /// + public string TargetModule { get; set; } + /// /// Gets or sets the test assemblies output produced by the task. /// @@ -64,31 +69,26 @@ public override bool Execute() throw new FileNotFoundException("The MapFilePath provided could not be found. Please provide a valid MapFilePath."); } - var debugEnvironmentVariable = Environment.GetEnvironmentVariable("DebugLocalBuildTasks"); - bool debug; - if (!Boolean.TryParse(debugEnvironmentVariable, out debug)) - { - debug = false; - } + var mappingsDictionary = JsonConvert.DeserializeObject>(File.ReadAllText(MapFilePath)); if (FilesChanged != null && FilesChanged.Length > 0) { - Output = GetOutput(FilesChanged, MapFilePath); + Console.WriteLine($"Filter according to {FilesChanged.Length} file(s) in FilesChanged"); + var filesChangedSet = new HashSet(FilesChanged); + Output = SetGenerator.Generate(filesChangedSet, mappingsDictionary).ToArray(); + } + else if(!string.IsNullOrWhiteSpace(TargetModule)) + { + Console.WriteLine($"Filter module {TargetModule}"); + var modules = (TargetModule.Equals("Accounts"))? new string[] { "Accounts"} : new string[] { "Accounts" , TargetModule}; + Output = SetGenerator.Generate(modules, mappingsDictionary).ToArray(); } else { - if (debug) - { - Console.WriteLine("Debug: ModuleMapping.json"); - var lines = File.ReadAllLines(MapFilePath); - foreach (var line in lines) - { - Console.WriteLine(line); - } - } + Console.WriteLine($"Skip filter and load all from ${MapFilePath}"); var set = new HashSet(); - var dictionary = JsonConvert.DeserializeObject>(File.ReadAllText(MapFilePath)); - foreach (KeyValuePair pair in dictionary) + mappingsDictionary = JsonConvert.DeserializeObject>(File.ReadAllText(MapFilePath)); + foreach (KeyValuePair pair in mappingsDictionary) { set.UnionWith(pair.Value); } @@ -98,10 +98,5 @@ public override bool Execute() return true; } - - public string[] GetOutput(string[] filesChanged, string mapFilePath) - { - return SetGenerator.Generate(filesChanged, mapFilePath).ToArray(); - } } } diff --git a/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/SetGenerator.cs b/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/SetGenerator.cs index e4ef8f398684..c5431a4536f7 100644 --- a/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/SetGenerator.cs +++ b/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/SetGenerator.cs @@ -17,8 +17,6 @@ namespace Microsoft.WindowsAzure.Build.Tasks { using System; using System.Collections.Generic; - using Newtonsoft.Json; - using System.IO; using System.Linq; /// @@ -32,36 +30,6 @@ public static class SetGenerator /// public const int MaxFilesPossible = 300; - /// - /// Static method used to generate a set of tests to be run based on - /// a Json file which maps files to test Dlls. - /// - /// This is a set of paths. - /// This is the filepath of the map that contains - /// the mapping between files and test DLLs. - /// Set of tests to be run - public static IEnumerable Generate(IEnumerable filesChanged, string mapFilePath) - { - if (mapFilePath == null) - { - throw new ArgumentNullException("The mappings file path cannot be null."); - } - - if (!File.Exists(mapFilePath)) - { - throw new FileNotFoundException("The file path provided for the mappings could not be found."); - } - - if (filesChanged == null) - { - throw new ArgumentNullException("The list of files changed cannot be null."); - } - - var filesChangedSet = new HashSet(filesChanged); - var mappingsDictionary = JsonConvert.DeserializeObject>(File.ReadAllText(mapFilePath)); - - return SetGenerator.Generate(filesChangedSet, mappingsDictionary); - } /// /// Static method used to generate a set of tests to be run based on /// a set of paths @@ -89,7 +57,6 @@ public static HashSet Generate(HashSet filesChangedSet, Dictiona } var outputSet = new HashSet(); - var filesProvidedCount = filesChangedSet.Count; var filesFoundCount = 0; var useFullMapping = false; if (filesChangedSet.Count >= MaxFilesPossible || filesChangedSet.Count == 0) @@ -152,5 +119,34 @@ public static HashSet Generate(HashSet filesChangedSet, Dictiona return outputSet; } + /// + /// Generate set according to module names + /// + /// + /// + /// + public static HashSet Generate(string[] moduleNames, Dictionary mappingsDictionary) + { + var outputSet = new HashSet(); + + foreach (var module in moduleNames) + { + var key = $"src/{module}/"; + if (mappingsDictionary.ContainsKey(key)) + { + var lines = mappingsDictionary[key]; + foreach (var line in lines) + { + if (line.Contains($"/src/{module}/") || line.Contains($"\\src\\{module}\\") || line.Equals($"Az.{module}")) + { + outputSet.Add(line); + } + } + } + } + + return outputSet; + } + } } diff --git a/tools/CreateFilterMappings.ps1 b/tools/CreateFilterMappings.ps1 index 24060237a643..4b668785796e 100644 --- a/tools/CreateFilterMappings.ps1 +++ b/tools/CreateFilterMappings.ps1 @@ -148,7 +148,7 @@ function Add-ProjectDependencies [string]$SolutionPath ) - $CommonProjectsToIgnore = @( "Authentication", "Authentication.ResourceManager", "Authenticators", "ScenarioTest.ResourceManager", "TestFx", "Tests" ) + $CommonProjectsToIgnore = @("Authenticators", "ScenarioTest.ResourceManager", "TestFx", "Tests" ) $ProjectDependencies = @() $Content = Get-Content -Path $SolutionPath @@ -220,7 +220,7 @@ function Create-ModuleMappings $Script:ModuleMappings = Initialize-Mappings -PathsToIgnore $PathsToIgnore -CustomMappings $CustomMappings foreach ($ServiceFolder in $Script:ServiceFolders) { - $Key = "src/$($ServiceFolder.Name)" + $Key = "src/$($ServiceFolder.Name)/" $ModuleManifestFiles = Get-ChildItem -Path $ServiceFolder.FullName -Filter "*.psd1" -Recurse | Where-Object { $_.FullName -notlike "*.Test*" -and ` $_.FullName -notlike "*Release*" -and ` $_.FullName -notlike "*Debug*" -and ` diff --git a/tools/PublishModules.psm1 b/tools/PublishModules.psm1 index 59ef1d93b56b..d6c9e0ba7427 100644 --- a/tools/PublishModules.psm1 +++ b/tools/PublishModules.psm1 @@ -273,6 +273,12 @@ function Get-AllModules { Write-Host "Getting Azure client modules" $clientModules = Get-ClientModules -BuildConfig $BuildConfig -Scope $Scope -PublishLocal:$PublishLocal -IsNetCore:$isNetCore Write-Host " " + + if($clientModules.Length -le 2) { + return @{ + ClientModules = $clientModules + } + } Write-Host "Getting admin modules" $adminModules = Get-AdminModules -BuildConfig $BuildConfig -Scope $Scope