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

Trigger Az.Predictor CI #18067

Merged
merged 5 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .azure-pipelines/powershell-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ variables:
BuildTimeoutInMinutes: 120
AnalysisTimeoutInMinutes: 120
TestTimeoutInMinutes: 180
BuildAzPredictor: false

trigger: none

Expand Down
23 changes: 22 additions & 1 deletion .azure-pipelines/util/build-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,39 @@ steps:
filePath: tools/CheckIgnoredFile.ps1

- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
displayName: 'Use .NET Core sdk 3.1.x'
inputs:
packageType: sdk
version: 3.1.x

- task: UseDotNet@2
displayName: 'Use .NET Core sdk 6.0.x'
inputs:
packageType: sdk
version: 6.0.x

- task: PowerShell@2
displayName: Setup global.json
inputs:
targetType: inline
script: "$SdkVersion=(dotnet --list-sdks | Select-String '[3,4,5].\\d.\\d{3}').Matches[0].Value; dotnet new globaljson --sdk-version $SdkVersion --force"
pwsh: true

- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: custom
custom: msbuild
arguments: 'build.proj /t:Build /p:Configuration=${{ parameters.configuration }};TestFramework=${{ parameters.testFramework }};PullRequestNumber=$(System.PullRequest.PullRequestNumber)'

- task: PowerShell@2
displayName: Build-AzPredictor
condition: eq(variables.BuildAzPredictor, 'true')
inputs:
targetType: inline
script: "$SdkVersion=(dotnet --list-sdks | Select-String '6.0.\\d{3}').Matches[0].Value; dotnet new globaljson --sdk-version $SdkVersion --force;dotnet msbuild tools/Az.Tools.Predictor/build.proj /t:\"clean;build;test\""
pwsh: true

- template: publish-artifacts-steps.yml
parameters:
artifactName: build-${{ parameters.testFramework }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SecurityTmp/
tmp/
FilesChanged.txt
CsprojMappings.json
global.json

obj
bin
Expand Down
8 changes: 2 additions & 6 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@
<Exec Command="dotnet new sln -n Azure.PowerShell -o $(RepoArtifacts) --force" />
<CallTarget Targets="BuildNormalModules" />

<CallTarget Targets="AzToolsPredictor" Condition="$(SubTasks.Contains('predictor'))" />
<CallTarget Targets="AzToolsInstaller" Condition="$(SubTasks.Contains('installer'))" />
<Exec Command="echo ##vso[task.setvariable variable=BuildAzPredictor;]true" Condition="$(SubTasks.Contains('Predictor')) OR $(SubTasks.Contains('all'))" />
<CallTarget Targets="AzToolsInstaller" Condition="$(SubTasks.Contains('Installer')) OR $(SubTasks.Contains('all'))" />
</Target>

<Target Name="BuildNormalModules">
Expand Down Expand Up @@ -290,10 +290,6 @@
<Exec Command='dotnet msbuild $(RepoTools)/Az.Tools.Installer/build.proj /t:"clean;build;test"' />
</Target>

<Target Name="AzToolsPredictor">
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<ProjectReference Include="..\Az.Tools.Predictor\Az.Tools.Predictor.csproj" />
<!-- The test project doesn't reference to it directly. Az.Tools.Predictor has a reference to Microsoft.PowerShell.SDK.
- But it's excluding content files to reduce the size of the module. The content files are not needed since they're in the runtime (PowerShell)
- The content files are needed to set up the runspace to parse the command line. So we need to include them when we run the unit tests.
-->
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.0" />
</ItemGroup>

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

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void Dispose()
[Fact]
public void VerifyParameterValues()
{
var predictionContext = PredictionContext.Create("Get-AzContext");
var predictionContext = PredictionContext.Create("Set-Content");

Action actual = () => this._service.GetSuggestion(null, 1, 1, CancellationToken.None);
Assert.Throws<ArgumentNullException>(actual);
Expand All @@ -116,14 +116,14 @@ public void VerifyParameterValues()
/// Verifies that the prediction comes from the command based list, not the fallback 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("new-azresourcegroup hello")]
[InlineData("SET-CONTENT")]
[InlineData("get-logproperties ")]
[InlineData("Clear-C")]
[InlineData("compare-")]
[InlineData("Clear-Variable -Name")]
[InlineData("CLEAR-CONTENT -PATH test")]
[InlineData("Clear-content -path test")]
[InlineData("clear-content ./Test.log")]
public void VerifyUsingCommandBasedPredictor(string userInput)
{
var predictionContext = PredictionContext.Create(userInput);
Expand Down Expand Up @@ -165,8 +165,8 @@ public void VerifyUsingCommandBasedPredictor(string userInput)
/// Verifies that when no prediction is in the command based list, we'll use the fallback list.
/// </summary>
[Theory]
[InlineData("New-AzApiManagementContext -ResourceGroupName hello -Serv")]
[InlineData("Get-AzAlert -TimeRange '1h' -Incl")]
[InlineData("Set-Variable -Name desc -Value ")]
[InlineData("remove-ite")]
public void VerifyUsingFallbackPredictor(string userInput)
{
var predictionContext = PredictionContext.Create(userInput);
Expand Down Expand Up @@ -209,12 +209,13 @@ public void VerifyUsingFallbackPredictor(string userInput)
/// </summary>
[Theory]
[InlineData(AzPredictorConstants.CommandPlaceholder)]
[InlineData("Get-Help")]
[InlineData("Get-ChildItem")]
[InlineData("new-azresourcegroup -NoExistingParam")]
[InlineData("get-azaccount ")]
[InlineData("NEW-AZCONTEXT")]
[InlineData("Remove-Item -NoExistingParam")]
[InlineData("get-childitem ")]
[InlineData("NEW-CHILDITEM ")]
[InlineData("git status")]
[InlineData("Get-AzContext Name")]
[InlineData("get-item name")]
public void VerifyNoPrediction(string userInput)
{
var predictionContext = PredictionContext.Create(userInput);
Expand All @@ -235,7 +236,7 @@ public void VerifyNoPrediction(string userInput)
/// Verify that it returns null when we cannot parse the user input.
/// </summary>
[Theory]
[InlineData("New-AzVM -Name A $Location")]
[InlineData("Remove-Item -Name A $Location")]
public void VerifyFailToParseUserInput(string userInput)
{
var predictionContext = PredictionContext.Create(userInput);
Expand Down
Loading