forked from MethodsAndPractices/vsteam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
168 lines (130 loc) · 5.59 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: $(Build.BuildID)
resources:
- repo: self
phases:
- phase: Phase_2
displayName: Linux
condition: succeeded()
queue:
name: Hosted Ubuntu 1604
steps:
- powershell: |
# Load the psd1 file so you can read the required modules and install them
$manifest = Import-PowerShellDataFile .\Source\*.psd1
# Install each module
$manifest.RequiredModules | ForEach-Object { Install-Module -Name $_ -Repository PSGallery -F -Scope CurrentUser }
displayName: 'Install Dependencies'
- powershell: 'Install-Module -Name Pester -Repository PSGallery -Force -Scope CurrentUser -AllowClobber -SkipPublisherCheck'
displayName: 'Install Pester'
- powershell: |
Import-Module .\Source\*.psd1
Invoke-Pester -Script .\unit -EnableExit -Strict -OutputFile test-results.xml -OutputFormat NUnitXml -passthru
workingDirectory: '$(System.DefaultWorkingDirectory)'
displayName: 'Run Unit Tests'
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testRunner: NUnit
testResultsFiles: '**\test-results.xml'
testRunTitle: 'Linux Unit Tests'
condition: succeededOrFailed()
- phase: Phase_3
displayName: MacOS
condition: succeeded()
queue:
name: Hosted macOS
steps:
- powershell: |
# Load the psd1 file so you can read the required modules and install them
$manifest = Import-PowerShellDataFile .\Source\*.psd1
# Install each module
$manifest.RequiredModules | ForEach-Object { Install-Module -Name $_ -Repository PSGallery -F -Scope CurrentUser }
displayName: 'Install Dependencies'
- powershell: 'Install-Module -Name Pester -Repository PSGallery -Force -Scope CurrentUser -AllowClobber -SkipPublisherCheck'
displayName: 'Install Pester'
- powershell: |
Import-Module .\Source\*.psd1
Invoke-Pester -Script .\unit -EnableExit -Strict -OutputFile test-results.xml -OutputFormat NUnitXml -passthru
workingDirectory: '$(System.DefaultWorkingDirectory)'
displayName: 'Run Unit Tests'
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testRunner: NUnit
testResultsFiles: '**\test-results.xml'
testRunTitle: 'Mac Unit Tests'
condition: succeededOrFailed()
- phase: Phase_1
displayName: Windows
condition: succeeded()
queue:
name: Hosted VS2017
steps:
- powershell: |
# Load the psd1 file so you can read the required modules and install them
$manifest = Import-PowerShellDataFile .\Source\*.psd1
# Install each module
$manifest.RequiredModules | ForEach-Object { Install-Module -Name $_ -Repository PSGallery -F -Scope CurrentUser }
displayName: 'Install Dependencies'
- powershell: 'Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Force -Scope CurrentUser -Verbose'
displayName: 'Install PSScriptAnalyzer'
- powershell: |
# Has to happen in this task for it to take effect
# Load the psd1 file so you can read the required modules and import them
$manifest = Import-PowerShellDataFile .\Source\*.psd1
# Import each module
$manifest.RequiredModules | ForEach-Object { Import-Module -Name $_ }
$r = Invoke-ScriptAnalyzer –Path ./Source –Recurse | Where-Object severity -ne "Information"
$r | ForEach-Object {Write-Host "##vso[task.logissue type=$($_.Severity);sourcepath=$($_.ScriptPath);linenumber=$($_.Line);columnnumber=$($_.Column);]$($_.Message)"}
displayName: 'Run Static Code Analysis'
- powershell: './gen-help.ps1'
displayName: 'Generate Help'
workingDirectory: .docs
- powershell: 'Install-Module -Name Pester -Repository PSGallery -Force -Scope CurrentUser -AllowClobber -SkipPublisherCheck -Verbose'
displayName: 'Install Pester'
- powershell: |
Import-Module .\Source\*.psd1
Invoke-Pester -Script .\unit -CodeCoverage .\Source\*.ps*1 -CodeCoverageOutputFile coverage.xml -CodeCoverageOutputFileFormat JaCoCo -EnableExit -Strict -OutputFile test-results.xml -OutputFormat NUnitXml
displayName: 'Run Unit Tests'
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testRunner: NUnit
testResultsFiles: '**\TEST-*.xml'
testRunTitle: 'Windows Unit Tests'
condition: succeededOrFailed()
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
summaryFileLocation: '**\coverage.xml'
failIfCoverageEmpty: true
condition: and(succeededOrFailed(), eq(variables['System.PullRequest.IsFork'], false))
- task: CopyFiles@2
displayName: 'Copy Module to Artifacts Folder'
inputs:
Contents: |
README.md
.gitignore
Source\**
TargetFolder: '$(build.artifactstagingdirectory)/VSTeam'
condition: and(succeeded(), eq(variables['System.PullRequest.IsFork'], false))
- task: PublishBuildArtifacts@1
displayName: 'Publish Module'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)/VSTeam'
ArtifactName: Module
condition: and(succeeded(), eq(variables['System.PullRequest.IsFork'], false))
- task: CopyFiles@2
displayName: 'Copy Integration Tests Artifacts Folder'
inputs:
Contents: |
Source\*.psd1
integration\**
TargetFolder: '$(build.artifactstagingdirectory)/Tests'
condition: and(succeeded(), eq(variables['System.PullRequest.IsFork'], false))
- task: PublishBuildArtifacts@1
displayName: 'Publish Tests'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)/Tests'
ArtifactName: Test
condition: and(succeeded(), eq(variables['System.PullRequest.IsFork'], false))