Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge internal/Az.Tools.Predictor #13546

Merged
merged 77 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
64a6838
psd1 & psm1 of Az.Installer with a demo cmdlet (#12698)
msJinLei Aug 19, 2020
ddcec55
Internal/az.installer (#12817)
VeryEarly Sep 1, 2020
cc9d652
Internal/az.installer (#12860)
VeryEarly Sep 4, 2020
34d0557
Cmdlet Update-AzModule (#12832)
msJinLei Sep 4, 2020
a1b007f
Add telemetry
dingmeng-xue Sep 4, 2020
79d1ed0
Merge branch 'internal/Az.Installer' of https://github.com/Azure/azur…
dingmeng-xue Sep 4, 2020
8192c7a
Support telemetry
dingmeng-xue Sep 4, 2020
0a23c60
Move Get-AzModuleUpdateList to internal (#12865)
msJinLei Sep 4, 2020
257e821
add telemetry to Uninstall-AzModule cmdlet
VeryEarly Sep 7, 2020
0d79e63
bugfix: module name was not handled properly
VeryEarly Sep 7, 2020
2eeae6d
Add environment variable to disable telemetry
dingmeng-xue Sep 7, 2020
a7efd49
Merge branch 'internal/Az.Installer' of https://github.com/Azure/azur…
dingmeng-xue Sep 7, 2020
be93bce
parallel executing Install/Uninstall module
VeryEarly Sep 7, 2020
3c1e225
Merge branch 'internal/Az.Installer' of https://github.com/Azure/azur…
VeryEarly Sep 7, 2020
ca5fc5b
update code after review
dingmeng-xue Sep 8, 2020
c8c7b31
improve performance
VeryEarly Sep 8, 2020
8846a97
Merge branch 'internal/Az.Installer' of https://github.com/Azure/azur…
VeryEarly Sep 8, 2020
021097e
Fix Update-AzModule issues
msJinLei Sep 8, 2020
28cefad
bug fix
VeryEarly Sep 8, 2020
7d80590
remove unused util
VeryEarly Sep 8, 2020
4d13c4e
remove az.accounts when allow preview
VeryEarly Sep 8, 2020
6da2f26
Fix issue when no module to udpate
msJinLei Sep 8, 2020
5f1e6e1
Add sign pipeline
dingmeng-xue Sep 8, 2020
385bceb
skip confirmation when remove-job
VeryEarly Sep 8, 2020
82b6ecb
Merge branch 'internal/Az.Installer' of https://github.com/Azure/azur…
VeryEarly Sep 8, 2020
42111d5
remove debug info
VeryEarly Sep 8, 2020
e339d16
fix parameter reference
VeryEarly Sep 8, 2020
7e4af16
Initial checking in AzPredictor (#12847)
kceiw Sep 9, 2020
25157f2
filter installedmodules before uninstall
VeryEarly Sep 9, 2020
7aad6d9
bugfix for uninstall
VeryEarly Sep 9, 2020
acb3b81
Add synopsis and example to exported cmdlets
dingmeng-xue Sep 9, 2020
26c6116
add default parameter set for uninstall-azmodule
VeryEarly Sep 9, 2020
cb1da08
merge from remote
VeryEarly Sep 9, 2020
82311c3
add input validatin
VeryEarly Sep 13, 2020
77f0e74
remove unnecessary warning message
VeryEarly Sep 14, 2020
a9bb931
Merge branch 'internal/Az.Installer' into internal/Az.Tools.Predictor
dingmeng-xue Sep 14, 2020
e940a50
Build and package module under artifacts folder
dingmeng-xue Sep 14, 2020
05a38c3
Improve Az.Tool.Predictor (#12922)
kceiw Sep 15, 2020
f70747d
Add Az as external dependency
dingmeng-xue Sep 15, 2020
2badd83
Add pipeline 'sign-tool-predictor'
BethanyZhou Sep 15, 2020
c69d426
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 15, 2020
1ecb5db
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 15, 2020
60fd57f
net.webclient.downloadfile
BethanyZhou Sep 15, 2020
815abe4
refine command
BethanyZhou Sep 15, 2020
03720c1
clean build
BethanyZhou Sep 16, 2020
c5a2050
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 16, 2020
caf8bc1
Improve the build of Az.Tools.Predictor (#12974)
kceiw Sep 16, 2020
910e2cc
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 16, 2020
98c6cbc
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 16, 2020
0d27485
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 16, 2020
58c204d
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 16, 2020
b3bda56
Override powershellcorecommandPrefix
BethanyZhou Sep 16, 2020
84927a9
join_path
BethanyZhou Sep 16, 2020
d59c151
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 16, 2020
716bb7d
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 16, 2020
61c21eb
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 16, 2020
3a74d57
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 16, 2020
2e8d65f
Install Az
BethanyZhou Sep 16, 2020
556abe1
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 16, 2020
2c113ea
Update sign-tool-predictor.yml for Azure Pipelines
BethanyZhou Sep 16, 2020
8405e63
Sign dll
BethanyZhou Sep 16, 2020
7893ac5
Remove dll sign
BethanyZhou Sep 16, 2020
57cab6d
Predict parameter values in the suggestion (#12984)
kceiw Sep 18, 2020
ce42552
improve telemetry (#13025)
kceiw Sep 24, 2020
e182978
return multiple suggestion (#13098)
kceiw Oct 5, 2020
822b212
Reduce the dependencies on Azure powershell common. (#13113)
kceiw Oct 8, 2020
a239d68
Add a missing file. (#13234)
kceiw Oct 17, 2020
4b1ff75
Fix duplicate text (#13326)
kceiw Oct 27, 2020
ec15095
Update how we send request and collect telemetry (#13327)
kceiw Nov 3, 2020
fff725f
Bug fixes and performance improvement (#13410)
kceiw Nov 5, 2020
33c1181
Improve the telemetry and http request (#13354)
kceiw Nov 5, 2020
5c27eb4
Update module infomation (#13328)
kceiw Nov 6, 2020
fbd0b9b
Update package script to support requiredmodule (#13424)
dingmeng-xue Nov 6, 2020
b25330e
Add variety to Az.Predictor result list (#13420)
yemohyle Nov 7, 2020
feecabf
Update description for release
dingmeng-xue Nov 10, 2020
2a97f4c
Merge from master
dingmeng-xue Nov 19, 2020
0083b36
Add PublishLocation to build.proj of Az.Tools.Installer
msJinLei Nov 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .azure-pipelines/sign-tool-predictor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
pr: none
trigger: none
pool:
vmImage: 'windows-2019'

steps:
- task: PowerShell@2
displayName: Install PS 7.1.0-preview.7
inputs:
targetType: 'inline'
script: |
$url = "https://github.com/PowerShell/PowerShell/releases/download/v7.1.0-preview.7/PowerShell-7.1.0-preview.7-win-x64.zip"
$output = Join-Path -Path $(Pipeline.Workspace) -ChildPath "./PowerShell-7.1.0-preview.7-win-x64.zip"
(New-Object System.Net.WebClient).DownloadFile($url, $output)
$pwshPath= Join-Path -Path $(Pipeline.Workspace) -ChildPath "./PowerShell-7.1.0-preview.7/"
Expand-Archive -Path $output -DestinationPath $pwshPath
$pwshFullPath = Convert-Path $pwshPath
Write-Host $pwshFullPath

- task: PowerShell@2
displayName: 'Install platyPS, PowerShellGet, Az 3.0.0'
inputs:
targetType: inline
script: |
$pwshPath= Join-Path -Path $(Pipeline.Workspace) -ChildPath "./PowerShell-7.1.0-preview.7/pwsh.exe"
$command = "`$PSVersionTable `
Install-Module platyPS -Force -Confirm:`$false -Scope CurrentUser `
Install-Module PowerShellGet -Force -Confirm:`$false -Scope CurrentUser -SkipPublisherCheck `
Install-Module Az -Repository PSGallery -RequiredVersion 3.0.0 -Confirm:`$false -Scope CurrentUser -AllowClobber -Force"
Invoke-Command -ScriptBlock { param ($pwshPath, $command) & $pwshPath -Command $command } -ArgumentList $pwshPath, $command

- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 5.0.100-rc.1.20452.10

- task: DotNetCoreCLI@2
displayName: 'Build'
inputs:
command: custom
custom: msbuild
arguments: 'tools\Az.Tools.Predictor\build.proj /target:"Clean;Build" /p:Configuration=Release'

- task: EsrpCodeSigning@1
displayName: 'Signing'
inputs:
ConnectedServiceName: $(signServiceConnection)
FolderPath: artifacts
Pattern: |
Tools/**/*.ps1
Tools/**/*.psd1
Tools/**/*.psm1
Tools/**/*.ps1xml
UseMinimatch: true
signConfigType: inlineSignParams
inlineOperation: |
[
{
"KeyCode": "CP-230012",
"OperationCode": "SigntoolSign",
"Parameters": {
"OpusName": "Microsoft",
"OpusInfo": "http://www.microsoft.com",
"FileDigest": "/fd \"SHA256\"",
"PageHash": "/NPH",
"TimeStamp": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
},
"ToolName": "sign",
"ToolVersion": "1.0"
},
{
"KeyCode": "CP-230012",
"OperationCode": "SigntoolVerify",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
}
]

- task: DotNetCoreCLI@2
displayName: Package
inputs:
command: custom
custom: msbuild
arguments: 'tools\Az.Tools.Predictor\build.proj /target:"Package" /p:Configuration=Release /p:PowerShellCoreCommandPrefix="$(Pipeline.Workspace)\\PowerShell-7.1.0-preview.7\\pwsh.exe -NonInteractive -NoLogo -NoProfile -Command" '

- task: PublishPipelineArtifact@0
displayName: 'Save artifacts'
inputs:
artifactName: artifacts
targetPath: artifacts
condition: succeededOrFailed()
4 changes: 2 additions & 2 deletions tools/Az.Tools.Installer/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@

<Target Name="Package">
<Message Text="Package $(ModuleName)" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)\PublishToolsModule.ps1 -RepositoryLocation $(ArtifactFolder) -ModuleName $(ModuleName)&quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)\PublishToolsModule.ps1 -RepositoryLocation $(ArtifactFolder) -PublishLocation $(ArtifactFolder) -ModuleName $(ModuleName)&quot;" />
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AssemblyName>Microsoft.Azure.PowerShell.Tools.AzPredictor.Test</AssemblyName>
<RootNamespace>Microsoft.Azure.PowerShell.Tools.AzPredictor.Test</RootNamespace>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RepoArtifacts>$(MSBuildThisFileDirectory)</RepoArtifacts>
<OutputPath>$(RepoArtifacts)..\..\..\artifacts\Tools\Az.Tools.Predictor.Test\</OutputPath>
<DocumentationFile>$(OutputPath)\Microsoft.Azure.PowerShell.AzPredictor.Tools.Test.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Management.Automation" Version="7.1.0-preview.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<ProjectReference Include="..\Az.Tools.Predictor\Az.Tools.Predictor.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="Data\CommandsModel.zip" CopyToOutputDirectory="PreserveNewest" />
<None Include="Data\PredictionsModel.zip" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.PowerShell.Tools.AzPredictor.Test.Mocks;
using System.Linq;
using System.Management.Automation.Subsystem;
using System.Threading;
using Xunit;

namespace Microsoft.Azure.PowerShell.Tools.AzPredictor.Test
{
/// <summary>
/// Tests for <see cref="AzPredictorService"/>
/// </summary>
[Collection("Model collection")]
public class AzPredictorServiceTests
{
private readonly ModelFixture _fixture;
private readonly AzPredictorService _service;
private readonly Predictor _suggestionsPredictor;
private readonly Predictor _commandsPredictor;

/// <summary>
/// Constructs a new instance of <see cref="AzPredictorServiceTests"/>
/// </summary>
/// <param name="fixture"></param>
public AzPredictorServiceTests(ModelFixture fixture)
{
this._fixture = fixture;
var startHistory = $"{AzPredictorConstants.CommandPlaceholder}{AzPredictorConstants.CommandConcatenator}{AzPredictorConstants.CommandPlaceholder}";
this._suggestionsPredictor = new Predictor(this._fixture.PredictionCollection[startHistory], null);
this._commandsPredictor = new Predictor(this._fixture.CommandCollection, null);

this._service = new MockAzPredictorService(startHistory, this._fixture.PredictionCollection[startHistory], this._fixture.CommandCollection);
}


/// <summary>
/// Verifies that the prediction comes from the suggestions list, not the command list.
/// </summary>
[Theory]
[InlineData("CONNECT-AZACCOUNT")]
[InlineData("set-azstorageaccount ")]
[InlineData("Get-AzResourceG")]
[InlineData("Get-AzStorageAcco")]
[InlineData("Get-AzKeyVault -VaultName")]
[InlineData("GET-AZSTORAGEACCOUNTKEY -NAME ")]
[InlineData("new-azresourcegroup -name hello")]
[InlineData("Get-AzContext -Name")]
[InlineData("Get-AzContext -ErrorAction")]
public void VerifyUsingSuggestion(string userInput)
{
var predictionContext = PredictionContext.Create(userInput);
var expected = this._suggestionsPredictor.Query(predictionContext.InputAst, 1, CancellationToken.None);
var actual = this._service.GetSuggestion(predictionContext.InputAst, 1, CancellationToken.None);
Assert.NotEmpty(actual);
Assert.NotNull(actual.First().Item1);
Assert.Equal(expected.First().Key, actual.First().Item1);
Assert.Equal(PredictionSource.CurrentCommand, actual.First().Item3);
}

/// <summary>
/// Verifies that when no prediction is in the suggestion list, we'll use the command list.
/// </summary>
[Theory]
[InlineData("Get-AzResource -Name hello -Pre")]
[InlineData("Get-AzADServicePrincipal -ApplicationObject")]
public void VerifyUsingCommand(string userInput)
{
var predictionContext = PredictionContext.Create(userInput);
var expected = this._commandsPredictor.Query(predictionContext.InputAst, 1, CancellationToken.None);
var actual = this._service.GetSuggestion(predictionContext.InputAst, 1, CancellationToken.None);
Assert.NotEmpty(actual);
Assert.NotNull(actual.First().Item1);
Assert.Equal(expected.First().Key, actual.First().Item1);
Assert.Equal(PredictionSource.StaticCommands, actual.First().Item3);
}

/// <summary>
/// Verify that no prediction for the user input, meaning it's not in the prediction list or the command list.
/// </summary>
[Theory]
[InlineData(AzPredictorConstants.CommandPlaceholder)]
[InlineData("git status")]
[InlineData("Get-ChildItem")]
[InlineData("new-azresourcegroup -NoExistingParam")]
[InlineData("get-azaccount ")]
[InlineData("Get-AzContext Name")]
[InlineData("NEW-AZCONTEXT")]
public void VerifyNoPrediction(string userInput)
{
var predictionContext = PredictionContext.Create(userInput);
var actual = this._service.GetSuggestion(predictionContext.InputAst, 1, CancellationToken.None);
Assert.Empty(actual);
}
}
}
Loading