-
Notifications
You must be signed in to change notification settings - Fork 7
109 lines (101 loc) · 4 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
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
name: CI
on:
workflow_dispatch:
pull_request:
jobs:
test-pssa:
runs-on: ubuntu-latest
steps:
- name: folder list
shell: pwsh
run: |
pwd
gci -recurse
- name: Build psm1
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PowerShellBuild -ErrorAction Stop
# setting a path other than the current dir for Build-PSBuildModule didn't work
cd ${{ github.workspace }}/${{ env.module_name }}
pwd
# new-item -path '${{ github.workspace }}/merged' -ItemType directory
Build-PSBuildModule -Path . -DestinationPath ../merged -ModuleName VenafiPS -Compile -Verbose
- name: Upload module artifact
uses: actions/upload-artifact@v3
with:
name: published_module
path: |
${{ github.workspace }}/merged/${{ env.module_name }}.psm1
${{ github.workspace }}/merged/${{ env.module_name }}.psd1
- 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