Skip to content

Commit 6da8f8d

Browse files
Set up CI with Azure Pipelines (#921)
* Set up CI with Azure Pipelines [skip ci] * linux * macos and linux * windows * trx * change to vstest * fix driveletter test failures * need a OS check * Fix drive letter in tests * Make lazy drive letter readonly * Fix readonly * add artifacts * publish to artifact staging directory * try to clean up * get rid of .. * some weird HRESULT * add job name * typo * test what env vars are avail * naming * version * goodbye Travis and AppVeyor * codacy :) * Patrick's feedback Co-Authored-By: TylerLeonhardt <[email protected]>
1 parent c664daf commit 6da8f8d

File tree

10 files changed

+129
-163
lines changed

10 files changed

+129
-163
lines changed

.travis.yml

-36
This file was deleted.

.vsts-ci/azure-pipelines-ci.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
trigger:
2+
- master
3+
- legacy/1.x
4+
variables:
5+
# Don't download unneeded packages
6+
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
7+
value: 'true'
8+
# Don't send telemetry
9+
- name: DOTNET_CLI_TELEMETRY_OPTOUT
10+
value: 'true'
11+
jobs:
12+
- job: Windows_powershell
13+
pool:
14+
vmImage: 'VS2017-Win2016'
15+
steps:
16+
- powershell: scripts/azurePipelinesBuild.ps1
17+
- task: PublishTestResults@2
18+
inputs:
19+
testRunner: VSTest
20+
testResultsFiles: '**/*.trx'
21+
condition: succeededOrFailed()
22+
- task: PublishBuildArtifacts@1
23+
inputs:
24+
ArtifactName: PowerShellEditorServices
25+
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
26+
27+
28+
- job: Windows_pwsh
29+
pool:
30+
vmImage: 'VS2017-Win2016'
31+
steps:
32+
- template: templates/ci-general.yml
33+
34+
- job: macOS
35+
pool:
36+
vmImage: 'macOS-10.13'
37+
steps:
38+
- template: templates/ci-general.yml
39+
40+
- job: Linux
41+
pool:
42+
vmImage: 'Ubuntu-16.04'
43+
steps:
44+
- template: templates/ci-general.yml

.vsts-ci/templates/ci-general.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
steps:
2+
- pwsh: scripts/azurePipelinesBuild.ps1
3+
- task: PublishTestResults@2
4+
inputs:
5+
testRunner: VSTest
6+
testResultsFiles: '**/*.trx'
7+
condition: succeededOrFailed()
8+
- task: PublishBuildArtifacts@1
9+
inputs:
10+
ArtifactName: PowerShellEditorServices
11+
PathtoPublish: '$(Build.ArtifactStagingDirectory)'

CONTRIBUTING.md

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Contribution Guidelines
22

3-
We welcome many kinds of community contributions to this project! Whether it's a feature implementation,
4-
bug fix, or a good idea, please create an issue so that we can discuss it. It is not necessary to create an
5-
issue before sending a pull request but it may speed up the process if we can discuss your idea before
3+
We welcome many kinds of community contributions to this project! Whether it's a feature implementation,
4+
bug fix, or a good idea, please create an issue so that we can discuss it. It is not necessary to create an
5+
issue before sending a pull request but it may speed up the process if we can discuss your idea before
66
you start implementing it.
77

8-
Because this project exposes a couple different public APIs, we must be very mindful of any potential breaking
9-
changes. Some contributions may not be accepted if they risk introducing breaking changes or if they
8+
Because this project exposes a couple different public APIs, we must be very mindful of any potential breaking
9+
changes. Some contributions may not be accepted if they risk introducing breaking changes or if they
1010
don't match the goals of the project. The core maintainer team has the right of final approval over
11-
any contribution to this project. However, we are very happy to hear community feedback on any decision
11+
any contribution to this project. However, we are very happy to hear community feedback on any decision
1212
so that we can ensure we are solving the right problems in the right way.
1313

1414
**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
3131
- Follow established guidelines for commit hygiene
3232
- Write unit tests to validate new features and bug fixes
3333
- Ensure that the 'Release' build and unit tests pass locally
34-
- Ensure that the AppVeyor build passes for your change
34+
- Ensure that the Azure DevOps build passes for your change
3535
- Respond to all review feedback and final commit cleanup
3636

