Repository navigation
99 lines (91 loc) · 2.9 KB
/
Copy pathpowershell.yml
File metadata and controls
99 lines (91 loc) · 2.9 KB
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
name: IT-ToolBox
on:
push:
branches: [master]
paths:
- 'Public/**'
- 'Private/**'
- 'Tests/**'
- 'scripts/**'
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- 'LICENSE'
- 'IT-ToolBox.psd1'
- 'IT-ToolBox.psm1'
- '.github/workflows/powershell.yml'
pull_request:
paths:
- 'Public/**'
- 'Private/**'
- 'Tests/**'
- 'scripts/**'
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- 'LICENSE'
- 'IT-ToolBox.psd1'
- 'IT-ToolBox.psm1'
- '.github/workflows/powershell.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
test:
name: Pester (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Check runtime and script syntax
run: |
$ErrorActionPreference = 'Stop'
$PSVersionTable
if ($PSVersionTable.PSVersion -lt [version]'7.4') {
throw 'PowerShell 7.4 or later is required.'
}
foreach ($file in Get-ChildItem ./Public, ./Private, ./Tests, ./scripts -Filter *.ps1 -Recurse) {
$tokens = $null
$parseErrors = $null
$null = [System.Management.Automation.Language.Parser]::ParseFile(
$file.FullName, [ref]$tokens, [ref]$parseErrors
)
if ($parseErrors.Count -gt 0) {
throw ($parseErrors | Out-String)
}
}
- name: Install Pester
run: |
$ErrorActionPreference = 'Stop'
Install-Module Pester -RequiredVersion 5.7.1 -Scope CurrentUser -Force -SkipPublisherCheck -Repository PSGallery
- name: Smoke test loader
run: |
$ErrorActionPreference = 'Stop'
Import-Module ./IT-ToolBox.psd1 -Force -ErrorAction Stop
$null = Get-Command New-LogEntry -CommandType Function -ErrorAction Stop
New-LogEntry -LogMessage 'CI smoke test' -BufferOnly
$entries = @(New-LogEntry -GetBuffer)
if ($entries.Count -ne 1 -or $entries[0] -notmatch '\[INFO\]: CI smoke test$') {
throw 'Loader smoke test failed.'
}
New-LogEntry -ClearBuffer
- name: Run Pester tests
run: |
$ErrorActionPreference = 'Stop'
Import-Module Pester -RequiredVersion 5.7.1 -Force
$configuration = New-PesterConfiguration
$configuration.Run.Path = './Tests'
$configuration.Run.Exit = $true
$configuration.Output.Verbosity = 'Detailed'
Invoke-Pester -Configuration $configuration
- name: Build supported module archive
run: ./scripts/Build-Module.ps1