-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (44 loc) · 1.95 KB
/
Copy pathtests.yml
File metadata and controls
46 lines (44 loc) · 1.95 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
name: Tests
on:
push:
branches: [develop]
paths:
- "**.psm1"
- "**.psd1"
workflow_dispatch:
jobs:
basic_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Run Basic Tests
working-directory: ${{ github.workspace }}
shell: pwsh
run: |
Write-Output "INFO: Setting PowerShell Gallery as a trusted repository."
Set-PSRepository psgallery -InstallationPolicy trusted
$moduleManifest = (Get-ChildItem -Path $env:GITHUB_WORKSPACE -Filter *.psd1).Name
if ($moduleManifest) {
Write-Output "SUCCESS: Manifest '$moduleManifest' found in '$env:GITHUB_WORKSPACE'."
} else {
Write-Output "FAILURE: Manifest not found in '$env:GITHUB_WORKSPACE'."
}
if ($moduleManifest -match '^(.*)\.psd1$') {
$moduleName = $Matches[1]
Write-Output "SUCCESS: Determining module name from manifest'$moduleManifest'."
} else {
Write-Error "FAILED: Determining module name from manifest '$moduleManifest'."
}
Write-Output "INFO: Reading module manifest '$moduleManifest'."
$moduleManifestData = Import-PowerShellDataFile -Path $moduleManifest
Write-Output "INFO: Importing module '$moduleName' from '$moduleManifest'."
Import-Module -Name (Resolve-Path $moduleManifest).Path -Force -ErrorAction Stop
if (Get-Module -Name $moduleName) {
Write-Output "SUCCESS: Module '$moduleName' was imported."
} else {
Write-Error "FAILED: Module '$moduleName' was not imported."
}
Write-Output "INFO: Installing module 'Pester' from PSGallery."
Install-Module -Name Pester -confirm:$false -Force
Write-Output "INFO: Invoking Pester tests."
Invoke-Pester -Path "./.ci/pester.tests.ps1" -Output Detailed -PassThru