Skip to content

Commit

Permalink
Merge pull request #1 from Azure/main
Browse files Browse the repository at this point in the history
Sync main
  • Loading branch information
yifanz7 authored Dec 4, 2023
2 parents f71ec4d + 15223b7 commit 786d38e
Show file tree
Hide file tree
Showing 334 changed files with 16,750 additions and 30,439 deletions.
4 changes: 3 additions & 1 deletion .azure-pipelines/code-oob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ stages:
inputs:
command: custom
custom: msbuild
arguments: 'build.proj "/t:Clean;Build" /p:Configuration=Release'
arguments: 'build.proj "/t:Clean;Build" /p:Configuration=Release;TargetModule=${{ parameters.ServiceName }}'
- pwsh: |
.\tools\RunVersionController.ps1 -ModuleName "Az.${{ parameters.ServiceName }}”
displayName: 'Bump up version'
Expand Down Expand Up @@ -140,6 +140,8 @@ stages:
- template: ./code-sign.yml
parameters:
OOBBranch: $(BumpUpBranch)
TargetModule: ${{ parameters.ServiceName }}
BuildInstaller: false
- job: PulishForTest
dependsOn: Release
steps:
Expand Down
27 changes: 25 additions & 2 deletions .azure-pipelines/code-sign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ parameters:
displayName: Branch for OOB pipeline
type: string
default: 'none'
- name: TargetModule
displayName: Build Module List(Split by ':')
type: string
default: 'none'
- name: BuildInstaller
displayName: Build Installer
type: boolean
default: true
jobs:
- job: Release
timeoutInMinutes: 180
Expand Down Expand Up @@ -31,10 +39,19 @@ jobs:

- task: DotNetCoreCLI@2
displayName: Build
condition: ne('${{ parameters.TargetModule }}', 'none')
inputs:
command: custom
custom: msbuild
arguments: 'build.proj /t:"Build;CopyAboutTopics;GenerateHelp" /p:"Configuration=Release;GenerateDocumentationFile=true;TargetModule=${{ parameters.TargetModule }}"'
- task: DotNetCoreCLI@2
displayName: Build
condition: eq('${{ parameters.TargetModule }}', 'none')
inputs:
command: custom
custom: msbuild
arguments: 'build.proj /t:"Build;CopyAboutTopics;GenerateHelp" /p:"Configuration=Release;GenerateDocumentationFile=true"'
arguments: 'build.proj /t:"Build;CopyAboutTopics;GenerateHelp" /p:"Configuration=Release;GenerateDocumentationFile=true;ModifiedModuleBuild=true"'


- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
displayName: 'Manifest Generator '
Expand Down Expand Up @@ -359,9 +376,11 @@ jobs:
./setup/generate.ps1 -repository MSIcreationrepository
Unregister-PSRepository -Name MSIcreationrepository
displayName: 'Build Installer'
condition: eq(${{ parameters.buildInstaller }}, true)
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@4
displayName: 'Installer Signing [Authenticode]'
condition: eq(${{ parameters.buildInstaller }}, true)
inputs:
ConnectedServiceName: 'ESRP Signing Service'
FolderPath: setup
Expand Down Expand Up @@ -404,9 +423,11 @@ jobs:
Get-ChildItem $Env:RepoArtifacts/$folderName
Copy-Item $Env:RepoArtifacts/$Env:Configuration/InstallModule.ps1 -Destination $Env:RepoArtifacts/$folderName
displayName: 'Gather nuget packages and install script'
condition: eq(${{ parameters.buildInstaller }}, true)
- task: ArchiveFiles@2
displayName: 'Pack nuget packages as Az-Cmdlets-latest.tar.gz'
condition: eq(${{ parameters.buildInstaller }}, true)
inputs:
rootFolderOrFile: 'artifacts/$(LocalRepoName)'
includeRootFolder: false
Expand All @@ -432,9 +453,11 @@ jobs:
" - "+$sha256.Hash+"`n"
New-Item -Path "setup" -Name "ReleaseNotes.txt" -ItemType File -Force -Value $value
displayName: 'Rename Az-Cmdlets-latest.tar.gz and Calculate SHA256'
condition: eq(${{ parameters.buildInstaller }}, true)
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: installer'
condition: eq(${{ parameters.buildInstaller }}, true)
inputs:
PathtoPublish: setup
ArtifactName: setup
Expand Down Expand Up @@ -468,4 +491,4 @@ jobs:
Get-ChildItem -Path $Env:RepoArtifacts -Filter Az.*.0.*.*.nupkg | Compress-Archive -DestinationPath "$buildName-preview.zip" -PassThru | Set-AzStorageBlobContent -Container $(ContainerName) -Context $context -Force
azurePowerShellVersion: LatestVersion
pwsh: true
condition: and(succeeded(), eq(variables['PushPackageToStorageAccount'], 'true'))
condition: and(succeeded(), eq(variables['PushPackageToStorageAccount'], 'true'), eq(${{ parameters.buildInstaller }}, true))
2 changes: 1 addition & 1 deletion .azure-pipelines/daily-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
inputs:
command: custom
custom: msbuild
arguments: 'build.proj /t:Build /p:Configuration=Release;TurnOnTestCoverage=true'
arguments: 'build.proj /t:Build /p:Configuration=Release;TurnOnTestCoverage=true;ModifiedModuleBuild=true'

