Skip to content

Commit

Permalink
Sync tools folder from main branch to generation branch (#25063)
Browse files Browse the repository at this point in the history
Co-authored-by: azurepowershell <[email protected]>
  • Loading branch information
azure-powershell-bot and azurepowershell authored Jun 5, 2024
1 parent f1a7228 commit 07df4dc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 32 deletions.
3 changes: 1 addition & 2 deletions .azure-pipelines/sync-tools-folder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ trigger:
paths:
include:
- .azure-pipelines
- .github
- tools
- src/lib
- .ci-config.json
Expand Down Expand Up @@ -53,4 +52,4 @@ jobs:
$BaseBranch = "$(BranchName)"
$Description = "Migrate Sync tools code from main branch to $(BranchName) branch"
./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(GithubToken) -Description $Description
displayName: Create PR to $(BranchName) branch
displayName: Create PR to $(BranchName) branch
36 changes: 8 additions & 28 deletions .azure-pipelines/test-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
parameters:
- name: dotnet_sdk_6
displayName: .NET 6
- name: dotnet_sdk
displayName: .NET SDK
type: string
default: 6.0.x
- name: dotnet_sdk_7
displayName: .NET 7
type: string
default: 7.0.x
- name: testFramework
displayName: Test Framework
type: string
Expand Down Expand Up @@ -34,10 +30,10 @@ jobs:

steps:
- task: UseDotNet@2
displayName: 'Install .NET 6 SDK'
displayName: 'Install .NET SDK'
inputs:
packageType: sdk
version: ${{ parameters.dotnet_sdk_6 }}
version: ${{ parameters.dotnet_sdk }}

- task: DotNetCoreCLI@2
displayName: Build Azure PowerShell Modules
Expand All @@ -61,10 +57,10 @@ jobs:

steps:
- task: UseDotNet@2
displayName: 'Install .NET 6.0 SDK'
displayName: 'Install .NET SDK'
inputs:
packageType: sdk
version: ${{ parameters.dotnet_sdk_6 }}
version: ${{ parameters.dotnet_sdk }}

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

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

- template: util/get-keyvault-secret-steps.yml
parameters:
serviceConnectionName: $(AzureSubscription)
keyVaultName: $(KustoServicePrincipalKeyVaultName)
secretName: $(KustoServicePrincipalSecretName)
outVar: 'KustoServicePrincipalSecret'

- task: PowerShell@2
displayName: Save Test Coverage Results
condition: succeeded()
inputs:
pwsh: true
targetType: filePath
filePath: ./tools/TestFx/Coverage/SaveTestCoverageResult.ps1
arguments: CITest $(KustoTenantId) $(KustoServicePrincipalId) $(KustoServicePrincipalSecret) $(KustoClusterName) $(KustoClusterRegion)

- template: util/get-github-pat-steps.yml

- task: PowerShell@2
Expand Down
14 changes: 12 additions & 2 deletions tools/TestFx/EnvironmentSetupHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.Azure.Commands.TestFx.Mocks;
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.Azure.Test.HttpRecorder;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Microsoft.WindowsAzure.Commands.Common;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Management.Automation;
Expand Down Expand Up @@ -525,13 +525,23 @@ public virtual Collection<PSObject> RunPowerShellTest(params string[] scripts)
Collection<PSObject> output = null;
foreach (var script in scripts)
{
Console.WriteLine($"Executing test: {script}");
TracingInterceptor?.Information(script);
powershell.AddScript(script);
}

try
{
string testName = string.Join("+", scripts);
Console.WriteLine($"Executing test {testName}");

var watch = Stopwatch.StartNew();
output = powershell.Invoke();
watch.Stop();

var resultFormatting = watch.ElapsedMilliseconds < 5000 ? "##[section]" : "##[warning]";

Console.WriteLine($"{resultFormatting}Test {testName} completed in {watch.ElapsedMilliseconds}ms");

if (powershell.Streams.Error.Count > 0)
{
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." : "")}");
Expand Down

0 comments on commit 07df4dc

Please sign in to comment.