From a3dff10129de8e5b38a283dae7386cf077ac57de Mon Sep 17 00:00:00 2001 From: Abhijeet Date: Tue, 29 Nov 2016 16:21:04 -0800 Subject: [PATCH] Repo tasks add spn (#3211) * refactoring task modules * missed Refactoring modules * Making modular modules for various tasks * Added cmdlet to create Service Principal. Refactored Repo-Tasks to include multiple modular modules (e.g. Build-Tasks, TestFx-Tasks) * Removing SPN cmdlets --- tools/Modules/Build-Tasks.psd1 | 127 ++++++++++++ tools/Modules/Build-Tasks.psm1 | 99 ++++++++++ tools/Modules/TestFx-Tasks.psd1 | 126 ++++++++++++ tools/Modules/TestFx-Tasks.psm1 | 153 ++++++++++++++ tools/Modules/Tests/CommonTestUtil.psm1 | 21 ++ tools/Modules/Tests/RepoModuleTests.ps1 | 10 + tools/PS-VSPrompt.lnk | Bin 2210 -> 2180 bytes tools/PSRepoStart.cmd | 4 + tools/Repo-Tasks.psd1 | Bin 8118 -> 4058 bytes tools/Repo-Tasks.psm1 | 253 +----------------------- 10 files changed, 545 insertions(+), 248 deletions(-) create mode 100644 tools/Modules/Build-Tasks.psd1 create mode 100644 tools/Modules/Build-Tasks.psm1 create mode 100644 tools/Modules/TestFx-Tasks.psd1 create mode 100644 tools/Modules/TestFx-Tasks.psm1 create mode 100644 tools/Modules/Tests/CommonTestUtil.psm1 create mode 100644 tools/Modules/Tests/RepoModuleTests.ps1 create mode 100644 tools/PSRepoStart.cmd diff --git a/tools/Modules/Build-Tasks.psd1 b/tools/Modules/Build-Tasks.psd1 new file mode 100644 index 000000000000..abaee4402785 --- /dev/null +++ b/tools/Modules/Build-Tasks.psd1 @@ -0,0 +1,127 @@ +# +# Module manifest for module 'PSGet_Build-Tasks' +# +# Generated by: abhishah +# +# Generated on: 11/18/2016 +# + +@{ + +# Script module or binary module file associated with this manifest. +RootModule = 'Build-Tasks.psm1' + +# Version number of this module. +ModuleVersion = '1.0' + +# Supported PSEditions +# CompatiblePSEditions = @() + +# ID used to uniquely identify this module +GUID = 'cda2be3c-14a7-4c83-9393-d5ebad9df7e4' + +# Author of this module +Author = 'abhishah' + +# Company or vendor of this module +CompanyName = 'Microsoft' + +# Copyright statement for this module +Copyright = '(c) 2016 abhishah. All rights reserved.' + +# Description of the functionality provided by this module +# Description = '' + +# Minimum version of the Windows PowerShell engine required by this module +# PowerShellVersion = '' + +# Name of the Windows PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the Windows PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# DotNetFrameworkVersion = '' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# CLRVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +# RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = 'Get-BuildScopes', 'Start-Build', 'Invoke-CheckinTests', + 'Install-VSProjectTemplates' + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = @() + +# Variables to export from this module +# VariablesToExport = @() + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = @() + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + # LicenseUri = '' + + # A URL to the main website for this project. + # ProjectUri = '' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # External dependent modules of this module + # ExternalModuleDependencies = '' + + } # End of PSData hashtable + +} # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + diff --git a/tools/Modules/Build-Tasks.psm1 b/tools/Modules/Build-Tasks.psm1 new file mode 100644 index 000000000000..c6b235dd056a --- /dev/null +++ b/tools/Modules/Build-Tasks.psm1 @@ -0,0 +1,99 @@ +[CmdletBinding] +Function Get-BuildScopes +{ +<# +.SYNOPSIS +You can build a particular package rather than doing a full build by providing Build Scope. +This cmdlet will help to identify existing Scope available +This will enable to execute Start-RepoBuild + +#> + + Write-Host "Below are available scopes you can specify for building specific projects" + Write-Host "" + Get-ChildItem -path "$env:repoRoot\src\ResourceManager" -dir | Format-Wide -Column 5 | Format-Table -Property Name + Write-Host "e.g of a scope would be 'ResourceManager\Compute'" -ForegroundColor Yellow + + Get-ChildItem -path "$env:repoRoot\src\ServiceManagement" -dir -Exclude "ResourceManager" | Format-Wide -Column 5 | Format-Table -Property Name + Write-Host "e.g of a scope would be 'ServiceManagement\ExpressRoute'" -ForegroundColor Yellow +} + +[CmdletBinding] +Function Start-Build +{ +<# +.SYNOPSIS +This cmdlet will help to do either with full build or targeted build for specific scopes. + +.PARAMETER BuildScope +Use Get-BuildScope cmdLet to get list of existing scopes that can be used to build +#> + param( + [parameter(Mandatory=$false, Position=0, HelpMessage='BuildScope that you would like to use. For list of build scopes, run List-BuildScopes')] + [string]$BuildScope + ) + + if([string]::IsNullOrEmpty($BuildScope) -eq $true) + { + Write-Host "Starting Full build" + msbuild.exe "$env:repoRoot\build.proj" /t:Build + } + else + { + Write-Host "Building $BuildScope" + msbuild.exe "$env:repoRoot\build.proj" /t:Build /p:Scope=$BuildScope + } +} + +[CmdletBinding] +Function Invoke-CheckinTests +{ +<# +.SYNOPSIS +Runs all the check in tests +#> + Write-Host "cmdline Args: msbuild.exe $env:repoRoot\build.proj /t:Test" + msbuild.exe "$env:repoRoot\build.proj" /t:Test +} + +[cmdletBinding] +Function Install-VSProjectTemplates +{ +<# +.SYNOPSIS + +Install-VSProjectTemplates will install getting started project templates for +1) Autorest-.NET SDKProject +2) .NET SDK Test projectct + +After executing the cmdlet, restart VS (if already open), create new project +Search for the project template as we install the following three project templates +AutoRest-AzureDotNetSDK +AzureDotNetSDK-TestProject +AzurePowerShell-TestProject +#> + if($env:VisualStudioVersion -eq "14.0") + { + if((Test-Path "$env:repoRoot\tools\ProjectTemplates\") -eq $true) + { + Write-Host "Installing VS templates for 'AutoRest as well as Test Project'" + Copy-Item "$env:repoRoot\tools\ProjectTemplates\*.zip" "$env:USERPROFILE\Documents\Visual Studio 2015\Templates\ProjectTemplates\" + Write-Host "Installed VS Test Project Templates for Powershell test projects" + Write-Host "" + Write-Host "Restart VS (if already open), search for 'AzurePowerShell-TestProject'" -ForegroundColor Yellow + } + else + { + Write-Host "Missing templates to install, make sure you have project templates available in the repo under $env:repoRoot\tools\ProjectTemplates\" + } + } + else + { + Write-Host "Unsupported VS Version detected. Visual Studio 2015 is the only supported version for current set of project templates" + } +} + +export-modulemember -Function Get-BuildScopes +export-modulemember -Function Start-Build +export-modulemember -Function Invoke-CheckinTests +export-modulemember -Function Install-VSProjectTemplates \ No newline at end of file diff --git a/tools/Modules/TestFx-Tasks.psd1 b/tools/Modules/TestFx-Tasks.psd1 new file mode 100644 index 000000000000..d5709e08e2fa --- /dev/null +++ b/tools/Modules/TestFx-Tasks.psd1 @@ -0,0 +1,126 @@ +# +# Module manifest for module 'PSGet_TestFx-Tasks' +# +# Generated by: ShahAbhijeet +# +# Generated on: 11/18/2016 +# + +@{ + +# Script module or binary module file associated with this manifest. +RootModule = 'TestFx-Tasks.psm1' + +# Version number of this module. +ModuleVersion = '1.0' + +# Supported PSEditions +# CompatiblePSEditions = @() + +# ID used to uniquely identify this module +GUID = '676f988a-1745-4263-bb86-5887d6b1f9f3' + +# Author of this module +Author = 'ShahAbhijeet' + +# Company or vendor of this module +CompanyName = 'Microsoft' + +# Copyright statement for this module +Copyright = '(c) 2016 ShahAbhijeet. All rights reserved.' + +# Description of the functionality provided by this module +# Description = '' + +# Minimum version of the Windows PowerShell engine required by this module +# PowerShellVersion = '' + +# Name of the Windows PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the Windows PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# DotNetFrameworkVersion = '' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# CLRVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +# RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = 'Set-TestEnvironment', 'Remove-ServicePrincipal', 'New-ServicePrincipal', 'Set-SPNRole' + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = @() + +# Variables to export from this module +# VariablesToExport = @() + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = @() + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + # LicenseUri = '' + + # A URL to the main website for this project. + # ProjectUri = '' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # External dependent modules of this module + # ExternalModuleDependencies = '' + + } # End of PSData hashtable + +} # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + diff --git a/tools/Modules/TestFx-Tasks.psm1 b/tools/Modules/TestFx-Tasks.psm1 new file mode 100644 index 000000000000..6ff09e64f655 --- /dev/null +++ b/tools/Modules/TestFx-Tasks.psm1 @@ -0,0 +1,153 @@ +[CmdletBinding] +Function Set-TestEnvironment +{ +<# +.SYNOPSIS +This cmdlet helps you to setup Test Environment for running tests +In order to successfully run a test, you will need SubscriptionId, TenantId +This cmdlet will only prompt you for Subscription and Tenant information, rest all other parameters are optional + +#> + [CmdletBinding(DefaultParameterSetName='UserIdParamSet')] + param( + [Parameter(ParameterSetName='UserIdParamSet', Mandatory=$true, HelpMessage = "UserId (OrgId) you would like to use")] + [ValidateNotNullOrEmpty()] + [string]$UserId, + + [Parameter(ParameterSetName='UserIdParamSet', Mandatory=$true, HelpMessage = "UserId (OrgId) you would like to use")] + [ValidateNotNullOrEmpty()] + [string]$Password, + + [Parameter(ParameterSetName='SpnParamSet', Mandatory=$true, HelpMessage='ServicePrincipal/ClientId you would like to use')] + [ValidateNotNullOrEmpty()] + [string]$ServicePrincipal, + + [Parameter(ParameterSetName='SpnParamSet', Mandatory=$true, HelpMessage='ServicePrincipal Secret/ClientId Secret you would like to use')] + [ValidateNotNullOrEmpty()] + [string]$ServicePrincipalSecret, + + [Parameter(ParameterSetName='SpnParamSet', Mandatory=$true)] + [Parameter(ParameterSetName='UserIdParamSet', Mandatory=$true, HelpMessage = "SubscriptionId you would like to use")] + [ValidateNotNullOrEmpty()] + [string]$SubscriptionId, + + [Parameter(ParameterSetName='SpnParamSet', Mandatory=$true, HelpMessage='AADTenant/TenantId you would like to use')] + [ValidateNotNullOrEmpty()] + [string]$TenantId, + + [ValidateSet("Playback", "Record", "None")] + [string]$RecordMode='Playback', + + [ValidateSet("Prod", "Dogfood", "Current", "Next")] + [string]$TargetEnvironment='Prod' + ) + + [string]$uris="https://management.azure.com/" + + $formattedConnStr = [string]::Format("SubscriptionId={0};HttpRecorderMode={1};Environment={2}", $SubscriptionId, $RecordMode, $TargetEnvironment) + + if([string]::IsNullOrEmpty($UserId) -eq $false) + { + $formattedConnStr = [string]::Format([string]::Concat($formattedConnStr, ";UserId={0}"), $UserId) + } + + if([string]::IsNullOrEmpty($Password) -eq $false) + { + $formattedConnStr = [string]::Format([string]::Concat($formattedConnStr, ";Password={0}"), $Password) + } + + if([string]::IsNullOrEmpty($TenantId) -eq $false) + { + $formattedConnStr = [string]::Format([string]::Concat($formattedConnStr, ";AADTenant={0}"), $TenantId) + } + + if([string]::IsNullOrEmpty($ServicePrincipal) -eq $false) + { + $formattedConnStr = [string]::Format([string]::Concat($formattedConnStr, ";ServicePrincipal={0}"), $ServicePrincipal) + } + + if([string]::IsNullOrEmpty($ServicePrincipalSecret) -eq $false) + { + $formattedConnStr = [string]::Format([string]::Concat($formattedConnStr, ";ServicePrincipalSecret={0}"), $ServicePrincipalSecret) + } + + $formattedConnStr = [string]::Format([string]::Concat($formattedConnStr, ";BaseUri={0}"), $uris) + + Write-Host "Below connection string is ready to be set" + Print-ConnectionString $UserId $Password $SubscriptionId $TenantId $ServicePrincipal $ServicePrincipalSecret $RecordMode $TargetEnvironment $uris + + #Set connection string to Environment variable + $env:TEST_CSM_ORGID_AUTHENTICATION=$formattedConnStr + Write-Host "" + + # Retrieve the environment variable + Write-Host "" + Write-Host "Below connection string was set. Start Visual Studio by typing devenv" -ForegroundColor Green + [Environment]::GetEnvironmentVariable($envVariableName) + Write-Host "" + + Write-Host "If your needs demand you to set connection string differently, for all the supported Key/Value pairs in connection string" + Write-Host "Please visit https://github.com/Azure/azure-powershell/blob/dev/documentation/Using-Azure-TestFramework.md" -ForegroundColor Yellow +} + +Function Print-ConnectionString([string]$uid, [string]$pwd, [string]$subId, [string]$aadTenant, [string]$spn, [string]$spnSecret, [string]$recordMode, [string]$targetEnvironment, [string]$uris) +{ + + if([string]::IsNullOrEmpty($uid) -eq $false) + { + Write-Host "UserId=" -ForegroundColor Green -NoNewline + Write-Host $uid";" -NoNewline + } + + if([string]::IsNullOrEmpty($pwd) -eq $false) + { + Write-Host "Password=" -ForegroundColor Green -NoNewline + Write-Host $pwd";" -NoNewline + } + + if([string]::IsNullOrEmpty($subId) -eq $false) + { + Write-Host "SubscriptionId=" -ForegroundColor Green -NoNewline + Write-Host $subId";" -NoNewline + } + + if([string]::IsNullOrEmpty($aadTenant) -eq $false) + { + Write-Host "AADTenant=" -ForegroundColor Green -NoNewline + Write-Host $aadTenant";" -NoNewline + } + + if([string]::IsNullOrEmpty($spn) -eq $false) + { + Write-Host "ServicePrincipal=" -ForegroundColor Green -NoNewline + Write-Host $spn";" -NoNewline + } + + if([string]::IsNullOrEmpty($spnSecret) -eq $false) + { + Write-Host "ServicePrincipalSecret=" -ForegroundColor Green -NoNewline + Write-Host $spnSecret";" -NoNewline + } + + if([string]::IsNullOrEmpty($recordMode) -eq $false) + { + Write-Host "HttpRecorderMode=" -ForegroundColor Green -NoNewline + Write-Host $recordMode";" -NoNewline + } + + if([string]::IsNullOrEmpty($targetEnvironment) -eq $false) + { + Write-Host "Environment=" -ForegroundColor Green -NoNewline + Write-Host $targetEnvironment";" -NoNewline + } + + if([string]::IsNullOrEmpty($uris) -eq $false) + { + Write-Host "BaseUri=" -ForegroundColor Green -NoNewline + Write-Host $uris -NoNewline + } + + Write-Host "" +} + +export-modulemember -Function Set-TestEnvironment \ No newline at end of file diff --git a/tools/Modules/Tests/CommonTestUtil.psm1 b/tools/Modules/Tests/CommonTestUtil.psm1 new file mode 100644 index 000000000000..9174a2e7c661 --- /dev/null +++ b/tools/Modules/Tests/CommonTestUtil.psm1 @@ -0,0 +1,21 @@ +Function Log-Info +{ + [CmdletBinding()] + param( [string] [Parameter(Position=0)] $info = "") + + $info = [string]::Format("[INFO]: {0}", $info) + Write-Host $info -ForegroundColor Yellow +} + + +function Write-Log +{ + [CmdletBinding()] + param( [Object] [Parameter(Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$false)] $obj = "") + PROCESS + { + $obj | Out-String | Write-Verbose + } +} +export-modulemember -Function Log-Info +export-modulemember -Function Write-Log \ No newline at end of file diff --git a/tools/Modules/Tests/RepoModuleTests.ps1 b/tools/Modules/Tests/RepoModuleTests.ps1 new file mode 100644 index 000000000000..75c537b1b153 --- /dev/null +++ b/tools/Modules/Tests/RepoModuleTests.ps1 @@ -0,0 +1,10 @@ +Function CreateAdApp_Test +{ + $adDisplayName = "TestAdAppForNodeCliTestCase" + $subId = '2c224e7e-3ef5-431d-a57b-e71f4662e3a6' + + Create-ServicePrincipal -ADAppDisplayName "MyModTestApp1" -SubscriptionId 2c224e7e-3ef5-431d-a57b-e71f4662e3a6 -TenantId 72f988bf-86f1-41af-91ab-2d7cd011db47 -createADAppIfNotFound $true -createADSpnIfNotFound $true + + Set-SPNRole -ADAppDisplayName "MyModTestApp1" -SubscriptionId 2c224e7e-3ef5-431d-a57b-e71f4662e3a6 + Remove-ServicePrincipal -ADAppDisplayName "MyModTestApp1" -SubscriptionId 2c224e7e-3ef5-431d-a57b-e71f4662e3a6 -TenantId 72f988bf-86f1-41af-91ab-2d7cd011db47 +} diff --git a/tools/PS-VSPrompt.lnk b/tools/PS-VSPrompt.lnk index 3df2242b3e1c1df137a4cf07f2bf3a259a77c62a..560dc664b6d7530ca5fa501ec0ef3cda146b796f 100644 GIT binary patch delta 52 zcmZ1^*dn;$GNZa8gFZtxg93vRLjXfCLl8qMLjglRkX6Ev$WR0%^%#;Fav4%KOE7h@ F0RSwp3ikj2 delta 82 zcmZn>TqL;RGNY>jgFZtxg93vR5UMhSF$6OhGMF$JFgP>#Gx#$2F@ykVe+D0*I7qgb e!G$4}p$sUS%aFpL$B@L3$WX$dwD}if7aIU(hz~~q diff --git a/tools/PSRepoStart.cmd b/tools/PSRepoStart.cmd new file mode 100644 index 000000000000..389dd8c925aa --- /dev/null +++ b/tools/PSRepoStart.cmd @@ -0,0 +1,4 @@ +@echo off +SET currDir=%~dp0 +SET PSModulePath=%PSModulePath%;%currDir%\Modules +"%VS140COMNTOOLS%VsDevCmd.bat" diff --git a/tools/Repo-Tasks.psd1 b/tools/Repo-Tasks.psd1 index f8e52b1f750b904acccc7d02e80173044542fbe2..2fd3d67654f0495414eceff4da5695e9d90b2167 100644 GIT binary patch literal 4058 zcmc&%U2oeq6n)pPxIiA946$6NL6#OMP%lo}V2NkMX}5<011-@O8%b12%8obmzwhwF zvh1W;Ghka@0#oFdc=C>$-*0#&ySGf==}xqV z6YqG*6*D}g>FPDaIfZvsX?e&Nnd>Z+2;-flcOPlW-72Hcq}DrUqq=bL4ELvQyFtg*`>)fz{Pq`DMe zYM!r1q`Wj@wrbmr-hIGUSbO#I)lvV)Q`Sw6lH>02EIsX>zGS@1PhawcCDWrs{m@d-yLv7%N60!f|u#Tvth%C72Gnp7KxHt&P+I6t(2H&hO~k63tYiv zgm=I5U34bbdvJU|IUpNd8vIc!PLtu!-SH%*L7tPt(WJQMYQfXk85nZyqHjavF2!k9 zmx*;V%Y|7{rQ`yxv&psPxjkwhg=GhKElN?;1+MC&9Uy-dxcO4kST4DmWE^aGITs}d zn=iFckHK&Dwz9$*ajyC{awbtW--G)e8`o}sCi`dE*yaC-lbWbgJUYLn3x#Z0N_F?G zd&G2W3$Rk$T~rIh3BMPJSsD_Ax4n&6-5FUC_Z394%vUiAWh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LZxqAk8vJ23ilLy(E`J~aA$r)*Ok2dMEA%YyIu<&ab&dQC)7t(+~bvj za=7CUk;av`{%}r>z04)unZ6J0=#Pr#Mx79+j_k3JEtwS%&&&p`LaO`UL#=7J-+a95 z>bZIMye+DnZX#3c(#|w@WL;fJdPlq-D`Fn1*XK(}UAx`tiWx1S5BJq_!eh)c*s-M@ z!H)!s5~Bwl`>$tIWaV14u8J>g%vmk7tgP0P%0s!Po~08tjab%!E3R{Ld^T1^Q*+AOh-k9rU8L-9-2vK`atQjCo3 z%~iEJn;&8^e-A%I8guq diff --git a/tools/Repo-Tasks.psm1 b/tools/Repo-Tasks.psm1 index d67b1bdbc487..32f6506d27fa 100644 --- a/tools/Repo-Tasks.psm1 +++ b/tools/Repo-Tasks.psm1 @@ -4,252 +4,11 @@ $userPsFileDir = [string]::Empty [string]$envVariableName="TEST_CSM_ORGID_AUTHENTICATION" -[CmdletBinding] -Function Set-TestEnvironment +Function Init() { -<# -.SYNOPSIS -This cmdlet helps you to setup Test Environment for running tests -In order to successfully run a test, you will need SubscriptionId, TenantId -This cmdlet will only prompt you for Subscription and Tenant information, rest all other parameters are optional - -#> - [CmdletBinding(DefaultParameterSetName='UserIdParamSet')] - param( - [Parameter(ParameterSetName='UserIdParamSet', Mandatory=$true, HelpMessage = "UserId (OrgId) you would like to use")] - [ValidateNotNullOrEmpty()] - [string]$UserId, - - [Parameter(ParameterSetName='UserIdParamSet', Mandatory=$true, HelpMessage = "UserId (OrgId) you would like to use")] - [ValidateNotNullOrEmpty()] - [string]$Password, - - [Parameter(ParameterSetName='SpnParamSet', Mandatory=$true, HelpMessage='ServicePrincipal/ClientId you would like to use')] - [ValidateNotNullOrEmpty()] - [string]$ServicePrincipal, - - [Parameter(ParameterSetName='SpnParamSet', Mandatory=$true, HelpMessage='ServicePrincipal Secret/ClientId Secret you would like to use')] - [ValidateNotNullOrEmpty()] - [string]$ServicePrincipalSecret, - - [Parameter(ParameterSetName='SpnParamSet', Mandatory=$true)] - [Parameter(ParameterSetName='UserIdParamSet', Mandatory=$true, HelpMessage = "SubscriptionId you would like to use")] - [ValidateNotNullOrEmpty()] - [string]$SubscriptionId, - - [Parameter(ParameterSetName='SpnParamSet', Mandatory=$true, HelpMessage='AADTenant/TenantId you would like to use')] - [ValidateNotNullOrEmpty()] - [string]$TenantId, - - [ValidateSet("Playback", "Record", "None")] - [string]$RecordMode='Playback', - - [ValidateSet("Prod", "Dogfood", "Current", "Next")] - [string]$TargetEnvironment='Prod' - ) - - [string]$uris="https://management.azure.com/" - - $formattedConnStr = [string]::Format("SubscriptionId={0};HttpRecorderMode={1};Environment={2}", $SubscriptionId, $RecordMode, $TargetEnvironment) - - if([string]::IsNullOrEmpty($UserId) -eq $false) - { - $formattedConnStr = [string]::Format([string]::Concat($formattedConnStr, ";UserId={0}"), $UserId) - } - - if([string]::IsNullOrEmpty($Password) -eq $false) - { - $formattedConnStr = [string]::Format([string]::Concat($formattedConnStr, ";Password={0}"), $Password) - } - - if([string]::IsNullOrEmpty($TenantId) -eq $false) - { - $formattedConnStr = [string]::Format([string]::Concat($formattedConnStr, ";AADTenant={0}"), $TenantId) - } - - if([string]::IsNullOrEmpty($ServicePrincipal) -eq $false) - { - $formattedConnStr = [string]::Format([string]::Concat($formattedConnStr, ";ServicePrincipal={0}"), $ServicePrincipal) - } - - if([string]::IsNullOrEmpty($ServicePrincipalSecret) -eq $false) - { - $formattedConnStr = [string]::Format([string]::Concat($formattedConnStr, ";ServicePrincipalSecret={0}"), $ServicePrincipalSecret) - } - - $formattedConnStr = [string]::Format([string]::Concat($formattedConnStr, ";BaseUri={0}"), $uris) - - Write-Host "Below connection string is ready to be set" - Print-ConnectionString $UserId $Password $SubscriptionId $TenantId $ServicePrincipal $ServicePrincipalSecret $RecordMode $TargetEnvironment $uris - - #Set connection string to Environment variable - $env:TEST_CSM_ORGID_AUTHENTICATION=$formattedConnStr - Write-Host "" - - # Retrieve the environment variable - Write-Host "" - Write-Host "Below connection string was set. Start Visual Studio by typing devenv" -ForegroundColor Green - [Environment]::GetEnvironmentVariable($envVariableName) - Write-Host "" - - Write-Host "If your needs demand you to set connection string differently, for all the supported Key/Value pairs in connection string" - Write-Host "Please visit https://github.com/Azure/azure-powershell/blob/dev/documentation/Using-Azure-TestFramework.md" -ForegroundColor Yellow -} - -Function Print-ConnectionString([string]$uid, [string]$pwd, [string]$subId, [string]$aadTenant, [string]$spn, [string]$spnSecret, [string]$recordMode, [string]$targetEnvironment, [string]$uris) -{ - - if([string]::IsNullOrEmpty($uid) -eq $false) - { - Write-Host "UserId=" -ForegroundColor Green -NoNewline - Write-Host $uid";" -NoNewline - } - - if([string]::IsNullOrEmpty($pwd) -eq $false) - { - Write-Host "Password=" -ForegroundColor Green -NoNewline - Write-Host $pwd";" -NoNewline - } - - if([string]::IsNullOrEmpty($subId) -eq $false) - { - Write-Host "SubscriptionId=" -ForegroundColor Green -NoNewline - Write-Host $subId";" -NoNewline - } - - if([string]::IsNullOrEmpty($aadTenant) -eq $false) - { - Write-Host "AADTenant=" -ForegroundColor Green -NoNewline - Write-Host $aadTenant";" -NoNewline - } - - if([string]::IsNullOrEmpty($spn) -eq $false) - { - Write-Host "ServicePrincipal=" -ForegroundColor Green -NoNewline - Write-Host $spn";" -NoNewline - } - - if([string]::IsNullOrEmpty($spnSecret) -eq $false) - { - Write-Host "ServicePrincipalSecret=" -ForegroundColor Green -NoNewline - Write-Host $spnSecret";" -NoNewline - } - - if([string]::IsNullOrEmpty($recordMode) -eq $false) - { - Write-Host "HttpRecorderMode=" -ForegroundColor Green -NoNewline - Write-Host $recordMode";" -NoNewline - } - - if([string]::IsNullOrEmpty($targetEnvironment) -eq $false) - { - Write-Host "Environment=" -ForegroundColor Green -NoNewline - Write-Host $targetEnvironment";" -NoNewline - } - - if([string]::IsNullOrEmpty($uris) -eq $false) - { - Write-Host "BaseUri=" -ForegroundColor Green -NoNewline - Write-Host $uris -NoNewline - } - - Write-Host "" + #Initialize Code } -[CmdletBinding] -Function Get-BuildScopes -{ -<# -.SYNOPSIS -You can build a particular package rather than doing a full build by providing Build Scope. -This cmdlet will help to identify existing Scope available -This will enable to execute Start-RepoBuild - -#> - - Write-Host "Below are available scopes you can specify for building specific projects" - Write-Host "" - Get-ChildItem -path "$env:repoRoot\src\ResourceManagement" -dir | Format-Wide -Column 5 | Format-Table -Property Name - Write-Host "e.g of a scope would be 'ResourceManagement\Compute'" -ForegroundColor Yellow - - Get-ChildItem -path "$env:repoRoot\src\" -dir -Exclude "ResourceManagement" | Format-Wide -Column 5 | Format-Table -Property Name - Write-Host "e.g of a scope would be 'Authentication'" -ForegroundColor Yellow -} - -[CmdletBinding] -Function Start-Build -{ -<# -.SYNOPSIS -This cmdlet will help to do either with full build or targeted build for specific scopes. - -.PARAMETER BuildScope -Use Get-BuildScope cmdLet to get list of existing scopes that can be used to build -#> - param( - [parameter(Mandatory=$false, Position=0, HelpMessage='BuildScope that you would like to use. For list of build scopes, run List-BuildScopes')] - [string]$BuildScope - ) - - if([string]::IsNullOrEmpty($BuildScope) -eq $true) - { - Write-Host "Starting Full build" - msbuild.exe "$env:repoRoot\build.proj" /t:Build - } - else - { - Write-Host "Building $BuildScope" - msbuild.exe "$env:repoRoot\build.proj" /t:Build /p:Scope=$BuildScope - } -} - -[CmdletBinding] -Function Invoke-CheckinTests -{ -<# -.SYNOPSIS -Runs all the check in tests -#> - Write-Host "cmdline Args: msbuild.exe $env:repoRoot\build.proj /t:Test" - msbuild.exe "$env:repoRoot\build.proj" /t:Test -} - -[cmdletBinding] -Function Install-VSProjectTemplates -{ -<# -.SYNOPSIS - -Install-VSProjectTemplates will install getting started project templates for -1) Autorest-.NET SDKProject -2) .NET SDK Test projectct - -After executing the cmdlet, restart VS (if already open), create new project -Search for the project template as we install the following three project templates -AutoRest-AzureDotNetSDK -AzureDotNetSDK-TestProject -AzurePowerShell-TestProject -#> - if($env:VisualStudioVersion -eq "14.0") - { - if((Test-Path "$env:repoRoot\tools\ProjectTemplates\") -eq $true) - { - Write-Host "Installing VS templates for 'AutoRest as well as Test Project'" - Copy-Item "$env:repoRoot\tools\ProjectTemplates\*.zip" "$env:USERPROFILE\Documents\Visual Studio 2015\Templates\ProjectTemplates\" - Write-Host "Installed VS Test Project Templates for Powershell test projects" - Write-Host "" - Write-Host "Restart VS (if already open), search for 'AzurePowerShell-TestProject'" -ForegroundColor Yellow - } - else - { - Write-Host "Missing templates to install, make sure you have project templates available in the repo under $env:repoRoot\tools\ProjectTemplates\" - } - } - else - { - Write-Host "Unsupported VS Version detected. Visual Studio 2015 is the only supported version for current set of project templates" - } -} <# We allow users to include any helper powershell scripts they would like to include in the current session @@ -279,8 +38,6 @@ else Write-Host "Loading skipped. 'psuserpreferences' environment variable was not set to load user preferences." -ForegroundColor DarkYellow } -export-modulemember -Function Set-TestEnvironment -export-modulemember -Function Get-BuildScopes -export-modulemember -Function Start-Build -export-modulemember -Function Invoke-CheckinTests -export-modulemember -Function Install-VSProjectTemplates \ No newline at end of file + +#Execute Init +#Init \ No newline at end of file