-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add module import pipeline to be triggered on PR raises (#59)
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: TestModuleImports | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Test Module Imports | ||
shell: powershell | ||
run: | | ||
$ErrorActionPreference = 'Stop' | ||
$moduleFiles = Get-ChildItem -path ./* -recurse -include *.psm1 | ||
Write-Host "Count of module files: $($moduleFiles.count)" | ||
try { | ||
ForEach ($moduleFile in $moduleFiles) { | ||
Import-Module $moduleFile.Fullname -ErrorAction Stop | ||
} | ||
} | ||
catch { | ||
throw "Failed test import module '$moduleFile' with error: $_" | ||
} | ||
$importedModules = Get-Module | ||
Write-Host "Imported modules: `n $($importedModules.Path | Out-String)" | ||
$missingModules = $moduleFiles | Where-object {$_ -inotin ($importedModules).Path} | ||
If ($missingModules) { | ||
throw "The following modules failed import test: $missingModules" | ||
} |