-
Notifications
You must be signed in to change notification settings - Fork 2
/
azure-pipelines.yml
143 lines (140 loc) · 5.57 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
# Unit test pipeline for PowerShell Desktop platform
# This pipeline uses the Pester test framework to
# execute unit tests for the module.
# https://aka.ms/yaml
trigger:
- main
variables:
TEST_OUTPUT_DIRECTORY: $(Build.Repository.LocalPath)/test/results
TEST_OUTPUT_FILE: pester-testresults.xml
TEST_SAMPLES_OUTPUT_FILE: sample-testresults.xml
TEST_INTEGRATION_OUTPUT_FILE: integration-testresults.xml
TEST_APPID: 7cb1941c-080a-406a-8d4c-0bd8b06c37c9
TEST_APPTENANT: cb494bd3-5606-4ab6-bc24-d8187b172b2b
jobs:
- job: BuildWithTests
displayName: 'Build and test PowerShell module'
strategy:
matrix:
PowerShellDesktop:
VM_IMAGE: 'windows-latest'
OS_PLATFORM: 'windows'
USE_POWERSHELL_CORE: false
PowerShellCoreWindows:
VM_IMAGE: 'windows-latest'
OS_PLATFORM: 'windows'
USE_POWERSHELL_CORE: true
PowerShellCoreUbuntu:
VM_IMAGE: 'ubuntu-latest'
OS_PLATFORM: 'ubuntu'
USE_POWERSHELL_CORE: true
pool:
vmImage: $(VM_IMAGE)
steps:
- checkout: self
- task: AzureKeyVault@2
displayName: 'Populate pipeline variables with the certificate from keyvault'
inputs:
azureSubscription: 'Azure Free Trial(439deb75-e36b-4569-b075-f2c2448e8a3e)'
KeyVaultName: 'CI-AutoGraphPS-SDK'
SecretsFilter: 'CI-AutoGraph-App-Certificate'
RunAsPreJob: false
- task: powershell@2
displayName: 'Show current PowerShell version information'
inputs:
targetType: inline
script: 'echo $PSVersionTable'
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Get original Pester test framework module version'
inputs:
targetType: inline
script: 'Get-Module Pester -ListAvailable'
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Install Pester test framework required version'
inputs:
targetType: inline
script: 'Install-Module Pester -RequiredVersion 4.8.1 -scope currentuser -force -skippublishercheck'
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Get updated Pester test framework module version'
inputs:
targetType: inline
script: 'Get-Module Pester -ListAvailable'
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Clean build'
inputs:
targetType: inline
script: './build/clean-build.ps1'
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Install and configure build tools'
inputs:
targetType: inline
script: './build/configure-tools.ps1 -Force -Verbose'
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Install .net dependencies'
inputs:
targetType: inline
script: './build/configure-tools.ps1; ./build/install.ps1'
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Build module package'
inputs:
targetType: inline
script: './build/configure-tools.ps1; ./build/build-package -verbose;'
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Publish module for local testing'
condition: true
inputs:
targetType: inline
script: './build/configure-tools.ps1; ./build/publish-moduletodev.ps1' # Creates .devmodule directory
pwsh: false
- task: powershell@2
displayName: 'Create test output directory'
inputs:
targetType: inline
script: '. ./build/common-build-functions.ps1;psmkdir -name $env:TEST_OUTPUT_DIRECTORY'
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Run tests'
condition: eq(variables.OS_PLATFORM, 'windows') # Only on Windows because this hangs on Linux
inputs:
targetType: inline
script: si env:TEST_OUTPUT_PATH "$($env:TEST_OUTPUT_DIRECTORY)/$($env:TEST_OUTPUT_FILE)"; ./build/import-devmodule.ps1 -initialcommand 'Invoke-Pester -OutputFile $env:TEST_OUTPUT_PATH -OutputFormat NUnitXml' -Wait -ReuseConsole
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Run tests directly'
condition: eq(variables.OS_PLATFORM, 'ubuntu') # Only needed on Linux to avoid hangs
inputs:
targetType: inline
script: './build/Init-DirectTestRun.ps1 -verbose; Invoke-Pester -OutputFile "$($env:TEST_OUTPUT_DIRECTORY)/$($env:TEST_OUTPUT_FILE)" -OutputFormat NUnitXml'
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Run integration tests'
inputs:
targetType: inline
script: './test/CI/RunIntegrationTests.ps1 -TestRoot test -TestAppId $(TEST_APPID) -TestAppTenant $(TEST_APPTENANT) -CIBase64TestAppCert $(CI-AutoGraph-App-Certificate) -TestParamsPassThru @{OutputFile="$($env:TEST_OUTPUT_DIRECTORY)/$($env:TEST_INTEGRATION_OUTPUT_FILE)";OutputFormat="NUnitXml"} -verbose'
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Generate sample documents and tests'
inputs:
targetType: inline
script: './samples/Generate-SampleTestScripts.ps1 -verbose'
pwsh: $(USE_POWERSHELL_CORE)
- task: powershell@2
displayName: 'Run sample code integration tests'
inputs:
targetType: inline
script: './test/CI/RunIntegrationTests.ps1 -TestRoot .test -TestAppId $(TEST_APPID) -TestAppTenant $(TEST_APPTENANT) -CIBase64TestAppCert $(CI-AutoGraph-App-Certificate) -TestParamsPassThru @{OutputFile="$($env:TEST_OUTPUT_DIRECTORY)/$($env:TEST_SAMPLES_OUTPUT_FILE)";OutputFormat="NUnitXml"} -verbose'
pwsh: $(USE_POWERSHELL_CORE)
- task: PublishTestResults@2
inputs:
searchFolder: $(TEST_OUTPUT_DIRECTORY)
testResultsFormat: NUnit
testResultsFiles: '*.xml'
failTaskOnFailedTests: true