- task: EsrpCodeSigning@4
inputs:
Expand Down
11 changes: 8 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

<!-- Please add a brief description of the changes made in this PR. If you have an ongoing or finished cmdlet design, please paste the link below. -->

## Checklist
## Mandatory Checklist

- Please choose the target release of Azure PowerShell
- [ ] [General release](../blob/main/CONTRIBUTING.md#target-release-types)
- [ ] [Public preview](../blob/main/CONTRIBUTING.md#target-release-types)
- [ ] [Private preview](../blob/main/CONTRIBUTING.md#target-release-types)
- [ ] [Engineering build](../blob/main/CONTRIBUTING.md#target-release-types)
- [ ] N/A

- **Mandatory**: please state whether this PR targets a [**general** release](../blob/main/CONTRIBUTING.md#target-release-types) / [**public preview**](../blob/main/CONTRIBUTING.md#target-release-types) / [**private preview**]((../blob/main/CONTRIBUTING.md#target-release-types)) / [**engineering build**](../blob/main/CONTRIBUTING.md#target-release-types) of Azure PowerShell?
- `{Enter your answer here}`
- [ ] Check this box to confirm: **I have read the [_Submitting Changes_](../blob/main/CONTRIBUTING.md#submitting-changes) section of [`CONTRIBUTING.md`](../blob/main/CONTRIBUTING.md) and reviewed the following information:**

* **SHOULD** update `ChangeLog.md` file(s) appropriately
Expand Down
78 changes: 25 additions & 53 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
/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.
/p:ModifiedModuleBuild=True
Only build changed module according to the changelog in root folder or according to another property "TargetModule"
/p:TargetModule
Just focus on modules and its dependency such as Az.Account. Module name doesn't need to lead with Az. Split by ":"
-->
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

Expand All @@ -36,7 +38,9 @@
<TestFramework Condition="'$(TestFramework)' == ''">netcoreapp2.2</TestFramework>
<IsGenerateBased Condition="'$(IsGenerateBased)' != 'true'">false</IsGenerateBased>
<IsSecurityCheck Condition="'$(IsSecurityCheck)' != 'true'">false</IsSecurityCheck>
<ModifiedModuleBuild Condition="'$(ModifiedModuleBuild)' != 'true'">false</ModifiedModuleBuild>


<!-- Flags -->
<CodeSign Condition ="'$(CodeSign)' == ''">false</CodeSign>
<SkipHelp Condition ="'$(SkipHelp)' != 'true'">false</SkipHelp>
Expand All @@ -61,7 +65,7 @@
<!-- Testing related -->
<TestsToRun Condition="$(TestsToRun) == ''" >All</TestsToRun>
<CoreTests Condition="'$(TestsToRun)' != 'All'">$(RepoRoot)src/Compute/Compute.Test/Compute.Test.csproj;$(RepoRoot)src/Network/Network.Test/Network.Test.csproj;$(RepoRoot)src/Resources/Resources.Test/Resources.Test.csproj;$(RepoRoot)src/Sql/Sql.Test/Sql.Test.csproj;$(RepoRoot)src/Websites/Websites.Test/Websites.Test.csproj;</CoreTests>
<Net472TestExclude Condition="'$(TestFramework)' == 'net472'">$(RepoRoot)src/**/Automation.Test.csproj;$(RepoRoot)src/**/Storage.Test.csproj;</Net472TestExclude>
<CoreTests Condition="'$(CoreTests)' == ''">null</CoreTests>

<!-- CI build related -->
<CIToolsPath>$(OnPremiseBuildTasks)</CIToolsPath>
Expand Down Expand Up @@ -116,23 +120,23 @@
<Exec Command="dotnet publish $(RepoTools)StaticAnalysis/StaticAnalysis.Netcore.csproj -c $(Configuration)" />
</Target>

<Target Name="FilterBuild" Condition="$(PullRequestNumber) != '' OR $(TargetModule) != ''" DependsOnTargets="BuildTools">
<Target Name="FilterBuild" Condition="$(PullRequestNumber) != ''" DependsOnTargets="BuildTools">
<Message Importance="high" Text="Filtering projects and modules..." />

<Message Text="$(IsGenerateBased)" />
<!-- Build the Microsoft.Azure.Build.Tasks project -->
<Exec Command="dotnet publish $(RepoTools)BuildPackagesTask/Microsoft.Azure.Build.Tasks/Microsoft.Azure.Build.Tasks.csproj -c $(Configuration)" />

<!-- Get all of the files changed in the given pull request -->
<FilesChangedTask RepositoryOwner="Azure" RepositoryName="azure-powershell" PullRequestNumber="$(PullRequestNumber)" TargetModule="$(TargetModule)" OutputFile="$(RepoArtifacts)/FilesChanged.txt">
<FilesChangedTask RepositoryOwner="Azure" RepositoryName="azure-powershell" PullRequestNumber="$(PullRequestNumber)" OutputFile="$(RepoArtifacts)/FilesChanged.txt">
<Output TaskParameter="FilesChanged" ItemName="FilesChanged" />
</FilesChangedTask>

<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)PrepareAutorestModule.ps1&quot;" Condition="'$(IsGenerateBased)' == 'true'"/>
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)/CreateFilterMappings.ps1&quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)/PrepareForSecurityCheck.ps1&quot;" Condition="'$(IsSecurityCheck)' == 'true'"/>

<CIFilterTask FilesChanged="@(FilesChanged)" TargetModule="$(TargetModule)" Mode="$(Configuration)" CsprojMapFilePath="./CsprojMappings.json">
<CIFilterTask FilesChanged="@(FilesChanged)" Mode="$(Configuration)" CsprojMapFilePath="./CsprojMappings.json">
<Output TaskParameter="BuildCsprojList" ItemName="BuildCsprojList" />
<Output TaskParameter="TestCsprojList" ItemName="TestCsprojList" />
<Output TaskParameter="SubTasks" PropertyName="SubTasks" />
Expand All @@ -149,33 +153,24 @@
<Copy SourceFiles="$(RepoTools)after.Azure.PowerShell.sln.targets" DestinationFolder="$(RepoArtifacts)" />

<!-- 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="AzToolsPredictor" Condition="$(SubTasks.Contains('Predictor')) OR $(SubTasks.Contains('all'))" />
<CallTarget Targets="AzToolsInstaller" Condition="$(SubTasks.Contains('Installer')) OR $(SubTasks.Contains('all'))" />
</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'" />
<CsprojFiles Include="$(RepoRoot)src/**/*.Test.csproj" Exclude="$(CoreTests)$(Net472TestExclude)" Condition="'$(Configuration)' != 'Release' and '$(TestsToRun)' == 'NonCore'" />
<CsprojFiles Include="$(CoreTests)" Exclude="$(Net472TestExclude)" Condition="'$(Configuration)' != 'Release' and '$(TestsToRun)' == 'Core'" />
<CsprojFiles Include="$(RepoRoot)src/**/Authenticators.csproj" Condition="'$([MSBuild]::IsOsPlatform(&quot;Windows&quot;))' == 'true' and '$(TestFramework)' != 'net472'" />
</ItemGroup>
<ItemGroup Condition="$(PullRequestNumber) != ''">
<!-- Always build and test common code -->
<CsprojFiles Include="@(BuildCsprojList)" />
<CsprojFiles Include="@(TestCsprojList)" />
</ItemGroup>
<ItemGroup Condition="$(TargetModule) != ''">
<!-- Add test projects only if Configuration is not Release -->
<CsprojFiles Include="@(BuildCsprojList)" />
<CsprojFiles Include="@(TestCsprojList)" 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;" Condition="'@(CsprojFiles)' != ''" />
<Exec Condition="$(PullRequestNumber) == '' AND $(TargetModule) == '' AND $(ModifiedModuleBuild) == 'false'"
Command="$(PowerShellCoreCommandPrefix) &quot;.\tools\BuildScripts\BuildModules.ps1 -RepoRoot $(RepoRoot) -Configuration $(Configuration) -TestsToRun $(TestsToRun) -CoreTests $(CoreTests) -RepoArtifacts $(RepoArtifacts) &quot;"
/>
<Exec Condition="$(PullRequestNumber) != ''"
Command="$(PowerShellCoreCommandPrefix) &quot;.\tools\BuildScripts\BuildModules.ps1 -RepoRoot $(RepoRoot) -Configuration $(Configuration) -TestsToRun $(TestsToRun) -CoreTests $(CoreTests) -RepoArtifacts $(RepoArtifacts) -BuildCsprojList '@(BuildCsprojList)' -TestCsprojList '@(TestCsprojList)'&quot;"
/>
<Exec Condition="$(ModifiedModuleBuild) != 'false'"
Command="$(PowerShellCoreCommandPrefix) &quot;.\tools\BuildScripts\BuildModules.ps1 -RepoRoot $(RepoRoot) -Configuration $(Configuration) -TestsToRun $(TestsToRun) -CoreTests $(CoreTests) -RepoArtifacts $(RepoArtifacts) -ModifiedModuleBuild $(ModifiedModuleBuild) &quot;"
/>
<Exec Condition="$(TargetModule) != ''"
Command="$(PowerShellCoreCommandPrefix) &quot;.\tools\BuildScripts\BuildModules.ps1 -RepoRoot $(RepoRoot) -Configuration $(Configuration) -TestsToRun $(TestsToRun) -CoreTests $(CoreTests) -RepoArtifacts $(RepoArtifacts) -TargetModule $(TargetModule)&quot;"
/>
<PropertyGroup>
<BuildAction Condition="'$(Configuration)' != 'Release'">build</BuildAction>
<BuildAction Condition="'$(Configuration)' == 'Release'">publish</BuildAction>
Expand Down Expand Up @@ -251,11 +246,6 @@
<Error Text="StaticAnalysis has failed. Please follow the instructions on this doc: https://github.com/Azure/azure-powershell/blob/master/documentation/Debugging-StaticAnalysis-Errors.md" />
</Target>

<Target Name="ChangeLogCheck">
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/CheckChangeLog.ps1 -FilesChanged '@(FilesChanged)'&quot;" Condition=" '$(Scope)' == 'All' or '$(Scope)' == 'Latest' " />
<OnError ExecuteTargets="ChangeLogErrorMessage" />
</Target>

<Target Name="AzToolsInstaller">
<Exec Command='dotnet msbuild $(RepoTools)/Az.Tools.Installer/build.proj /t:"clean;build;test"' />
</Target>
Expand All @@ -264,22 +254,18 @@
<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>

<Target Name="Publish" Condition="'$(Configuration)' == 'Release'">
<Message Importance="high" Text="Publishing Cmdlets using $(Scope) scope" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/NewOutputTypeIndex.ps1 -OutputFile $(RepoArtifacts)/outputtypes.json -BuildConfig $(Configuration)&quot;" Condition="'$(TargetModule)' == ''"/>
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/NewHelpIndex.ps1 -OutputFile $(RepoArtifacts)/index.json -BuildConfig $(Configuration)&quot;" Condition="'$(TargetModule)' == ''"/>
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/NewOutputTypeIndex.ps1 -OutputFile $(RepoArtifacts)/outputtypes.json -BuildConfig $(Configuration)&quot;"/>
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/NewHelpIndex.ps1 -OutputFile $(RepoArtifacts)/index.json -BuildConfig $(Configuration)&quot;"/>

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

<Error Condition="'$(NuGetKey)' == ''" Text="You must provide the NuGetKey parameter to the build: /p:NuGetKey=YOUR_PUBLISHING_KEY" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/PublishModules.ps1 -IsNetCore:$$(NetCore) -BuildConfig $(Configuration) -Scope $(Scope) -ApiKey $(NuGetKey) -RepositoryLocation \&quot;$(NuGetPublishingSource)\&quot;&quot; -NugetExe $(NuGetCommand)" />
</Target>

<Target Name="BuildInstaller" AfterTargets="Publish" Condition="('$(Scope)' == 'All' or '$(Scope)' == 'Latest' or '$(Scope)' == 'Netcore') and '$(TargetModule)' == ''">
<Target Name="BuildInstaller" AfterTargets="Publish" Condition="('$(Scope)' == 'All' or '$(Scope)' == 'Latest' or '$(Scope)' == 'Netcore')">
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. Register-PSRepository -Name MSIcreationrepository -SourceLocation $(RepoArtifacts) -InstallationPolicy Trusted &quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoRoot)/setup/generate.ps1 -repository MSIcreationrepository &quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. Unregister-PSRepository -Name MSIcreationrepository &quot;" />
Expand All @@ -301,20 +287,6 @@
<OnError ExecuteTargets="TestFailureErrorMessage" />
</Target>

<Target Name="TestNet472" Condition="'$(TestFramework)' == 'net472'">
<PropertyGroup>
<PowerShellCommandPrefix>powershell -NonInteractive -NoLogo -NoProfile -Command</PowerShellCommandPrefix>
</PropertyGroup>
<Message Importance="high" Text="Running check in tests..." />
<MakeDir Directories="$(TestOutputDirectory)" ContinueOnError="false" />
<Exec Command="dotnet build $(RepoArtifacts)Azure.PowerShell.sln -c $(Configuration)" />
<Exec Command="dotnet new console -n Net472Tests" />
<Exec Command="dotnet add Net472Tests package xunit.runner.console --version 2.4.0" />
<Exec Command="dotnet restore --packages $(RepoArtifacts)/xUnit -f --no-cache Net472Tests" />
<Exec Command="$(PowerShellCommandPrefix) &quot;$(RepoTools)/TestNet472Modules.ps1 -TestExecPath '$(RepoArtifacts)/xUnit/xunit.runner.console/2.4.0/tools/net472/xunit.console.exe'&quot;" />
<OnError ExecuteTargets="TestFailureErrorMessage" />
</Target>

<Target Name="TestFailureErrorMessage">
<Error Text="Test failures occurred, check the files in artifacts/TestResults" />
</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Describe 'Remove-AzADDomainService' {
It 'DeleteViaIdentity' {
$ReplicaSet = New-AzADDomainServiceReplicaSetObject -Location $env.Location -SubnetId $env.SubnetId
$NewAdDomain = New-AzADDomainService -name $env.ADdomainName -ResourceGroupName $env.ResourceGroupName -DomainName $env.ADDomainNameCom -ReplicaSet $ReplicaSet
# Start-Sleep -s 120
$GetADDomainExample = Get-AzADDomainService -ResourceGroupName $env.ResourceGroupName -Name $env.ADdomainName
Remove-AzADDomainService -InputObject $GetADDomainExample
$GetADDomainList = Get-AzADDomainService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Describe 'Update-AzADDomainService' {
}

It 'UpdateViaIdentityExpanded' {
# Start-Sleep -s 240
$GetADDomainExample = Get-AzADDomainService -ResourceGroupName $env.ResourceGroupName -Name $env.ADdomainName
$UpdateADDomain = Update-AzADDomainService -InputObject $GetADDomainExample -DomainSecuritySettingTlsV1 $env.TlsV1Status2
$UpdateADDomain.DomainSecuritySettingTlsV1 | Should -Be $env.TlsV1Status2
Expand Down
Loading

0 comments on commit 786d38e

Please sign in to comment.