Skip to content

Commit 71932d1

Browse files
authored
Run a selected module list instead of run all the modules to speed up the CI process. (#17850)
1 parent 3be834a commit 71932d1

File tree

2 files changed

+51
-11
lines changed

2 files changed

+51
-11
lines changed

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

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,18 @@ private List<string> GetBuildCsprojList(string moduleName, Dictionary<string, st
122122
{
123123
if (moduleName.Equals(AllModule))
124124
{
125-
moduleName = ACCOUNT_MODULE_NAME;
125+
HashSet<string> csprojSet = new HashSet<string>();
126+
foreach (string m in GetSelectedModuleList())
127+
{
128+
csprojSet.UnionWith(GetBuildCsprojList(m, csprojMap));
129+
}
130+
return csprojSet.ToList();
131+
}
132+
else
133+
{
134+
return GetRelatedCsprojList(moduleName, csprojMap)
135+
.Where(x => !x.Contains("Test")).ToList();
126136
}
127-
return GetRelatedCsprojList(moduleName, csprojMap)
128-
.Where(x => !x.Contains("Test")).ToList();
129137
}
130138

131139
private string GetModuleNameFromCsprojPath(string csprojPath)
@@ -137,6 +145,10 @@ private string GetModuleNameFromCsprojPath(string csprojPath)
137145

138146
private List<string> GetDependenceModuleList(string moduleName, Dictionary<string, string[]> csprojMap)
139147
{
148+
if (moduleName.Equals(ACCOUNT_MODULE_NAME))
149+
{
150+
return GetSelectedModuleList();
151+
}
140152
List<string> moduleList = new List<string>();
141153

142154
foreach (string key in csprojMap.Keys)
@@ -162,22 +174,45 @@ private List<string> GetDependentModuleList(string moduleName, Dictionary<string
162174
{
163175
if (moduleName.Equals(AllModule))
164176
{
165-
moduleName = ACCOUNT_MODULE_NAME;
177+
HashSet<string> csprojSet = new HashSet<string>();
178+
foreach (string m in GetSelectedModuleList())
179+
{
180+
csprojSet.UnionWith(GetDependentModuleList(m, csprojMap));
181+
}
182+
return csprojSet.ToList();
183+
}
184+
else
185+
{
186+
return GetRelatedCsprojList(moduleName, csprojMap)
187+
.Select(GetModuleNameFromCsprojPath)
188+
.Distinct()
189+
.ToList();
166190
}
167-
return GetRelatedCsprojList(moduleName, csprojMap)
168-
.Select(GetModuleNameFromCsprojPath)
169-
.Distinct()
170-
.ToList();
191+
}
192+
193+
// Run a selected module list instead of run all the modules to speed up the CI process.
194+
private List<string> GetSelectedModuleList()
195+
{
196+
string[] lines = System.IO.File.ReadAllLines(@"./tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/SelectedModuleList.txt");
197+
return new List<string>(lines);
171198
}
172199

173200
private List<string> GetTestCsprojList(string moduleName, Dictionary<string, string[]> csprojMap)
174201
{
175202
if (moduleName.Equals(AllModule))
176203
{
177-
moduleName = ACCOUNT_MODULE_NAME;
204+
HashSet<string> csprojSet = new HashSet<string>();
205+
foreach (string m in GetSelectedModuleList())
206+
{
207+
csprojSet.UnionWith(GetTestCsprojList(m, csprojMap));
208+
}
209+
return csprojSet.ToList();
210+
}
211+
else
212+
{
213+
return GetRelatedCsprojList(moduleName, csprojMap)
214+
.Where(x => x.Contains("Test")).ToList();;
178215
}
179-
return GetRelatedCsprojList(moduleName, csprojMap)
180-
.Where(x => x.Contains("Test")).ToList();;
181216
}
182217

183218
private bool ProcessTargetModule(Dictionary<string, string[]> csprojMap)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Accounts
2+
KeyVault
3+
Network
4+
Compute
5+
Storage

0 commit comments

Comments
 (0)