Skip to content

Commit

Permalink
Optimize for CI filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
wyunchi-ms committed Jan 27, 2021
1 parent 41def27 commit 83fb93a
Show file tree
Hide file tree
Showing 10 changed files with 995 additions and 46 deletions.
182 changes: 182 additions & 0 deletions .ci-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# module: this module
# dependent-module: self and modules that self dependent on
# dependence-module: self and modules dependent on this module
# related-module: self, modules that self dependent on and modules dependent on this module
rules:
- patterns:
- .azure-pipeline/*
- NugGet.Config
- Repo.props
phases:
- build:all
- breaking-change:all
- dependence:all
- help:all
- signature:all
- test:all
- sub-task:all
- patterns:
- src/*.props
phases:
- build:all
- dependence:all
- test:all
- patterns:
- src/lib/*
phases:
- build:all
- dependence:all
- patterns:
- docker/*
- .github/*
- setup/*
- .dockerignore
- .git*
- appveyor.yml
- CONTRIBUTION.md
- LICENSE.txt
- README.md
- '**/ChangeLog.md'
- '**/readme.md'
- src/**/document/*
phases: []
- patterns:
- src/{ModuleName}/test/*
- src/{ModuleName}/*.Test/*
phases:
- build:dependent-module
- test:module
- patterns:
- src/{ModuleName}/**/*.md
phases:
- build:module
- help:module
- patterns:
- src/{ModuleName}/**/*.csproj
phases:
- build:related-module
- dependence:dependence-module
- test:dependence-module
- patterns:
- src/{ModuleName}/*
phases:
- build:related-module
- breaking-change:module
- help:module
- signature:module
- test:dependence-module
- patterns:
- tools/StaticAnalysis/Exceptions/{ModuleName}/MissingAssemblies.csv
- tools/StaticAnalysis/Exceptions/{ModuleName}/AssemblyVersionConflict.csv
- tools/StaticAnalysis/Exceptions/{ModuleName}/ExtraAssemblies.csv
- tools/StaticAnalysis/Exceptions/{ModuleName}/SharedAssemblyConflict.csv
phases:
- build:module
- dependence:module
- patterns:
- tools/StaticAnalysis/Exceptions/{ModuleName}/BreakingChangeIssues.csv
phases:
- build:module
- breaking-change:module
- patterns:
- tools/StaticAnalysis/Exceptions/{ModuleName}/HelpIssues.csv
phases:
- build:module
- help:module
- patterns:
- tools/StaticAnalysis/Exceptions/{ModuleName}/SignatureIssues.csv
phases:
- build:module
- signature:module
- patterns:
- tools/StaticAnalysis/*
- tools/Tools.Common/*
phases:
- build:all
- breaking-change:all
- dependence:all
- help:all
- signature:all
- patterns:
- tools/Az.Tools.Predictor/*
phases:
- sub-task:Predictor
- patterns:
- tools/Az.Tools.Installer/*
phases:
- sub-task:Installer
- patterns:
- tools/AddModulePsm1Dependency.ps1
- tools/Common.Netcore.Dependencies.targets
- tools/AzureRM.Example.psm1
phases:
- build:all
- breaking-change:all
- dependence:all
- help:all
- signature:all
- test:all
- patterns:
- tools/GenerateHelp.ps1
- tools/HelpGeneration/*
phases:
- build:all
- help:all
- patterns:
- tools/CheckAssemblies.ps1
phases:
- build:all
- dependence:all
- patterns:
- tools/CheckSignature.ps1
phases:
- build:all
- signature:all
- patterns:
- tools/Common.Netcore.Dependencies.Test.targets
phases:
- build:all
- test:all
- patterns:
- tools/ARMIncrementVersion.ps1
- tools/ARMSyncVersion.ps1
- tools/ASMIncrementVersion.ps1
- tools/AzureRM.Example.psm1
- tools/BuildInstaller.ps1
- tools/CheckChangeLog.ps1
- tools/CheckIgnoredFile.ps1
- tools/CleanupBuild.ps1
- tools/CommonIncrementVersion.ps1
- tools/CreateAliasMapping.ps1
- tools/CreateFilterMappings.ps1
- tools/CreateMappings_rules.json
- tools/CreateMappings.ps1
- tools/CreateRegistryEntry.ps1
phases: []
- patterns:
- tools/Az/*
- tools/BatchModelGenerator/*
- tools/BreakingChanges/*
- tools/Docker/*
- tools/FormatPs1XmlGenerator/*
- tools/Gen2Master/*
- tools/InstallationTests/*
- tools/Installer/*
- tools/NetCoreCsProjSync/*
- tools/NetCorePsd1Sync/*
- tools/ProjectTemplates/*
- tools/RepoTasks/*
- tools/SecurityTools/*
- tools/Test/*
- tools/Tools.Common.Test/*
- tools/VersionController/*
phases: []
- patterns:
- others
phases:
- build:all
- breaking-change:all
- dependence:all
- help:all
- signature:all
- test:all
108 changes: 80 additions & 28 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<UsingTask TaskName="ESRPSignTask" AssemblyFile="$(CISignRepoPath)/tools/sdkbuildtools/tasks/MS.Az.Sdk.OnPremise.Build.Tasks.dll" />
<UsingTask TaskName="FilesChangedTask" AssemblyFile="$(RepoArtifacts)Microsoft.Azure.Build.Tasks/Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="FilterTask" AssemblyFile="$(RepoArtifacts)Microsoft.Azure.Build.Tasks/Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="CIFilterTask" AssemblyFile="$(RepoArtifacts)Microsoft.Azure.Build.Tasks/Microsoft.Azure.Build.Tasks.dll" />

<Target Name="Clean">
<Message Importance="high" Text="Cleaning Cmdlets..." />
Expand Down Expand Up @@ -119,23 +120,33 @@
<Output TaskParameter="FilesChanged" ItemName="FilesChanged" />
</FilesChangedTask>

<!-- Get the list of modules changed -->
<FilterTask FilesChanged="@(FilesChanged)" MapFilePath="./ModuleMappings.json" TargetModule="$(TargetModule)">
<Output TaskParameter="Output" ItemName="ModulesChanged" />
</FilterTask>
<Message Importance="high" Text="Filtering help generation and StaticAnalysis by the following modules:" />
<Message Importance="high" Text="%(ModulesChanged.Identity)" />
<Message Importance="high" Text="Total: @(ModulesChanged->Count())" />
<Message Importance="high" Text="" />

<!-- Get the list of projects to build -->
<FilterTask FilesChanged="@(FilesChanged)" MapFilePath="./CsprojMappings.json" TargetModule="$(TargetModule)">
<Output TaskParameter="Output" ItemName="ProjectsToBuild" />
</FilterTask>
<Message Importance="high" Text="Filtering projects to build by the following:" />
<Message Importance="high" Text="%(ProjectsToBuild.Identity)" />
<Message Importance="high" Text="Total: @(ProjectsToBuild->Count())" />
<Message Importance="high" Text="" />
<CIFilterTask FilesChanged="@(FilesChanged)" TargetModule="$(TargetModule)" Mode="$(Configuration)" CsprojMapFilePath="./CsprojMappings.json">
<Output TaskParameter="FilterTaskResult" ItemName="FilterTaskResult" />
</CIFilterTask>
<CreateProperty
Value="%(FilterTaskResult.build)">
<Output
TaskParameter="Value"
PropertyName="BuildCsprojList" />
</CreateProperty>
<CreateProperty
Value="%(FilterTaskResult.test)">
<Output
TaskParameter="Value"
PropertyName="TestCsprojList" />
</CreateProperty>
<CreateProperty
Value="%(FilterTaskResult.sub-task)">
<Output
TaskParameter="Value"
PropertyName="SubTasks" />
</CreateProperty>
<CreateProperty
Value="@(BuildCsprojList->Split(`;`)->Count())">
<Output
TaskParameter="Value"
PropertyName="IsBuildListEmpty" />
</CreateProperty>
</Target>

<!-- Build all flavors of the Cmdlets -->
Expand All @@ -150,6 +161,13 @@
<!-- Build and create package content -->
<Exec Command="dotnet --version" />
<Exec Command="dotnet new sln -n Azure.PowerShell -o $(RepoArtifacts) --force" />
<CallTarget Targets="BuildNormalModules" />

<CallTarget Targets="Predictor" Condition="$(SubTasks.Contains('predictor'))" />
<CallTarget Targets="Installer" Condition="$(SubTasks.Contains('installer'))" />
</Target>

<Target Name="BuildNormalModules">
<ItemGroup Condition="$(PullRequestNumber) == '' AND $(TargetModule) == ''">
<CsprojFiles Include="$(RepoRoot)src/**/*.csproj" Exclude="$(RepoRoot)src/**/*.Test.csproj;$(RepoRoot)src/**/Authenticators.csproj" />
<CsprojFiles Include="$(RepoRoot)src/**/*.Test.csproj" Exclude="$(Net472TestExclude)" Condition="'$(Configuration)' != 'Release' and '$(TestsToRun)' == 'All'" />
Expand All @@ -159,17 +177,13 @@
</ItemGroup>
<ItemGroup Condition="$(PullRequestNumber) != ''">
<!-- Always build and test common code -->
<CsprojFiles Include="$(LibraryRoot)src/Accounts/**/*.csproj;$(LibraryRoot)tools/TestFx/TestFx.csproj" Exclude="$(LibraryRoot)src/**/Authenticators.csproj" />
<CsprojFiles Include="%(ProjectsToBuild.Identity)" />
<CsprojFiles Include="$(LibraryRoot)src/**/Authenticators.csproj" Condition="'$([MSBuild]::IsOsPlatform(&quot;Windows&quot;))' == 'true'" />
<CsprojFiles Include="$(BuildCsprojList.Split(`;`))" />
<CsprojFiles Include="$(TestCsprojList.Split(`;`))" />
</ItemGroup>
<ItemGroup Condition="$(TargetModule) != ''">
<!-- Add test projects only if Configuration is not Release -->
<CsprojFiles Include="$(LibraryRoot)src/Accounts/**/*.csproj;$(LibraryRoot)tools/TestFx/TestFx.csproj" Exclude="$(LibraryRoot)src/**/Authenticators.csproj" Condition="'$(Configuration)' != 'Release'" />
<CsprojFiles Include="$(LibraryRoot)src/Accounts/**/*.csproj" Exclude="$(RepoRoot)src/**/*.Test.csproj;$(LibraryRoot)src/**/Authenticators.csproj" Condition="'$(Configuration)' == 'Release'"/>
<CsprojFiles Include="%(ProjectsToBuild.Identity)" Condition="'$(Configuration)' != 'Release'" />
<CsprojFiles Include="%(ProjectsToBuild.Identity)" Exclude="$(RepoRoot)src/**/*.Test.csproj" Condition="'$(Configuration)' == 'Release'" />
<CsprojFiles Include="$(LibraryRoot)src/**/Authenticators.csproj" Condition="'$([MSBuild]::IsOsPlatform(&quot;Windows&quot;))' == 'true'" />
<CsprojFiles Include="$(BuildCsprojList.Split(`;`))" />
<CsprojFiles Include="$(TestCsprojList.Split(`;`))" Condition="'$(Configuration)' != 'Release'" />
</ItemGroup>
<!-- https://github.com/dotnet/cli/issues/6295#issuecomment-346973582 -->
<Exec Command="dotnet sln $(RepoArtifacts)Azure.PowerShell.sln add &quot;%(CsprojFiles.FullPath)&quot;" />
Expand Down Expand Up @@ -215,12 +229,42 @@
<!-- Everything except Publish -->
<Target Name="Full" DependsOnTargets="Clean;Build;OnPremChecks;GenerateHelp;StaticAnalysis;Test" />

