From 4975ed1b33fac442ba1016b0b89e320333a874bf Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 14 Sep 2018 18:57:55 -0700 Subject: [PATCH 01/11] add appveyor --- appveyor.yml | 22 ++++++++++++++++++++++ build.ps1 | 33 +++++++++++++++++++-------------- 2 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..065b2623 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,22 @@ +version: 0.1.{build} +pull_requests: + do_not_increment_build_number: true +branches: + only: + - dev + - master + +image: +- Ubuntu +- Visual Studio 2017 + +max_jobs: 1 + +build_script: + - pwsh: ./build.ps1 -Clean + +test_script: + - pwsh: ./build.ps1 -NoBuild -Test + +artifacts: + - path: package/bin/$(configuration)/Microsoft.Azure.Functions.PowerShell.Worker.0.1.0.nupkg diff --git a/build.ps1 b/build.ps1 index a283d758..1320519a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -13,6 +13,10 @@ param( [switch] $Test, + [Parameter()] + [switch] + $NoBuild, + [Parameter()] [string] $Configuration = "Debug" @@ -58,28 +62,29 @@ if ($missingTools.Count -gt 0) { Push-Location $PSScriptRoot # Clean step -if($Clean) { +if($Clean.IsPresent) { git clean -fdx } # Build step +if(!$NoBuild.IsPresent) { + # Install using PSDepend if it's available, otherwise use the backup script + if ((Get-Module -ListAvailable -Name PSDepend).Count -gt 0) { + Invoke-PSDepend -Path src -Force + } else { + & "$PSScriptRoot/tools/InstallDependencies.ps1" + } -# Install using PSDepend if it's available, otherwise use the backup script -if ((Get-Module -ListAvailable -Name PSDepend).Count -gt 0) { - Invoke-PSDepend -Path src -Force -} else { - & "$PSScriptRoot/tools/InstallDependencies.ps1" -} - -dotnet build -c $Configuration -dotnet publish -c $Configuration + dotnet build -c $Configuration + dotnet publish -c $Configuration -Push-Location package -dotnet pack -c $Configuration -Pop-Location + Push-Location package + dotnet pack -c $Configuration + Pop-Location +} # Test step -if($Test) { +if($Test.IsPresent) { Push-Location test dotnet test Invoke-Pester Modules From dcae4ad84fc1862528c47b6a3f8b056a118447cb Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 14 Sep 2018 19:13:31 -0700 Subject: [PATCH 02/11] add PSDepend and hard code configuration for now --- appveyor.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 065b2623..bae4cbb2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,6 +12,9 @@ image: max_jobs: 1 +install: + - pwsh: Install-Module PSDepend -Force + build_script: - pwsh: ./build.ps1 -Clean @@ -19,4 +22,4 @@ test_script: - pwsh: ./build.ps1 -NoBuild -Test artifacts: - - path: package/bin/$(configuration)/Microsoft.Azure.Functions.PowerShell.Worker.0.1.0.nupkg + - path: package/bin/Debug/Microsoft.Azure.Functions.PowerShell.Worker.0.1.0.nupkg From 77bad9b26aa5b123baf83a3c83dc8bc14f8c507d Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 14 Sep 2018 19:16:12 -0700 Subject: [PATCH 03/11] Scope CurrentUser --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index bae4cbb2..24eacad4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,7 +13,7 @@ image: max_jobs: 1 install: - - pwsh: Install-Module PSDepend -Force + - pwsh: Install-Module PSDepend -Force -Scope CurrentUser build_script: - pwsh: ./build.ps1 -Clean From 4c4329a9af5a8f4c51532162afb70a1a7851e3be Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 14 Sep 2018 19:25:55 -0700 Subject: [PATCH 04/11] no . --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 24eacad4..91ae315f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,4 +22,4 @@ test_script: - pwsh: ./build.ps1 -NoBuild -Test artifacts: - - path: package/bin/Debug/Microsoft.Azure.Functions.PowerShell.Worker.0.1.0.nupkg + - path: package/bin/Debug/Microsoft.Azure.Functions.PowerShellWorker.0.1.0.nupkg From c18fc7bf0f4ad06647bd20d5bf05de8947147fd3 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 14 Sep 2018 19:34:35 -0700 Subject: [PATCH 05/11] upload Pester tests --- build.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 1320519a..4a16cb18 100644 --- a/build.ps1 +++ b/build.ps1 @@ -87,7 +87,14 @@ if(!$NoBuild.IsPresent) { if($Test.IsPresent) { Push-Location test dotnet test - Invoke-Pester Modules + + if($env:APPVEYOR) { + $res = Invoke-Pester Modules -OutputFormat NUnitXml -OutputFile TestsResults.xml -PassThru + (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.xml)) + if ($res.FailedCount -gt 0) { throw "$($res.FailedCount) tests failed." } + } else { + Invoke-Pester Modules + } Pop-Location } From 3469815eda9ef4eb05c1e47c878dc66a61979978 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 14 Sep 2018 19:49:01 -0700 Subject: [PATCH 06/11] configuration --- appveyor.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 91ae315f..1ae737d8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,14 +12,16 @@ image: max_jobs: 1 +configuration: Debug + install: - pwsh: Install-Module PSDepend -Force -Scope CurrentUser build_script: - - pwsh: ./build.ps1 -Clean + - pwsh: ./build.ps1 -Clean -Configuration $(configuration) test_script: - pwsh: ./build.ps1 -NoBuild -Test artifacts: - - path: package/bin/Debug/Microsoft.Azure.Functions.PowerShellWorker.0.1.0.nupkg + - path: package/bin/$(configuration)/Microsoft.Azure.Functions.PowerShellWorker.0.1.0.nupkg From 2b4f49fcaa2991c491cc59d4fb147d79365f83cb Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 14 Sep 2018 19:53:54 -0700 Subject: [PATCH 07/11] CONFIGURATION --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1ae737d8..c2095081 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,10 +18,10 @@ install: - pwsh: Install-Module PSDepend -Force -Scope CurrentUser build_script: - - pwsh: ./build.ps1 -Clean -Configuration $(configuration) + - pwsh: ./build.ps1 -Clean -Configuration $env:CONFIGURATION test_script: - pwsh: ./build.ps1 -NoBuild -Test artifacts: - - path: package/bin/$(configuration)/Microsoft.Azure.Functions.PowerShellWorker.0.1.0.nupkg + - path: package/bin/$env:CONFIGURATION/Microsoft.Azure.Functions.PowerShellWorker.0.1.0.nupkg From 55b9b39e6d33d04f90fc05d5ac5bd5d79f769f47 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 14 Sep 2018 20:01:18 -0700 Subject: [PATCH 08/11] $(configuration) --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index c2095081..50b5f352 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,4 +24,4 @@ test_script: - pwsh: ./build.ps1 -NoBuild -Test artifacts: - - path: package/bin/$env:CONFIGURATION/Microsoft.Azure.Functions.PowerShellWorker.0.1.0.nupkg + - path: package\bin\$(configuration)\Microsoft.Azure.Functions.PowerShellWorker.*.nupkg From 9e37ac01492d1723274b6e9f394000251f07725e Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 14 Sep 2018 20:18:40 -0700 Subject: [PATCH 09/11] * instead of env var and ErrorActionPref --- appveyor.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 50b5f352..70867a00 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,10 +18,12 @@ install: - pwsh: Install-Module PSDepend -Force -Scope CurrentUser build_script: - - pwsh: ./build.ps1 -Clean -Configuration $env:CONFIGURATION + - pwsh: | + $ErrorActionPreference = "Stop" + ./build.ps1 -Clean -Configuration $env:CONFIGURATION test_script: - pwsh: ./build.ps1 -NoBuild -Test artifacts: - - path: package\bin\$(configuration)\Microsoft.Azure.Functions.PowerShellWorker.*.nupkg + - path: package\bin\*\Microsoft.Azure.Functions.PowerShellWorker.*.nupkg From 8ba37f21031e1345c32807f8dd355b7b21e64134 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 14 Sep 2018 20:20:51 -0700 Subject: [PATCH 10/11] more spaces --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 70867a00..323c864a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,8 +19,8 @@ install: build_script: - pwsh: | - $ErrorActionPreference = "Stop" - ./build.ps1 -Clean -Configuration $env:CONFIGURATION + $ErrorActionPreference = "Stop" + ./build.ps1 -Clean -Configuration $env:CONFIGURATION test_script: - pwsh: ./build.ps1 -NoBuild -Test From eb4884a374c9ab08c0b4788f4aba8ca53ad39fc2 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 17 Sep 2018 10:07:13 -0700 Subject: [PATCH 11/11] explictly say paths and remove bogus failing test --- build.ps1 | 26 ++++------- test/Requests/HandleWorkerInitRequestTests.cs | 44 ------------------- 2 files changed, 8 insertions(+), 62 deletions(-) delete mode 100644 test/Requests/HandleWorkerInitRequestTests.cs diff --git a/build.ps1 b/build.ps1 index 4a16cb18..9f2f9941 100644 --- a/build.ps1 +++ b/build.ps1 @@ -58,45 +58,35 @@ if ($missingTools.Count -gt 0) { return } -# Start at the root of the directory -Push-Location $PSScriptRoot - # Clean step if($Clean.IsPresent) { + Push-Location $PSScriptRoot git clean -fdx + Pop-Location } # Build step if(!$NoBuild.IsPresent) { # Install using PSDepend if it's available, otherwise use the backup script if ((Get-Module -ListAvailable -Name PSDepend).Count -gt 0) { - Invoke-PSDepend -Path src -Force + Invoke-PSDepend -Path "$PSScriptRoot/src" -Force } else { & "$PSScriptRoot/tools/InstallDependencies.ps1" } - dotnet build -c $Configuration - dotnet publish -c $Configuration - - Push-Location package - dotnet pack -c $Configuration - Pop-Location + dotnet publish -c $Configuration $PSScriptRoot + dotnet pack -c $Configuration "$PSScriptRoot/package" } # Test step if($Test.IsPresent) { - Push-Location test - dotnet test + dotnet test "$PSScriptRoot/test" if($env:APPVEYOR) { - $res = Invoke-Pester Modules -OutputFormat NUnitXml -OutputFile TestsResults.xml -PassThru + $res = Invoke-Pester "$PSScriptRoot/test/Modules" -OutputFormat NUnitXml -OutputFile TestsResults.xml -PassThru (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.xml)) if ($res.FailedCount -gt 0) { throw "$($res.FailedCount) tests failed." } } else { - Invoke-Pester Modules + Invoke-Pester "$PSScriptRoot/test/Modules" } - Pop-Location } - -# Return to the original directory -Pop-Location diff --git a/test/Requests/HandleWorkerInitRequestTests.cs b/test/Requests/HandleWorkerInitRequestTests.cs deleted file mode 100644 index c9adef27..00000000 --- a/test/Requests/HandleWorkerInitRequestTests.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// - -using Microsoft.Azure.Functions.PowerShellWorker; -using Microsoft.Azure.Functions.PowerShellWorker.Utility; -using Microsoft.Azure.WebJobs.Script.Grpc.Messages; -using Xunit; - -namespace Microsoft.Azure.Functions.PowerShellWorker.Test -{ - public class ProcessWorkerInitRequestTests - { - [Fact] - public void HandleWorkerInitRequestSuccess() - { - var requestId = "testRequest"; - var status = StatusResult.Types.Status.Success; - var expectedResponse = new StreamingMessage() - { - RequestId = requestId, - WorkerInitResponse = new WorkerInitResponse() - { - Result = new StatusResult() - { - Status = status - } - } - }; - - var requestProcessor = new RequestProcessor(null); - StreamingMessage result = requestProcessor.ProcessWorkerInitRequest( - new StreamingMessage() - { - RequestId = requestId - } - ); - - Assert.Equal(requestId, result.RequestId); - Assert.Equal(status, result.WorkerInitResponse.Result.Status); - } - } -}