-
-
Notifications
You must be signed in to change notification settings - Fork 67
176 lines (154 loc) · 6.11 KB
/
test-development.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
169
170
171
172
173
174
175
176
name: 'Validate development branch'
env:
BUILD_NUMBER: "704"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
on:
workflow_dispatch:
push:
branches: [ "development" ]
paths:
- 'Evergreen/**.ps1'
- 'Evergreen/**.psm1'
jobs:
psscriptanalyzer:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
name: Run PSScriptAnalyzer
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Run PSScriptAnalyzer (development push)
uses: microsoft/psscriptanalyzer-action@6b2948b1944407914a58661c49941824d149734f
with:
path: "./Evergreen"
recurse: true
output: results.sarif
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
pestertest5:
name: "Run Pester tests on Windows PowerShell (development push)"
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Pester tests
shell: powershell
working-directory: "${{ github.workspace }}"
run: |
.\tests\Install-Pester.ps1
Import-Module -Name "Pester" -Force -ErrorAction "Stop"
Import-Module -Name "$env:GITHUB_WORKSPACE\Evergreen" -Force
$Config = [PesterConfiguration]::Default
$Config.Run.Path = "$env:GITHUB_WORKSPACE\tests"
$Config.Run.PassThru = $true
$Config.CodeCoverage.Enabled = $true
$Config.CodeCoverage.Path = "$env:GITHUB_WORKSPACE\Evergreen"
$Config.CodeCoverage.OutputFormat = "JaCoCo"
$Config.CodeCoverage.OutputPath = "$env:GITHUB_WORKSPACE\CodeCoverage.xml"
$Config.Output.Verbosity = "Detailed"
$Config.TestResult.Enabled = $true
$Config.TestResult.OutputFormat = "NUnitXml"
$Config.TestResult.OutputPath = "$env:GITHUB_WORKSPACE\tests\TestResults.xml"
Invoke-Pester -Configuration $Config
# Upload test results
- name: Upload Pester test results
uses: actions/upload-artifact@v3
if: always()
with:
name: test-results
path: "${{ github.workspace }}\\tests\\TestResults.xml"
- name: Upload code coverage results
uses: actions/upload-artifact@v3
if: always()
with:
name: codecov-results
path: "${{ github.workspace }}\\CodeCoverage.xml"
# pestertest7:
# name: "Run Pester tests on PowerShell Core (development push)"
# needs: psscriptanalyzer
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Install module DnsClient-PS
# shell: pwsh
# working-directory: "${{ github.workspace }}"
# run: |
# [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Install-PackageProvider -Name "NuGet" -MinimumVersion "2.8.5.208" -Force -ErrorAction "SilentlyContinue"
# Install-PackageProvider -Name "PowerShellGet" -MinimumVersion "2.2.5" -Force -ErrorAction "SilentlyContinue"
# Set-PSRepository -Name "PSGallery" -InstallationPolicy "Trusted" -ErrorAction "SilentlyContinue"
# $params = @{
# Name = "DnsClient-PS"
# SkipPublisherCheck = $true
# Force = $true
# ErrorAction = "Stop"
# }
# Install-Module @params
# - name: Pester tests
# shell: pwsh
# working-directory: "${{ github.workspace }}"
# run: |
# ./tests/Install-Pester.ps1
# Import-Module -Name "Pester" -Force -ErrorAction "Stop"
# Import-Module -Name "$env:GITHUB_WORKSPACE/Evergreen" -Force
# $Config = [PesterConfiguration]::Default
# $Config.Run.Path = "$env:GITHUB_WORKSPACE/tests"
# $Config.Run.PassThru = $true
# $Config.CodeCoverage.Enabled = $true
# $Config.CodeCoverage.Path = "$env:GITHUB_WORKSPACE/Evergreen"
# $Config.CodeCoverage.OutputFormat = "JaCoCo"
# $Config.CodeCoverage.OutputPath = "$env:GITHUB_WORKSPACE/CodeCoverage7.xml"
# $Config.Output.Verbosity = "Detailed"
# $Config.TestResult.Enabled = $true
# $Config.TestResult.OutputFormat = "NUnitXml"
# $Config.TestResult.OutputPath = "$env:GITHUB_WORKSPACE/tests/TestResults7.xml"
# Invoke-Pester -Configuration $Config
# # Upload test results
# - name: Upload Pester test results
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: test-results
# path: "${{ github.workspace }}//tests//TestResults7.xml"
# - name: Upload code coverage results
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: codecov-results
# path: "${{ github.workspace }}//CodeCoverage7.xml"
publish-test-results:
name: "Publish Tests Results"
needs: [ "pestertest5"]
runs-on: ubuntu-latest
if: always()
permissions:
checks: write
# only needed unless run with comment_mode: off
pull-requests: write
steps:
- name: Download Pester Test Result Artifacts
uses: actions/download-artifact@v3
with:
name: test-results
path: test-results
- name: Publish Pester Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
nunit_files: "test-results/**/*.xml"
- name: Download Code Coverage Result Artifacts
uses: actions/download-artifact@v3
if: always()
with:
name: codecov-results
path: codecov-results
- name: Upload to Codecov
id: codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: "codecov-results/**/*.xml"
verbose: true