-
Notifications
You must be signed in to change notification settings - Fork 7
83 lines (79 loc) · 3.1 KB
/
ci.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
name: CI
on:
workflow_dispatch:
pull_request:
jobs:
test-pssa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install PSScriptAnalyzer module
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -ErrorAction Stop
- name: Lint with PSScriptAnalyzer
shell: pwsh
run: |
Invoke-ScriptAnalyzer -Path ./VenafiPS -Recurse -Outvariable issues
$issues | ConvertTo-Json -Depth 2 | Set-Content -Path '${{ github.workspace }}/pssa.json'
$errors = $issues.Where({$_.Severity -eq 'Error'})
$warnings = $issues.Where({$_.Severity -eq 'Warning'})
if ($errors) {
Write-Error "There were $($errors.Count) errors and $($warnings.Count) warnings total." -ErrorAction Stop
} else {
Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total."
}
- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: pssa-results
path: ${{ github.workspace }}/pssa.json
test-pwsh:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: Run Pester tests (pwsh)
run: |
Write-host $PSVersionTable.PSVersion.Major $PSVersionTable.PSRemotingProtocolVersion.Minor
Set-PSRepository psgallery -InstallationPolicy trusted
Install-Module -Name Pester -RequiredVersion 5.0.4 -confirm:$false -Force
import-module Pester
$config = [PesterConfiguration]::Default
$config.Run.Path = '${{ github.workspace }}/Tests'
$config.TestResult.Enabled = $true
$config.TestResult.OutputPath = 'test_result.xml'
Invoke-Pester -Configuration $config
shell: pwsh
- name: Upload test results
uses: actions/upload-artifact@v2
if: always()
with:
name: Powershell (v7) Pester Test Results ${{ matrix.platform }}
path: test_result.xml
test-posh:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Run Pester tests (PowerShell)
run: |
Write-host $PSVersionTable.PSVersion.Major $PSVersionTable.PSRemotingProtocolVersion.Minor
Set-PSRepository psgallery -InstallationPolicy trusted
Install-Module -Name Pester -RequiredVersion 5.0.4 -Confirm:$false -Force
import-module Pester
$config = [PesterConfiguration]::Default
$config.Run.Path = '${{ github.workspace }}/Tests'
$config.TestResult.Enabled = $true
$config.TestResult.OutputPath = 'test_result.xml'
Invoke-Pester -Configuration $config
if ($Error[0].Fullyqualifiederrorid -eq 'PesterAssertionFailed') {exit 1}
shell: powershell
- name: Upload test results
uses: actions/upload-artifact@v2
if: always()
with:
name: Windows Powershell (v5) Pester Test Results
path: test_result.xml