Skip to content

Commit d6c3b53

Browse files
Initial setup with Azure Pipelines CI (#107)
Adds CI validation via Azure Dev Ops Pipelines. Validation includes both static analysis validation (via PSScriptAnalyzer) and UT validation (via Pester). Builds will automatically run when changes are merged into master, but must be kicked off manually for PR's after code inspection has occurred. Two "hacks" were added to tests that were consistently failing without the hack in ADO. A separate issue will be opened to track identifying the proper fix for those tests.
1 parent 4030361 commit d6c3b53

File tree

7 files changed

+68
-68
lines changed

7 files changed

+68
-68
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ Set-GitHubConfiguration -LogRequestBody
285285
----------
286286

287287
### Testing
288-
[![Build status](https://ci.appveyor.com/api/projects/status/vsfq8kxo2et2dn7i?svg=true
289-
)](https://ci.appveyor.com/project/HowardWolosky/powershellforgithub)
288+
[![Build status](https://dev.azure.com/ms/PowerShellForGitHub/_apis/build/status/PowerShellForGitHub-CI?branchName=master)](https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master)
290289

291290
#### Installing Pester
292291
This module supports testing using the [Pester UT framework](https://github.com/pester/Pester).
@@ -348,8 +347,7 @@ There are many more nuances to code-coverage, see
348347
[its documentation](https://github.com/pester/Pester/wiki/Code-Coverage) for more details.
349348

350349
#### Automated Tests
351-
[![Build status](https://ci.appveyor.com/api/projects/status/vsfq8kxo2et2dn7i?svg=true
352-
)](https://ci.appveyor.com/project/HowardWolosky/powershellforgithub)
350+
[![Build status](https://dev.azure.com/ms/PowerShellForGitHub/_apis/build/status/PowerShellForGitHub-CI?branchName=master)](https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master)
353351

354352
These test are configured to automatically execute upon any update to the `master` branch
355353
on the `HowardWolosky` fork of `PowerShellForGitHub`. (At this time, we don't have the proper

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# PowerShellForGitHub PowerShell Module
22

33
[![[GitHub version]](https://badge.fury.io/gh/PowerShell%2FPowerShellForGitHub.svg)](https://badge.fury.io/gh/PowerShell%2FPowerShellForGitHub)
4-
[![Build status](https://ci.appveyor.com/api/projects/status/vsfq8kxo2et2dn7i?svg=true
5-
)](https://ci.appveyor.com/project/HowardWolosky/powershellforgithub)
4+
[![Build status](https://dev.azure.com/ms/PowerShellForGitHub/_apis/build/status/PowerShellForGitHub-CI?branchName=master)](https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master)
65

76
#### Table of Contents
87

Tests/Common.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ function Initialize-CommonTestSetup
3232
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification="Needed to configure with the stored, encrypted string value in AppVeyor.")]
3333
param()
3434

35-
$moduleRootPath = Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)
35+
$moduleRootPath = Split-Path -Path $PSScriptRoot -Parent
3636
. (Join-Path -Path $moduleRootPath -ChildPath 'Tests\Config\Settings.ps1')
3737
Import-Module -Name (Join-Path -Path $moduleRootPath -ChildPath 'PowerShellForGitHub.psd1') -Force
3838

39-
if ([string]::IsNullOrEmpty($env:avAccessToken))
39+
if ([string]::IsNullOrEmpty($env:ciAccessToken))
4040
{
4141
$message = @(
4242
'The tests are using the configuration settings defined in Tests\Config\Settings.ps1.',
@@ -48,14 +48,14 @@ function Initialize-CommonTestSetup
4848
}
4949
else
5050
{
51-
$secureString = $env:avAccessToken | ConvertTo-SecureString -AsPlainText -Force
51+
$secureString = $env:ciAccessToken | ConvertTo-SecureString -AsPlainText -Force
5252
$cred = New-Object System.Management.Automation.PSCredential "<username is ignored>", $secureString
5353
Set-GitHubAuthentication -Credential $cred
5454

55-
$script:ownerName = $env:avOwnerName
56-
$script:organizationName = $env:avOrganizationName
55+
$script:ownerName = $env:ciOwnerName
56+
$script:organizationName = $env:ciOrganizationName
5757

58-
Write-Warning -Message 'This run is being executed in the AppVeyor environment.'
58+
Write-Warning -Message 'This run is being executed in the Azure Dev Ops environment.'
5959
}
6060

6161
$script:accessTokenConfigured = Test-GitHubAuthenticationConfigured

Tests/GitHubAnalytics.tests.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,10 @@ try
242242
}
243243

244244
Describe 'Getting repositories from organization' {
245+
<# Temporary hack due to issues with this test in ADO #> . (Join-Path -Path $moduleRootPath -ChildPath 'Tests\Config\Settings.ps1')
246+
245247
$original = Get-GitHubRepository -OrganizationName $script:organizationName
246248

247-
$repositoryName = [guid]::NewGuid().Guid
248249
$repo = New-GitHubRepository -RepositoryName ([guid]::NewGuid().Guid) -OrganizationName $script:organizationName
249250
$current = Get-GitHubRepository -OrganizationName $script:organizationName
250251

Tests/GitHubRepositoryForks.tests.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ try
3535
$originalForks = Get-GitHubRepositoryFork -OwnerName Microsoft -RepositoryName PowerShellForGitHub
3636

3737
Context 'When a new fork is created' {
38+
<# Temporary hack due to issues with this test in ADO #> . (Join-Path -Path $moduleRootPath -ChildPath 'Tests\Config\Settings.ps1')
39+
3840
$repo = New-GitHubRepositoryFork -OwnerName Microsoft -RepositoryName PowerShellForGitHub -OrganizationName $script:organizationName
3941
$newForks = Get-GitHubRepositoryFork -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Sort Newest
4042

appveyor.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

azure-pipelines.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
# Continuous Integration (CI)
3+
# This pipeline validates the module for StaticAnalysis and Unit Test issues.
4+
#
5+
6+
trigger:
7+
- master
8+
9+
# Intionally not having the PR trigger, as we want to kick off PR validation manually after code inspection
10+
#pr:
11+
#- master
12+
13+
pool:
14+
vmImage: 'vs2017-win2016'
15+
16+
steps:
17+
- powershell: |
18+
Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Scope CurrentUser -AllowClobber -SkipPublisherCheck -Force -Verbose
19+
displayName: 'Install PSScriptAnalyzer'
20+
21+
- powershell: |
22+
$results = Invoke-ScriptAnalyzer -Path ./ –Recurse
23+
$results | ForEach-Object { Write-Host "##vso[task.logissue type=$($_.Severity);sourcepath=$($_.ScriptPath);linenumber=$($_.Line);columnnumber=$($_.Column);]$($_.Message)" }
24+
displayName: 'Run Static Code Analysis (PSScriptAnalyzer)'
25+
26+
- powershell: |
27+
Install-Module -Name Pester -Repository PSGallery -Scope CurrentUser -AllowClobber -SkipPublisherCheck -Force -Verbose
28+
displayName: 'Install Pester'
29+
30+
- powershell: |
31+
Invoke-Pester -CodeCoverage .\*.ps*1 -CodeCoverageOutputFile ./coverage.xml -CodeCoverageOutputFileFormat JaCoCo -EnableExit -Strict -OutputFile ./test-results.xml -OutputFormat NUnitXml
32+
workingDirectory: '$(System.DefaultWorkingDirectory)'
33+
displayName: 'Run Unit Tests via Pester'
34+
env:
35+
ciAccessToken: $(GitHubAccessToken)
36+
ciOwnerName: $(GitHubOwnerName)
37+
ciOrganizatioName: $(GitHubOrganizationName)
38+
39+
- task: PublishTestResults@2
40+
displayName: 'Publish Test Results'
41+
inputs:
42+
testRunTitle: 'Windows Test Results for Pester'
43+
buildPlatform: 'Windows'
44+
testRunner: NUnit
45+
testResultsFiles: './test-results.xml'
46+
failTaskOnFailedTests: true # required to fail build when tests fail
47+
condition: succeededOrFailed()
48+
49+
- task: PublishCodeCoverageResults@1
50+
displayName: 'Publish code coverage'
51+
inputs:
52+
codeCoverageTool: 'JaCoCo'
53+
summaryFileLocation: './coverage.xml'
54+
failIfCoverageEmpty: true
55+
condition: and(succeededOrFailed(), eq(variables['System.PullRequest.IsFork'], false))

0 commit comments

Comments
 (0)