Skip to content

Commit 07df4dc

Browse files
azure-powershell-botazurepowershell
andauthored
Sync tools folder from main branch to generation branch (#25063)
Co-authored-by: azurepowershell <[email protected]>
1 parent f1a7228 commit 07df4dc

File tree

3 files changed

+21
-32
lines changed

3 files changed

+21
-32
lines changed

.azure-pipelines/sync-tools-folder.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ trigger:
1111
paths:
1212
include:
1313
- .azure-pipelines
14-
- .github
1514
- tools
1615
- src/lib
1716
- .ci-config.json
@@ -53,4 +52,4 @@ jobs:
5352
$BaseBranch = "$(BranchName)"
5453
$Description = "Migrate Sync tools code from main branch to $(BranchName) branch"
5554
./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(GithubToken) -Description $Description
56-
displayName: Create PR to $(BranchName) branch
55+
displayName: Create PR to $(BranchName) branch

.azure-pipelines/test-coverage.yml

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
parameters:
2-
- name: dotnet_sdk_6
3-
displayName: .NET 6
2+
- name: dotnet_sdk
3+
displayName: .NET SDK
44
type: string
55
default: 6.0.x
6-
- name: dotnet_sdk_7
7-
displayName: .NET 7
8-
type: string
9-
default: 7.0.x
106
- name: testFramework
117
displayName: Test Framework
128
type: string
@@ -34,10 +30,10 @@ jobs:
3430

3531
steps:
3632
- task: UseDotNet@2
37-
displayName: 'Install .NET 6 SDK'
33+
displayName: 'Install .NET SDK'
3834
inputs:
3935
packageType: sdk
40-
version: ${{ parameters.dotnet_sdk_6 }}
36+
version: ${{ parameters.dotnet_sdk }}
4137

4238
- task: DotNetCoreCLI@2
4339
displayName: Build Azure PowerShell Modules
@@ -61,10 +57,10 @@ jobs:
6157

6258
steps:
6359
- task: UseDotNet@2
64-
displayName: 'Install .NET 6.0 SDK'
60+
displayName: 'Install .NET SDK'
6561
inputs:
6662
packageType: sdk
67-
version: ${{ parameters.dotnet_sdk_6 }}
63+
version: ${{ parameters.dotnet_sdk }}
6864

6965
- task: PowerShell@2
7066
displayName: Initialize Environment
@@ -88,7 +84,7 @@ jobs:
8884
arguments: 'build.proj -t:"Test" -p:"Configuration=Debug;TestFramework=${{ parameters.testFramework }}"'
8985

9086
- task: PowerShell@2
91-
displayName: Test AutoRest-Based Cmdlets
87+
displayName: Test Autorest-Based Cmdlets
9288
condition: succeeded()
9389
inputs:
9490
pwsh: true
@@ -101,7 +97,7 @@ jobs:
10197
$debugDir = Join-Path -Path $rootDir -ChildPath "artifacts" | Join-Path -ChildPath "Debug"
10298
$env:PSModulePath += $delimiter + $debugDir
10399
Get-ChildItem -Path $debugDir -Filter test-module.ps1 -File -Recurse | Select-Object -ExpandProperty FullName | ForEach-Object {
104-
Write-Host "##[section]Testing $_"
100+
Write-Host "##[section]Executing $_"
105101
& $_
106102
}
107103
@@ -114,22 +110,6 @@ jobs:
114110
filePath: ./tools/TestFx/Coverage/AnalyzeTestCoverage.ps1
115111
arguments: -CalcBaseline
116112

117-
- template: util/get-keyvault-secret-steps.yml
118-
parameters:
119-
serviceConnectionName: $(AzureSubscription)
120-
keyVaultName: $(KustoServicePrincipalKeyVaultName)
121-
secretName: $(KustoServicePrincipalSecretName)
122-
outVar: 'KustoServicePrincipalSecret'
123-
124-
- task: PowerShell@2
125-
displayName: Save Test Coverage Results
126-
condition: succeeded()
127-
inputs:
128-
pwsh: true
129-
targetType: filePath
130-
filePath: ./tools/TestFx/Coverage/SaveTestCoverageResult.ps1
131-
arguments: CITest $(KustoTenantId) $(KustoServicePrincipalId) $(KustoServicePrincipalSecret) $(KustoClusterName) $(KustoClusterRegion)
132-
133113
- template: util/get-github-pat-steps.yml
134114

135115
- task: PowerShell@2

tools/TestFx/EnvironmentSetupHelper.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
using Microsoft.Azure.Commands.ScenarioTest;
2020
using Microsoft.Azure.Commands.TestFx.Mocks;
2121
using Microsoft.Azure.ServiceManagement.Common.Models;
22-
using Microsoft.Azure.Test.HttpRecorder;
2322
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
2423
using Microsoft.WindowsAzure.Commands.Common;
2524
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2625
using System;
2726
using System.Collections.Generic;
2827
using System.Collections.ObjectModel;
28+
using System.Diagnostics;
2929
using System.IO;
3030
using System.Linq;
3131
using System.Management.Automation;
@@ -525,13 +525,23 @@ public virtual Collection<PSObject> RunPowerShellTest(params string[] scripts)
525525
Collection<PSObject> output = null;
526526
foreach (var script in scripts)
527527
{
528-
Console.WriteLine($"Executing test: {script}");
529528
TracingInterceptor?.Information(script);
530529
powershell.AddScript(script);
531530
}
531+
532532
try
533533
{
534+
string testName = string.Join("+", scripts);
535+
Console.WriteLine($"Executing test {testName}");
536+
537+
var watch = Stopwatch.StartNew();
534538
output = powershell.Invoke();
539+
watch.Stop();
540+
541+
var resultFormatting = watch.ElapsedMilliseconds < 5000 ? "##[section]" : "##[warning]";
542+
543+
Console.WriteLine($"{resultFormatting}Test {testName} completed in {watch.ElapsedMilliseconds}ms");
544+
535545
if (powershell.Streams.Error.Count > 0)
536546
{
537547
throw new RuntimeException($"Test failed due to a non-empty error stream. First error: {PowerShellExtensions.FormatErrorRecord(powershell.Streams.Error[0])}{(powershell.Streams.Error.Count > 0 ? "Check the error stream in the test log for additional errors." : "")}");

0 commit comments

Comments
 (0)