3737
### Practice Good Commit Hygiene
@@ -44,46 +44,46 @@ so that your commits provide a good history of the changes you are making. To b
4444
Commit messages should be clearly written so that a person can look at the commit log and understand
4545
how and why a given change was made. Here is a great model commit message taken from a [blog post
4646
by Tim Pope](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html):
47-
47+
4848
Capitalized, short (50 chars or less) summary
49-
49+
5050
More detailed explanatory text, if necessary. Wrap it to about 72
5151
characters or so. In some contexts, the first line is treated as the
5252
subject of an email and the rest of the text as the body. The blank
5353
line separating the summary from the body is critical (unless you omit
5454
the body entirely); tools like rebase can get confused if you run the
5555
two together.
56-
56+
5757
Write your commit message in the imperative: "Fix bug" and not "Fixed bug"
5858
or "Fixes bug." This convention matches up with commit messages generated
5959
by commands like git merge and git revert.
60-
60+
6161
Further paragraphs come after blank lines.
62-
62+
6363
- Bullet points are okay, too
64-
64+
6565
- Typically a hyphen or asterisk is used for the bullet, followed by a
6666
single space, with blank lines in between, but conventions vary here
67-
67+
6868
- Use a hanging indent
69-
69+
7070
A change that fixes a known bug with an issue filed should use the proper syntax so that the [issue
71-
is automatically closed](https://help.github.com/articles/closing-issues-via-commit-messages/) once
71+
is automatically closed](https://help.github.com/articles/closing-issues-via-commit-messages/) once
7272
your change is merged. Here's an example of what such a commit message should look like:
73-
73+
7474
Fix #3: Catch NullReferenceException from DoThing
75-
75+
7676
This change adds a try/catch block to catch a NullReferenceException that
7777
gets thrown by DoThing [...]
7878

7979
- **Squash your commits**
8080

81-
If you are introducing a new feature but have implemented it over multiple commits,
82-
please [squash those commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)
81+
If you are introducing a new feature but have implemented it over multiple commits,
82+
please [squash those commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)
8383
into a single commit that contains all the changes in one place. This especially applies to any "oops"
84-
commits where a file is forgotten or a typo is being fixed. Following this approach makes it a lot easier
84+
commits where a file is forgotten or a typo is being fixed. Following this approach makes it a lot easier
8585
to pull those changes to other branches or roll back the change if necessary.
86-
86+
8787
- **Keep individual commits for larger changes**
8888

8989
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
9696
If you're adding a new feature to the project, please make sure to include adequate [xUnit](http://xunit.github.io/)
9797
tests with your change. In this project, we have chosen write out unit tests in a way that uses the
9898
actual PowerShell environment rather than extensive interface mocking. This allows us to be sure that
99-
our features will work in practice.
99+
our features will work in practice.
100100

101-
We do both component-level and scenario-level testing depending on what code is being tested. We don't
102-
expect contributors to test every possible edge case. Testing mainline scenarios and the most common
101+
We do both component-level and scenario-level testing depending on what code is being tested. We don't
102+
expect contributors to test every possible edge case. Testing mainline scenarios and the most common
103103
failure scenarios is often good enough.
104104

105105
We are very happy to accept unit test contributions for any feature areas that are more error-prone than
@@ -118,15 +118,15 @@ on this check so that our project will always have good generated documentation.
118118

119119
- **Create your pull request**
120120

121-
Use the [typical process](https://help.github.com/articles/using-pull-requests/) to send a pull request
121+
Use the [typical process](https://help.github.com/articles/using-pull-requests/) to send a pull request
122122
from your fork of the project. In your pull request message, please give a high-level summary of the
123123
changes that you have made so that reviewers understand the intent of the changes. You should receive
124124
initial comments within a day or two, but please feel free to ping if things are taking longer than
125125
expected.
126126

127127
- **The build and unit tests must run green**
128128

129-
When you submit your pull request, our automated build system on AppVeyor will attempt to run a
129+
When you submit your pull request, our automated build system on Azure DevOps will attempt to run a
130130
Release build of your changes and then run all unit tests against the build. If you notice that
131131
any of your unit tests have failed, please fix them by creating a new commit and then pushing it
132132
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.
137137

138138
If the reviewers ask you to make changes, make them as a new commit to your branch and push them so
139139
that they are made available for a final review pass. Do not rebase the fixes just yet so that the
140-
commit hash changes don't upset GitHub's pull request UI.
141-
140+
commit hash changes don't upset GitHub's pull request UI.
141+
142142
- **If necessary, do a final rebase**
143143

144144
Once your final changes have been accepted, we may ask you to do a final rebase to have your commits
145145
so that they follow our commit guidelines. If specific guidance is given, please follow it when
146-
rebasing your commits. Once you do your final push and we see the AppVeyor build pass, we will
146+
rebasing your commits. Once you do your final push and we see the Azure DevOps build pass, we will
147147
merge your changes!
148-
148+
149149
### Security Reporting
150150

151151
If you believe that there is a security vulnerability in the PowerShell extension for VSCode,

PowerShellEditorServices.build.ps1

+14-48
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ param(
1818

1919
#Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"}
2020

21-
$script:IsCIBuild = $env:APPVEYOR -ne $null
21+
$script:IsCIBuild = $env:TF_BUILD -ne $null
2222
$script:IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq "Core" -and !$IsWindows
2323
$script:TargetPlatform = "netstandard2.0"
2424
$script:TargetFrameworksParam = "/p:TargetFrameworks=`"$script:TargetPlatform`""
@@ -264,8 +264,11 @@ task GetProductVersion -Before PackageNuGet, PackageModule, UploadArtifacts {
264264
$script:BuildNumber = 9999
265265
$script:VersionSuffix = $props.Project.PropertyGroup.VersionSuffix
266266

267-
if ($env:APPVEYOR) {
268-
$script:BuildNumber = $env:APPVEYOR_BUILD_NUMBER
267+
if ($env:TF_BUILD) {
268+
# SYSTEM_PHASENAME is the Job name.
269+
# Job names can only include `_` but that's not a valid character for versions.
270+
$jobname = $env:SYSTEM_PHASENAME -replace '_', ''
271+
$script:BuildNumber = "$jobname-$env:BUILD_BUILDNUMBER"
269272
}
270273

271274
if ($script:VersionSuffix -ne $null) {
@@ -285,12 +288,7 @@ task CreateBuildInfo -Before Build {
285288
$buildOrigin = "<development>"
286289

287290
# Set build info fields on build platforms
288-
if ($env:APPVEYOR)
289-
{
290-
$buildVersion = $env:APPVEYOR_BUILD_VERSION
291-
$buildOrigin = if ($env:CI) { "AppVeyor CI" } else { "AppVeyor" }
292-
}
293-
elseif ($env:TF_BUILD)
291+
if ($env:TF_BUILD)
294292
{
295293
$psd1Path = [System.IO.Path]::Combine($PSScriptRoot, "module", "PowerShellEditorServices", "PowerShellEditorServices.psd1")
296294
$buildVersion = (Import-PowerShellDataFile -LiteralPath $psd1Path).Version
@@ -331,24 +329,6 @@ task Build {
331329
exec { & $script:dotnetExe build -c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj $script:TargetFrameworksParam }
332330
}
333331

334-
function UploadTestLogs {
335-
if ($script:IsCIBuild) {
336-
$testLogsPath = "$PSScriptRoot/test/PowerShellEditorServices.Test.Host/bin/$Configuration/net452/logs"
337-
$testLogsZipPath = "$PSScriptRoot/TestLogs.zip"
338-
339-
if (Test-Path $testLogsPath) {
340-
[System.IO.Compression.ZipFile]::CreateFromDirectory(
341-
$testLogsPath,
342-
$testLogsZipPath)
343-
344-
Push-AppveyorArtifact $testLogsZipPath
345-
}
346-
else {
347-
Write-Host "`n### WARNING: Test logs could not be found!`n" -ForegroundColor Yellow
348-
}
349-
}
350-
}
351-
352332
function DotNetTestFilter {
353333
# Reference https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests
354334
if ($TestFilter) { @("--filter",$TestFilter) } else { "" }
@@ -360,23 +340,23 @@ task TestServer {
360340
Set-Location .\test\PowerShellEditorServices.Test\
361341

362342
if (-not $script:IsUnix) {
363-
exec { & $script:dotnetExe test -f $script:TestRuntime.Desktop (DotNetTestFilter) }
343+
exec { & $script:dotnetExe test --logger trx -f $script:TestRuntime.Desktop (DotNetTestFilter) }
364344
}
365345

366346
Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath {
367-
exec { & $script:dotnetExe test -f $script:TestRuntime.Core (DotNetTestFilter) }
347+
exec { & $script:dotnetExe test --logger trx -f $script:TestRuntime.Core (DotNetTestFilter) }
368348
}
369349
}
370350

371351
task TestProtocol {
372352
Set-Location .\test\PowerShellEditorServices.Test.Protocol\
373353

374354
if (-not $script:IsUnix) {
375-
exec { & $script:dotnetExe test -f $script:TestRuntime.Desktop (DotNetTestFilter) }
355+
exec { & $script:dotnetExe test --logger trx -f $script:TestRuntime.Desktop (DotNetTestFilter) }
376356
}
377357

378358
Invoke-WithCreateDefaultHook {
379-
exec { & $script:dotnetExe test -f $script:TestRuntime.Core (DotNetTestFilter) }
359+
exec { & $script:dotnetExe test --logger trx -f $script:TestRuntime.Core (DotNetTestFilter) }
380360
}
381361
}
382362

@@ -392,15 +372,6 @@ task TestHost {
392372
exec { & $script:dotnetExe test -f $script:TestRuntime.Core (DotNetTestFilter) }
393373
}
394374

395-
task CITest ?Test, {
396-
# This task is used to ensure we have a chance to upload
397-
# test logs as a CI artifact when the tests fail
398-
if (error Test) {
399-
UploadTestLogs
400-
Write-Error "Failing build due to test failure."
401-
}
402-
}
403-
404375
task LayoutModule -After Build {
405376
# Copy Third Party Notices.txt to module folder
406377
Copy-Item -Force -Path "$PSScriptRoot\Third Party Notices.txt" -Destination $PSScriptRoot\module\PowerShellEditorServices
@@ -519,14 +490,9 @@ task PackageModule {
519490
$false)
520491
}
521492

522-
task UploadArtifacts -If ($script:IsCIBuild) {
523-
if ($env:APPVEYOR) {
524-
Push-AppveyorArtifact .\src\PowerShellEditorServices\bin\$Configuration\Microsoft.PowerShell.EditorServices.$($script:FullVersion).nupkg
525-
Push-AppveyorArtifact .\src\PowerShellEditorServices.Protocol\bin\$Configuration\Microsoft.PowerShell.EditorServices.Protocol.$($script:FullVersion).nupkg
526-
Push-AppveyorArtifact .\src\PowerShellEditorServices.Host\bin\$Configuration\Microsoft.PowerShell.EditorServices.Host.$($script:FullVersion).nupkg
527-
Push-AppveyorArtifact .\PowerShellEditorServices-$($script:FullVersion).zip
528-
}
493+
task UploadArtifacts -If ($null -ne $env:TF_BUILD) {
494+
Copy-Item -Path .\PowerShellEditorServices-$($script:FullVersion).zip -Destination $env:BUILD_ARTIFACTSTAGINGDIRECTORY
529495
}
530496

531497
# The default task is to run the entire CI build
532-
task . GetProductVersion, Clean, Build, CITest, BuildCmdletHelp, PackageNuGet, PackageModule, UploadArtifacts
498+
task . GetProductVersion, Clean, Build, Test, BuildCmdletHelp, PackageNuGet, PackageModule, UploadArtifacts

README.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# PowerShell Editor Services
22

3+
[![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)
34
[![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)
45
[![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)
56

@@ -35,12 +36,6 @@ and communicate with it over named pipes (or Unix domain sockets on macOS & Linu
3536
and [Debug Adapter Protocol](https://github.com/Microsoft/vscode-debugadapter-node/blob/master/protocol/src/debugProtocol.ts).
3637
Detailed usage documentation for this module is coming soon!
3738

38-
## Build Status
39-
40-
| AppVeyor (Windows) | Travis CI (Linux / macOS) |
41-
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
42-
| [![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) |
43-
4439
## Documentation
4540

4641
Check out our **[documentation site](http://powershell.github.io/PowerShellEditorServices)** for information about

0 commit comments

Comments
 (0)