<Target Name="StaticAnalysis" Condition="'$(RunStaticAnalysis)' == 'true'">
<Message Importance="high" Text="Running static analysis..." />
<Target Name="StaticAnalysisBreakingChange" Condition="'$(RunStaticAnalysis)' == 'true'" DependsOnTargets="Build">
<Message Importance="high" Text="Running static analysis for breaking change..." />
<MakeDir Directories="$(StaticAnalysisOutputDirectory)" />

<Exec Command="dotnet $(RepoArtifacts)StaticAnalysis/StaticAnalysis.Netcore.dll -p $(RepoArtifacts)$(Configuration) -r $(StaticAnalysisOutputDirectory) --analyzers breaking-change -u -m %(FilterTaskResult.breaking-change)" />
</Target>

<Target Name="StaticAnalysisDependency" Condition="'$(RunStaticAnalysis)' == 'true'" DependsOnTargets="Build">
<Message Importance="high" Text="Running static analysis for dependency..." />
<MakeDir Directories="$(StaticAnalysisOutputDirectory)" />

<Exec Command="dotnet $(RepoArtifacts)StaticAnalysis/StaticAnalysis.Netcore.dll -p $(RepoArtifacts)$(Configuration) -r $(StaticAnalysisOutputDirectory) --analyzers dependency -u -m %(FilterTaskResult.breaking-change)" />
</Target>

