From 202b385c8248c33a7c9e448cdac93576cd7ae9bd Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Fri, 12 Apr 2019 16:22:45 -0700 Subject: [PATCH 01/13] legacy moved to AzDO --- .travis.yml | 35 ----------- .vsts-ci/azure-pipelines-ci.yml | 44 +++++++++++++ .vsts-ci/templates/ci-general.yml | 11 ++++ CONTRIBUTING.md | 62 +++++++++---------- PowerShellEditorServices.build.ps1 | 59 +++--------------- README.md | 7 +-- appveyor.yml | 26 -------- scripts/azurePipelinesBuild.ps1 | 17 +++++ scripts/travis.ps1 | 10 --- .../Session/WorkspaceTests.cs | 6 ++ 10 files changed, 119 insertions(+), 158 deletions(-) delete mode 100644 .travis.yml create mode 100644 .vsts-ci/azure-pipelines-ci.yml create mode 100644 .vsts-ci/templates/ci-general.yml delete mode 100644 appveyor.yml create mode 100644 scripts/azurePipelinesBuild.ps1 delete mode 100644 scripts/travis.ps1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b8ee9869c..000000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -language: cpp - -git: - depth: 1000 - -env: - # Avoid expensive initialization of dotnet cli, see: https://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds - DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 - -os: - - linux - - osx -sudo: required -dist: trusty -osx_image: xcode8.3 - -before_install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - brew update; - brew install openssl; - mkdir -p /usr/local/lib; - ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; - ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; - elif [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - sudo apt-get install libunwind8; - fi - -install: - - pushd scripts - - bash <(curl -s https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) - - popd - -script: - - ulimit -n 4096 - - pwsh -File scripts/travis.ps1 diff --git a/.vsts-ci/azure-pipelines-ci.yml b/.vsts-ci/azure-pipelines-ci.yml new file mode 100644 index 000000000..e12ee8277 --- /dev/null +++ b/.vsts-ci/azure-pipelines-ci.yml @@ -0,0 +1,44 @@ +trigger: +- master +- legacy/1.x +variables: + # Don't download unneeded packages + - name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE + value: 'true' + # Don't send telemetry + - name: DOTNET_CLI_TELEMETRY_OPTOUT + value: 'true' +jobs: +- job: Windows_powershell + pool: + vmImage: 'VS2017-Win2016' + steps: + - powershell: scripts/azurePipelinesBuild.ps1 + - task: PublishTestResults@2 + inputs: + testRunner: VSTest + testResultsFiles: '**/*.trx' + condition: succeededOrFailed() + - task: PublishBuildArtifacts@1 + inputs: + ArtifactName: PowerShellEditorServices + PathtoPublish: '$(Build.ArtifactStagingDirectory)' + + +- job: Windows_pwsh + pool: + vmImage: 'VS2017-Win2016' + steps: + - template: templates/ci-general.yml + +- job: macOS + pool: + vmImage: 'macOS-10.13' + steps: + - template: templates/ci-general.yml + +- job: Linux + pool: + vmImage: 'Ubuntu-16.04' + steps: + - template: templates/ci-general.yml diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml new file mode 100644 index 000000000..328370aa3 --- /dev/null +++ b/.vsts-ci/templates/ci-general.yml @@ -0,0 +1,11 @@ +steps: + - pwsh: scripts/azurePipelinesBuild.ps1 + - task: PublishTestResults@2 + inputs: + testRunner: VSTest + testResultsFiles: '**/*.trx' + condition: succeededOrFailed() + - task: PublishBuildArtifacts@1 + inputs: + ArtifactName: PowerShellEditorServices + PathtoPublish: '$(Build.ArtifactStagingDirectory)' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f68bb80f6..99fd971ab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,14 +1,14 @@ # Contribution Guidelines -We welcome many kinds of community contributions to this project! Whether it's a feature implementation, -bug fix, or a good idea, please create an issue so that we can discuss it. It is not necessary to create an -issue before sending a pull request but it may speed up the process if we can discuss your idea before +We welcome many kinds of community contributions to this project! Whether it's a feature implementation, +bug fix, or a good idea, please create an issue so that we can discuss it. It is not necessary to create an +issue before sending a pull request but it may speed up the process if we can discuss your idea before you start implementing it. -Because this project exposes a couple different public APIs, we must be very mindful of any potential breaking -changes. Some contributions may not be accepted if they risk introducing breaking changes or if they +Because this project exposes a couple different public APIs, we must be very mindful of any potential breaking +changes. Some contributions may not be accepted if they risk introducing breaking changes or if they don't match the goals of the project. The core maintainer team has the right of final approval over -any contribution to this project. However, we are very happy to hear community feedback on any decision +any contribution to this project. However, we are very happy to hear community feedback on any decision so that we can ensure we are solving the right problems in the right way. **NOTE**: If you believe there is a security vulnerability, please see [Security Reporting](#security-reporting). @@ -31,7 +31,7 @@ Here's a high level list of guidelines to follow to ensure your code contributio - Follow established guidelines for commit hygiene - Write unit tests to validate new features and bug fixes - Ensure that the 'Release' build and unit tests pass locally -- Ensure that the AppVeyor build passes for your change +- Ensure that the Azure DevOps build passes for your change - Respond to all review feedback and final commit cleanup ### Practice Good Commit Hygiene @@ -44,46 +44,46 @@ so that your commits provide a good history of the changes you are making. To b Commit messages should be clearly written so that a person can look at the commit log and understand how and why a given change was made. Here is a great model commit message taken from a [blog post by Tim Pope](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html): - + Capitalized, short (50 chars or less) summary - + More detailed explanatory text, if necessary. Wrap it to about 72 characters or so. In some contexts, the first line is treated as the subject of an email and the rest of the text as the body. The blank line separating the summary from the body is critical (unless you omit the body entirely); tools like rebase can get confused if you run the two together. - + Write your commit message in the imperative: "Fix bug" and not "Fixed bug" or "Fixes bug." This convention matches up with commit messages generated by commands like git merge and git revert. - + Further paragraphs come after blank lines. - + - Bullet points are okay, too - + - Typically a hyphen or asterisk is used for the bullet, followed by a single space, with blank lines in between, but conventions vary here - + - Use a hanging indent - + A change that fixes a known bug with an issue filed should use the proper syntax so that the [issue - is automatically closed](https://help.github.com/articles/closing-issues-via-commit-messages/) once + is automatically closed](https://help.github.com/articles/closing-issues-via-commit-messages/) once your change is merged. Here's an example of what such a commit message should look like: - + Fix #3: Catch NullReferenceException from DoThing - + This change adds a try/catch block to catch a NullReferenceException that gets thrown by DoThing [...] - **Squash your commits** - If you are introducing a new feature but have implemented it over multiple commits, - please [squash those commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) + If you are introducing a new feature but have implemented it over multiple commits, + please [squash those commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) into a single commit that contains all the changes in one place. This especially applies to any "oops" - commits where a file is forgotten or a typo is being fixed. Following this approach makes it a lot easier + commits where a file is forgotten or a typo is being fixed. Following this approach makes it a lot easier to pull those changes to other branches or roll back the change if necessary. - + - **Keep individual commits for larger changes** You can certainly maintain individual commits for different phases of a big change. For example, if @@ -96,10 +96,10 @@ so that your commits provide a good history of the changes you are making. To b If you're adding a new feature to the project, please make sure to include adequate [xUnit](http://xunit.github.io/) tests with your change. In this project, we have chosen write out unit tests in a way that uses the actual PowerShell environment rather than extensive interface mocking. This allows us to be sure that -our features will work in practice. +our features will work in practice. -We do both component-level and scenario-level testing depending on what code is being tested. We don't -expect contributors to test every possible edge case. Testing mainline scenarios and the most common +We do both component-level and scenario-level testing depending on what code is being tested. We don't +expect contributors to test every possible edge case. Testing mainline scenarios and the most common failure scenarios is often good enough. We are very happy to accept unit test contributions for any feature areas that are more error-prone than @@ -118,7 +118,7 @@ on this check so that our project will always have good generated documentation. - **Create your pull request** - Use the [typical process](https://help.github.com/articles/using-pull-requests/) to send a pull request + Use the [typical process](https://help.github.com/articles/using-pull-requests/) to send a pull request from your fork of the project. In your pull request message, please give a high-level summary of the changes that you have made so that reviewers understand the intent of the changes. You should receive initial comments within a day or two, but please feel free to ping if things are taking longer than @@ -126,7 +126,7 @@ on this check so that our project will always have good generated documentation. - **The build and unit tests must run green** - When you submit your pull request, our automated build system on AppVeyor will attempt to run a + When you submit your pull request, our automated build system on Azure DevOps will attempt to run a Release build of your changes and then run all unit tests against the build. If you notice that any of your unit tests have failed, please fix them by creating a new commit and then pushing it to your branch. If you see that some unrelated test has failed, try re-running the build for your @@ -137,15 +137,15 @@ on this check so that our project will always have good generated documentation. If the reviewers ask you to make changes, make them as a new commit to your branch and push them so that they are made available for a final review pass. Do not rebase the fixes just yet so that the - commit hash changes don't upset GitHub's pull request UI. - + commit hash changes don't upset GitHub's pull request UI. + - **If necessary, do a final rebase** Once your final changes have been accepted, we may ask you to do a final rebase to have your commits so that they follow our commit guidelines. If specific guidance is given, please follow it when - rebasing your commits. Once you do your final push and we see the AppVeyor build pass, we will + rebasing your commits. Once you do your final push and we see the Azure DevOps build pass, we will merge your changes! - + ### Security Reporting If you believe that there is a security vulnerability in the PowerShell extension for VSCode, diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 409eb5ee6..3f8b8b17f 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -18,7 +18,6 @@ param( #Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"} -$script:IsCIBuild = $env:APPVEYOR -ne $null $script:IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq "Core" -and !$IsWindows $script:TargetFrameworksParam = "/p:TargetFrameworks=\`"$(if (!$script:IsUnix) { "net452;" })netstandard1.6\`"" $script:SaveModuleSupportsAllowPrerelease = (Get-Command Save-Module).Parameters.ContainsKey("AllowPrerelease") @@ -120,8 +119,11 @@ task GetProductVersion -Before PackageNuGet, PackageModule, UploadArtifacts { $script:BuildNumber = 9999 $script:VersionSuffix = $props.Project.PropertyGroup.VersionSuffix - if ($env:APPVEYOR) { - $script:BuildNumber = $env:APPVEYOR_BUILD_NUMBER + if ($env:TF_BUILD) { + # SYSTEM_PHASENAME is the Job name. + # Job names can only include `_` but that's not a valid character for versions. + $jobname = $env:SYSTEM_PHASENAME -replace '_', '' + $script:BuildNumber = "$jobname-$env:BUILD_BUILDNUMBER" } if ($script:VersionSuffix -ne $null) { @@ -155,12 +157,7 @@ task CreateBuildInfo -Before Build { $buildOrigin = "" # Set build info fields on build platforms - if ($env:APPVEYOR) - { - $buildVersion = $env:APPVEYOR_BUILD_VERSION - $buildOrigin = if ($env:CI) { "AppVeyor CI" } else { "AppVeyor" } - } - elseif ($env:TF_BUILD) + if ($env:TF_BUILD) { $psd1Path = [System.IO.Path]::Combine($PSScriptRoot, "module", "PowerShellEditorServices", "PowerShellEditorServices.psd1") $buildVersion = (Import-PowerShellDataFile -LiteralPath $psd1Path).Version @@ -207,25 +204,7 @@ task Build { Copy-Item $PSScriptRoot\src\PowerShellEditorServices\bin\$Configuration\netstandard1.6\publish\runtimes\linux-64\native\libdisablekeyecho.so -Destination $PSScriptRoot\src\PowerShellEditorServices.Host\bin\$Configuration\netstandard1.6 } -function UploadTestLogs { - if ($script:IsCIBuild) { - $testLogsPath = "$PSScriptRoot/test/PowerShellEditorServices.Test.Host/bin/$Configuration/net452/logs" - $testLogsZipPath = "$PSScriptRoot/TestLogs.zip" - - if (Test-Path $testLogsPath) { - [System.IO.Compression.ZipFile]::CreateFromDirectory( - $testLogsPath, - $testLogsZipPath) - - Push-AppveyorArtifact $testLogsZipPath - } - else { - Write-Host "`n### WARNING: Test logs could not be found!`n" -ForegroundColor Yellow - } - } -} - -function XunitTraitFilter { +function DotNetTestFilter { # Reference https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests if ($TestFilter) { "-trait $TestFilter" } else { "" } } @@ -250,15 +229,6 @@ task TestHost -If { !$script:IsUnix } { exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (XunitTraitFilter) } } -task CITest ?Test, { - # This task is used to ensure we have a chance to upload - # test logs as a CI artifact when the tests fail - if (error Test) { - UploadTestLogs - Write-Error "Failing build due to test failure." - } -} - task LayoutModule -After Build { # Lay out the PowerShellEditorServices module's binaries New-Item -Force $PSScriptRoot\module\PowerShellEditorServices\bin\ -Type Directory | Out-Null @@ -375,12 +345,6 @@ task BuildCmdletHelp { New-ExternalHelp -Path $PSScriptRoot\module\docs -OutputPath $PSScriptRoot\module\PowerShellEditorServices\Commands\en-US -Force } -task PackageNuGet { - exec { & $script:dotnetExe pack -c $Configuration --version-suffix $script:VersionSuffix .\src\PowerShellEditorServices\PowerShellEditorServices.csproj $script:TargetFrameworksParam } - exec { & $script:dotnetExe pack -c $Configuration --version-suffix $script:VersionSuffix .\src\PowerShellEditorServices.Protocol\PowerShellEditorServices.Protocol.csproj $script:TargetFrameworksParam } - exec { & $script:dotnetExe pack -c $Configuration --version-suffix $script:VersionSuffix .\src\PowerShellEditorServices.Host\PowerShellEditorServices.Host.csproj $script:TargetFrameworksParam } -} - task PackageModule { [System.IO.Compression.ZipFile]::CreateFromDirectory( "$PSScriptRoot/module/", @@ -389,13 +353,8 @@ task PackageModule { $false) } -task UploadArtifacts -If ($script:IsCIBuild) { - if ($env:APPVEYOR) { - Push-AppveyorArtifact .\src\PowerShellEditorServices\bin\$Configuration\Microsoft.PowerShell.EditorServices.$($script:FullVersion).nupkg - Push-AppveyorArtifact .\src\PowerShellEditorServices.Protocol\bin\$Configuration\Microsoft.PowerShell.EditorServices.Protocol.$($script:FullVersion).nupkg - Push-AppveyorArtifact .\src\PowerShellEditorServices.Host\bin\$Configuration\Microsoft.PowerShell.EditorServices.Host.$($script:FullVersion).nupkg - Push-AppveyorArtifact .\PowerShellEditorServices-$($script:FullVersion).zip - } +task UploadArtifacts -If ($null -ne $env:TF_BUILD) { + Copy-Item -Path .\PowerShellEditorServices-$($script:FullVersion).zip -Destination $env:BUILD_ARTIFACTSTAGINGDIRECTORY } # The default task is to run the entire CI build diff --git a/README.md b/README.md index fcd67b0f8..b0dfe8431 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # PowerShell Editor Services +[![Build Status](https://powershell.visualstudio.com/PowerShellEditorServices/_apis/build/status/PowerShellEditorServices-ci?branchName=master)](https://powershell.visualstudio.com/PowerShellEditorServices/_build/latest?definitionId=50&branchName=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/fb9129c327dc4f459ad2fd167d9a574f)](https://app.codacy.com/app/TylerLeonhardt/PowerShellEditorServices?utm_source=github.com&utm_medium=referral&utm_content=PowerShell/PowerShellEditorServices&utm_campaign=Badge_Grade_Dashboard) [![Join the chat at https://gitter.im/PowerShell/PowerShellEditorServices](https://badges.gitter.im/PowerShell/PowerShellEditorServices.svg)](https://gitter.im/PowerShell/PowerShellEditorServices?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -35,12 +36,6 @@ and communicate with it over named pipes (or Unix domain sockets on macOS & Linu and [Debug Adapter Protocol](https://github.com/Microsoft/vscode-debugadapter-node/blob/master/protocol/src/debugProtocol.ts). Detailed usage documentation for this module is coming soon! -## Build Status - -| AppVeyor (Windows) | Travis CI (Linux / macOS) | -|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| -| [![Build status](https://ci.appveyor.com/api/projects/status/85tyhckawwxoiim2/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/powershelleditorservices/branch/master) | [![Build Status](https://travis-ci.org/PowerShell/PowerShellEditorServices.svg?branch=master)](https://travis-ci.org/PowerShell/PowerShellEditorServices) | - ## Documentation Check out our **[documentation site](http://powershell.github.io/PowerShellEditorServices)** for information about diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 53f3b5cdb..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,26 +0,0 @@ -version: '1.12.1{build}' -image: Visual Studio 2017 -clone_depth: 10 -skip_tags: true - -branches: - only: - - master - -environment: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Don't download unneeded packages - DOTNET_CLI_TELEMETRY_OPTOUT: true # Don't send telemetry - -install: - - ps: | - Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null - Import-PackageProvider NuGet -Force | Out-Null - Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null - Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force | Out-Null - Install-Module platyPS -RequiredVersion 0.9.0 -Scope CurrentUser -Force | Out-Null - -build_script: - - ps: Invoke-Build -Configuration Release - -# The build script takes care of the tests -test: off diff --git a/scripts/azurePipelinesBuild.ps1 b/scripts/azurePipelinesBuild.ps1 new file mode 100644 index 000000000..ab31ed358 --- /dev/null +++ b/scripts/azurePipelinesBuild.ps1 @@ -0,0 +1,17 @@ +$ErrorActionPreference = 'Stop' + +Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null +if ($IsWindows -or $PSVersionTable.PSVersion.Major -lt 6) { + # We rely on PowerShellGet's -AllowPrerelease which is in PowerShellGet 1.6 so we need to update PowerShellGet. + Get-Module PowerShellGet,PackageManagement | Remove-Module -Force -Verbose + powershell -Command { Install-Module -Name PowerShellGet -MinimumVersion 1.6 -Force -Confirm:$false -Verbose } + powershell -Command { Install-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force -Confirm:$false -Verbose } + Import-Module -Name PowerShellGet -MinimumVersion 1.6 -Force + Import-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force +} + +# Needed for build and docs gen. +Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser +Install-Module PlatyPS -RequiredVersion 0.9.0 -Scope CurrentUser + +Invoke-Build -Configuration Release diff --git a/scripts/travis.ps1 b/scripts/travis.ps1 deleted file mode 100644 index 5af67b0dd..000000000 --- a/scripts/travis.ps1 +++ /dev/null @@ -1,10 +0,0 @@ - - -# Install InvokeBuild -Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force -Install-Module PlatyPS -RequiredVersion 0.9.0 -Scope CurrentUser -Force - - -# Build the code and perform tests -Import-module InvokeBuild -Invoke-Build -Configuration Release diff --git a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs index b93d796d0..d579300e6 100644 --- a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs +++ b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs @@ -14,6 +14,12 @@ public class WorkspaceTests { private static readonly Version PowerShellVersion = new Version("5.0"); + private static readonly Lazy s_lazyDriveLetter = new Lazy(() => Path.GetFullPath("\\").Substring(0, 1)); + + public static string CurrentDriveLetter => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? s_lazyDriveLetter.Value + : string.Empty; + [Fact] public void CanResolveWorkspaceRelativePath() { From 50679b0ef05f59e3d25234993df7acd219a7b501 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 12 Apr 2019 17:05:17 -0700 Subject: [PATCH 02/13] removed task --- PowerShellEditorServices.build.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 3f8b8b17f..db38e0de0 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -32,7 +32,7 @@ if ($PSVersionTable.PSEdition -ne "Core") { Add-Type -Assembly System.IO.Compression.FileSystem } -task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestPowerShellApi, PackageNuGet { +task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestPowerShellApi { $requiredSdkVersion = "2.0.0" @@ -113,7 +113,7 @@ task Clean { Get-ChildItem $PSScriptRoot\module\PowerShellEditorServices\Commands\en-US\*-help.xml | Remove-Item -Force -ErrorAction Ignore } -task GetProductVersion -Before PackageNuGet, PackageModule, UploadArtifacts { +task GetProductVersion -Before PackageModule, UploadArtifacts { [xml]$props = Get-Content .\PowerShellEditorServices.Common.props $script:BuildNumber = 9999 @@ -358,4 +358,4 @@ task UploadArtifacts -If ($null -ne $env:TF_BUILD) { } # The default task is to run the entire CI build -task . GetProductVersion, Clean, Build, TestPowerShellApi, CITest, BuildCmdletHelp, PackageNuGet, PackageModule, UploadArtifacts +task . GetProductVersion, Clean, Build, TestPowerShellApi, CITest, BuildCmdletHelp, PackageModule, UploadArtifacts From f448bb72c4aaa1abb0d6ed135dcdb26578df4961 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 12 Apr 2019 17:20:39 -0700 Subject: [PATCH 03/13] no need to clean in CI and fix task --- PowerShellEditorServices.build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index db38e0de0..a8327ec07 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -358,4 +358,4 @@ task UploadArtifacts -If ($null -ne $env:TF_BUILD) { } # The default task is to run the entire CI build -task . GetProductVersion, Clean, Build, TestPowerShellApi, CITest, BuildCmdletHelp, PackageModule, UploadArtifacts +task . GetProductVersion, Build, TestPowerShellApi, Test, BuildCmdletHelp, PackageModule, UploadArtifacts From 922681615b74149e859f7b8a739bf0670295cc27 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 12 Apr 2019 17:29:20 -0700 Subject: [PATCH 04/13] missing RuntimeInformation --- .../PowerShellEditorServices.Test.csproj | 1 + test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj index 579ee55e0..66b43d662 100644 --- a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj +++ b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj @@ -18,6 +18,7 @@ + diff --git a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs index d579300e6..24957ee26 100644 --- a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs +++ b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs @@ -5,6 +5,7 @@ using System; using System.IO; +using System.Runtime.InteropServices; using Microsoft.PowerShell.EditorServices.Utility; using Xunit; From a2976457a2f63fc81fbb8db0c9449fd7a1bd04bf Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 12 Apr 2019 17:37:41 -0700 Subject: [PATCH 05/13] fix traits --- PowerShellEditorServices.build.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index a8327ec07..333d6f9ef 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -214,19 +214,19 @@ task Test TestServer,TestProtocol task TestServer -If { !$script:IsUnix } { Set-Location .\test\PowerShellEditorServices.Test\ exec { & $script:dotnetExe build -c $Configuration -f net452 } - exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (XunitTraitFilter) } + exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (DotNetTestFilter) } } task TestProtocol -If { !$script:IsUnix } { Set-Location .\test\PowerShellEditorServices.Test.Protocol\ exec { & $script:dotnetExe build -c $Configuration -f net452 } - exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (XunitTraitFilter) } + exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (DotNetTestFilter) } } task TestHost -If { !$script:IsUnix } { Set-Location .\test\PowerShellEditorServices.Test.Host\ exec { & $script:dotnetExe build -c $Configuration -f net452 } - exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (XunitTraitFilter) } + exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (DotNetTestFilter) } } task LayoutModule -After Build { From 9ee26adb1c5ab64a782c0d5f4fda94503fc104e5 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 12 Apr 2019 17:50:58 -0700 Subject: [PATCH 06/13] fix tests drive letter --- .../Session/WorkspaceTests.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs index 24957ee26..9bab95f26 100644 --- a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs +++ b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs @@ -79,22 +79,25 @@ public void CanDetermineIsPathInMemory() } [Theory()] - [InlineData("file:///C%3A/banana/", @"C:\banana\")] - [InlineData("file:///C%3A/banana/ex.ps1", @"C:\banana\ex.ps1")] - [InlineData("file:///E%3A/Path/to/awful%23path", @"E:\Path\to\awful#path")] - [InlineData("file:///path/with/no/drive", @"C:\path\with\no\drive")] - [InlineData("file:///path/wi[th]/squ[are/brackets/", @"C:\path\wi[th]\squ[are\brackets\")] - [InlineData("file:///Carrots/A%5Ere/Good/", @"C:\Carrots\A^re\Good\")] - [InlineData("file:///Users/barnaby/%E8%84%9A%E6%9C%AC/Reduce-Directory", @"C:\Users\barnaby\脚本\Reduce-Directory")] - [InlineData("file:///C%3A/Program%20Files%20%28x86%29/PowerShell/6/pwsh.exe", @"C:\Program Files (x86)\PowerShell\6\pwsh.exe")] - [InlineData("file:///home/maxim/test%20folder/%D0%9F%D0%B0%D0%BF%D0%BA%D0%B0/helloworld.ps1", @"C:\home\maxim\test folder\Папка\helloworld.ps1")] + [MemberData(nameof(s_PathsToResolve), parameters: 2)] public void CorrectlyResolvesPaths(string givenPath, string expectedPath) { Workspace workspace = new Workspace(PowerShellVersion, Logging.NullLogger); - string resolvedPath = workspace.ResolveFilePath(givenPath); - Assert.Equal(expectedPath, resolvedPath); } + + private static object[][] s_PathsToResolve = new object[][] + { + new object[] { "file:///C%3A/banana/", @"C:\banana\" }, + new object[] { "file:///C%3A/banana/ex.ps1", @"C:\banana\ex.ps1" }, + new object[] { "file:///E%3A/Path/to/awful%23path", @"E:\Path\to\awful#path" }, + new object[] { "file:///path/with/no/drive", $@"{CurrentDriveLetter}:\path\with\no\drive" }, + new object[] { "file:///path/wi[th]/squ[are/brackets/", $@"{CurrentDriveLetter}:\path\wi[th]\squ[are\brackets\" }, + new object[] { "file:///Carrots/A%5Ere/Good/", $@"{CurrentDriveLetter}:\Carrots\A^re\Good\" }, + new object[] { "file:///Users/barnaby/%E8%84%9A%E6%9C%AC/Reduce-Directory", $@"{CurrentDriveLetter}:\Users\barnaby\脚本\Reduce-Directory" }, + new object[] { "file:///C%3A/Program%20Files%20%28x86%29/PowerShell/6/pwsh.exe", @"C:\Program Files (x86)\PowerShell\6\pwsh.exe" }, + new object[] { "file:///home/maxim/test%20folder/%D0%9F%D0%B0%D0%BF%D0%BA%D0%B0/helloworld.ps1", $@"{CurrentDriveLetter}:\home\maxim\test folder\Папка\helloworld.ps1" } + }; } } From 82928825e9fc988e68a87e9105eed62b9829a282 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 12 Apr 2019 17:59:59 -0700 Subject: [PATCH 07/13] make public --- .../Session/WorkspaceTests.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs index 9bab95f26..61c779c58 100644 --- a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs +++ b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs @@ -87,17 +87,17 @@ public void CorrectlyResolvesPaths(string givenPath, string expectedPath) Assert.Equal(expectedPath, resolvedPath); } - private static object[][] s_PathsToResolve = new object[][] + public static object[][] s_PathsToResolve = new object[][] { - new object[] { "file:///C%3A/banana/", @"C:\banana\" }, - new object[] { "file:///C%3A/banana/ex.ps1", @"C:\banana\ex.ps1" }, - new object[] { "file:///E%3A/Path/to/awful%23path", @"E:\Path\to\awful#path" }, - new object[] { "file:///path/with/no/drive", $@"{CurrentDriveLetter}:\path\with\no\drive" }, - new object[] { "file:///path/wi[th]/squ[are/brackets/", $@"{CurrentDriveLetter}:\path\wi[th]\squ[are\brackets\" }, - new object[] { "file:///Carrots/A%5Ere/Good/", $@"{CurrentDriveLetter}:\Carrots\A^re\Good\" }, - new object[] { "file:///Users/barnaby/%E8%84%9A%E6%9C%AC/Reduce-Directory", $@"{CurrentDriveLetter}:\Users\barnaby\脚本\Reduce-Directory" }, - new object[] { "file:///C%3A/Program%20Files%20%28x86%29/PowerShell/6/pwsh.exe", @"C:\Program Files (x86)\PowerShell\6\pwsh.exe" }, - new object[] { "file:///home/maxim/test%20folder/%D0%9F%D0%B0%D0%BF%D0%BA%D0%B0/helloworld.ps1", $@"{CurrentDriveLetter}:\home\maxim\test folder\Папка\helloworld.ps1" } + new [] { "file:///C%3A/banana/", @"C:\banana\" }, + new [] { "file:///C%3A/banana/ex.ps1", @"C:\banana\ex.ps1" }, + new [] { "file:///E%3A/Path/to/awful%23path", @"E:\Path\to\awful#path" }, + new [] { "file:///path/with/no/drive", $@"{CurrentDriveLetter}:\path\with\no\drive" }, + new [] { "file:///path/wi[th]/squ[are/brackets/", $@"{CurrentDriveLetter}:\path\wi[th]\squ[are\brackets\" }, + new [] { "file:///Carrots/A%5Ere/Good/", $@"{CurrentDriveLetter}:\Carrots\A^re\Good\" }, + new [] { "file:///Users/barnaby/%E8%84%9A%E6%9C%AC/Reduce-Directory", $@"{CurrentDriveLetter}:\Users\barnaby\脚本\Reduce-Directory" }, + new [] { "file:///C%3A/Program%20Files%20%28x86%29/PowerShell/6/pwsh.exe", @"C:\Program Files (x86)\PowerShell\6\pwsh.exe" }, + new [] { "file:///home/maxim/test%20folder/%D0%9F%D0%B0%D0%BF%D0%BA%D0%B0/helloworld.ps1", $@"{CurrentDriveLetter}:\home\maxim\test folder\Папка\helloworld.ps1" } }; } } From 760bac842d49bf988ec1047601e7e4a5b9c989c1 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 12 Apr 2019 18:12:04 -0700 Subject: [PATCH 08/13] get xunit help --- PowerShellEditorServices.build.ps1 | 2 ++ test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 333d6f9ef..62f14a125 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -213,6 +213,8 @@ task Test TestServer,TestProtocol task TestServer -If { !$script:IsUnix } { Set-Location .\test\PowerShellEditorServices.Test\ + Write-Host "HERE HERE HERE" + exec { & $script:dotnetExe xunit --help } exec { & $script:dotnetExe build -c $Configuration -f net452 } exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (DotNetTestFilter) } } diff --git a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs index 61c779c58..9ded6e46e 100644 --- a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs +++ b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs @@ -87,7 +87,7 @@ public void CorrectlyResolvesPaths(string givenPath, string expectedPath) Assert.Equal(expectedPath, resolvedPath); } - public static object[][] s_PathsToResolve = new object[][] + public static readonly object[][] s_PathsToResolve = new object[][] { new [] { "file:///C%3A/banana/", @"C:\banana\" }, new [] { "file:///C%3A/banana/ex.ps1", @"C:\banana\ex.ps1" }, From 80443c3c842343af6b21a1a9311151c6aa2be938 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 12 Apr 2019 18:33:07 -0700 Subject: [PATCH 09/13] capture tests --- .vsts-ci/templates/ci-general.yml | 4 ++-- PowerShellEditorServices.build.ps1 | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml index 328370aa3..5139b4b08 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -2,8 +2,8 @@ steps: - pwsh: scripts/azurePipelinesBuild.ps1 - task: PublishTestResults@2 inputs: - testRunner: VSTest - testResultsFiles: '**/*.trx' + testRunner: xUnit + testResultsFiles: '**/*.Results.xml' condition: succeededOrFailed() - task: PublishBuildArtifacts@1 inputs: diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 62f14a125..676d63f13 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -213,22 +213,20 @@ task Test TestServer,TestProtocol task TestServer -If { !$script:IsUnix } { Set-Location .\test\PowerShellEditorServices.Test\ - Write-Host "HERE HERE HERE" - exec { & $script:dotnetExe xunit --help } exec { & $script:dotnetExe build -c $Configuration -f net452 } - exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (DotNetTestFilter) } + exec { & $script:dotnetExe xunit -xml $PSScriptRoot/PowerShellEditorServices.Test.Results.xml -configuration $Configuration -framework net452 -verbose -nobuild (DotNetTestFilter) } } task TestProtocol -If { !$script:IsUnix } { Set-Location .\test\PowerShellEditorServices.Test.Protocol\ exec { & $script:dotnetExe build -c $Configuration -f net452 } - exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (DotNetTestFilter) } + exec { & $script:dotnetExe xunit -xml $PSScriptRoot/PowerShellEditorServices.Test.Protocol.Results.xml -configuration $Configuration -framework net452 -verbose -nobuild (DotNetTestFilter) } } task TestHost -If { !$script:IsUnix } { Set-Location .\test\PowerShellEditorServices.Test.Host\ exec { & $script:dotnetExe build -c $Configuration -f net452 } - exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild (DotNetTestFilter) } + exec { & $script:dotnetExe xunit -xml $PSScriptRoot/PowerShellEditorServices.Test.Host.Results.xml -configuration $Configuration -framework net452 -verbose -nobuild (DotNetTestFilter) } } task LayoutModule -After Build { From ab0cdbd068b65f17a22dd3970fa103e4effb7a99 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 12 Apr 2019 18:44:06 -0700 Subject: [PATCH 10/13] xUnit tests for windows powershell --- .vsts-ci/azure-pipelines-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vsts-ci/azure-pipelines-ci.yml b/.vsts-ci/azure-pipelines-ci.yml index e12ee8277..d129967c8 100644 --- a/.vsts-ci/azure-pipelines-ci.yml +++ b/.vsts-ci/azure-pipelines-ci.yml @@ -16,8 +16,8 @@ jobs: - powershell: scripts/azurePipelinesBuild.ps1 - task: PublishTestResults@2 inputs: - testRunner: VSTest - testResultsFiles: '**/*.trx' + testRunner: xUnit + testResultsFiles: '**/*.Results.xml' condition: succeededOrFailed() - task: PublishBuildArtifacts@1 inputs: From f58c0543245c80c2a2955be4dac79740ecaf88ae Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Mon, 15 Apr 2019 09:40:38 -0700 Subject: [PATCH 11/13] Update WorkspaceTests.cs --- test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs index 9ded6e46e..85c0adb9d 100644 --- a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs +++ b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs @@ -87,7 +87,7 @@ public void CorrectlyResolvesPaths(string givenPath, string expectedPath) Assert.Equal(expectedPath, resolvedPath); } - public static readonly object[][] s_PathsToResolve = new object[][] + private static readonly object[][] s_PathsToResolve = new object[][] { new [] { "file:///C%3A/banana/", @"C:\banana\" }, new [] { "file:///C%3A/banana/ex.ps1", @"C:\banana\ex.ps1" }, From 87a516f23516dff31202301c9ff1d25f97794866 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Mon, 15 Apr 2019 10:39:40 -0700 Subject: [PATCH 12/13] Update WorkspaceTests.cs --- test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs index 85c0adb9d..a2bd61f9a 100644 --- a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs +++ b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs @@ -79,7 +79,7 @@ public void CanDetermineIsPathInMemory() } [Theory()] - [MemberData(nameof(s_PathsToResolve), parameters: 2)] + [MemberData(nameof(PathsToResolve), parameters: 2)] public void CorrectlyResolvesPaths(string givenPath, string expectedPath) { Workspace workspace = new Workspace(PowerShellVersion, Logging.NullLogger); @@ -87,7 +87,7 @@ public void CorrectlyResolvesPaths(string givenPath, string expectedPath) Assert.Equal(expectedPath, resolvedPath); } - private static readonly object[][] s_PathsToResolve = new object[][] + public static IReadOnlyList PathsToResolve => new object[][] { new [] { "file:///C%3A/banana/", @"C:\banana\" }, new [] { "file:///C%3A/banana/ex.ps1", @"C:\banana\ex.ps1" }, From 55cb0998a0ba282473acfc964f4ffa1302c2da0c Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Mon, 15 Apr 2019 10:55:36 -0700 Subject: [PATCH 13/13] Update WorkspaceTests.cs --- test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs index a2bd61f9a..9762e3709 100644 --- a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs +++ b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs @@ -7,6 +7,7 @@ using System.IO; using System.Runtime.InteropServices; using Microsoft.PowerShell.EditorServices.Utility; +using System.Collections.Generic; using Xunit; namespace Microsoft.PowerShell.EditorServices.Test.Session