-
Notifications
You must be signed in to change notification settings - Fork 96
60 lines (59 loc) · 2.25 KB
/
pester.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
name: Pester Tests
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
pester-test:
name: Pester test
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
experimental: [false]
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Perform a Pester test from the Tests.ps1 file
shell: pwsh
run: |
[System.Void](Invoke-Pester -script .\tests -PassThru -Show None -OutputFormat NUnit2.5 -OutVariable issues)
$failed_tests = @()
$passed_tests = @()
Foreach ($Result in $issues.Failed) {
[System.Array]$failed_tests += [PSCustomObject]@{
Name = $Result.Name
Status = $Result.Result
Passed = $Result.Passed
ExecutedAt = $Result.ExecutedAt
ErrorMessage = $Result.ErrorRecord.Exception.Message
}
}
Foreach ($Result in $issues.Passed) {
[System.Array]$passed_tests += [PSCustomObject]@{
Name = $Result.Name
Status = $Result.Result
Passed = $Result.Passed
ExecutedAt = $Result.ExecutedAt
}
}
if($passed_tests){
foreach ($e in $passed_tests){
$message = ("test_Name={0},Status={1},Passed={2}, ExecutedAt={3}" -f $e.Name,$e.Status,$e.Passed,$e.ExecutedAt)
$msgObject = [System.Management.Automation.HostInformationMessage]@{
Message = $message
ForegroundColor = [consolecolor]::Green
BackgroundColor = $Host.UI.RawUI.BackgroundColor
}
Write-Information -MessageData $msgObject -InformationAction Continue
}
}
if($failed_tests){
foreach ($e in $failed_tests){
$message = ("test_Name={0},Status={1},Passed={2}, ExecutedAt={3}, ErrorMessage={4}" -f $e.Name,$e.Status,$e.Passed,$e.ExecutedAt,$e.ErrorMessage)
Write-Error -Message $message
}
}