<Target Name="StaticAnalysisSignature" Condition="'$(RunStaticAnalysis)' == 'true'" DependsOnTargets="Build">
<Message Importance="high" Text="Running static analysis for signature..." />
<MakeDir Directories="$(StaticAnalysisOutputDirectory)" />

<Exec Command="dotnet $(RepoArtifacts)StaticAnalysis/StaticAnalysis.Netcore.dll -p $(RepoArtifacts)$(Configuration) -r $(StaticAnalysisOutputDirectory) -s -u -m @(ModulesChanged)" />
<Exec Command="dotnet $(RepoArtifacts)StaticAnalysis/StaticAnalysis.Netcore.dll -p $(RepoArtifacts)$(Configuration) -r $(StaticAnalysisOutputDirectory) --analyzers signature -u -m %(FilterTaskResult.breaking-change)" />
</Target>

<Target Name="StaticAnalysisHelp" Condition="'$(RunStaticAnalysis)' == 'true'" DependsOnTargets="Build">
<Message Importance="high" Text="Running static analysis for help..." />
<MakeDir Directories="$(StaticAnalysisOutputDirectory)" />

<Exec Command="dotnet $(RepoArtifacts)StaticAnalysis/StaticAnalysis.Netcore.dll -p $(RepoArtifacts)$(Configuration) -r $(StaticAnalysisOutputDirectory) --analyzers help -u -m %(FilterTaskResult.breaking-change)" />
</Target>

<!-- <Target Name="StaticAnalysis" DependsOnTargets="StaticAnalysisBreakingChange;StaticAnalysisDependency;StaticAnalysisSignature;StaticAnalysisHelp"> -->
<Target Name="StaticAnalysis">
<Exec Command="dotnet publish $(RepoTools)StaticAnalysis/StaticAnalysis.Netcore.csproj -c $(Configuration) -f netcoreapp2.1" />
<Message Importance="high" Text="Running static analysis..." />

<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/CheckAssemblies.ps1 -BuildConfig $(Configuration) &quot;" />

<Exec Command="dotnet $(RepoArtifacts)StaticAnalysis/StaticAnalysis.Netcore.dll -p $(RepoArtifacts)$(Configuration) -r $(StaticAnalysisOutputDirectory) --analyzers check-error" />
<OnError ExecuteTargets="StaticAnalysisErrorMessage" />
</Target>

Expand All @@ -233,6 +277,14 @@
<OnError ExecuteTargets="ChangeLogErrorMessage" />
</Target>

<Target Name="Installer">
<Exec Command="dotnet msbuild $(RepoTools)/Az.Tools.Installer/build.proj /t:clean;build;test" />
</Target>

<Target Name="Predictor">
<Exec Command="dotnet msbuild $(RepoTools)/Az.Tools.Predictor/build.proj /t:clean;build;test" />
</Target>

<Target Name="ChangeLogErrorMessage">
<Error Text="Modified files were found with no update to their change log. Please add a snippet to the affected modules' change log." />
</Target>
Expand Down
Loading

0 comments on commit 83fb93a

Please sign in to comment.