Skip to content

Commit

Permalink
add module import pipeline to be triggered on PR raises (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
singhgss authored Dec 21, 2023
1 parent 64a84f5 commit 43d94f6
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/test-module-import.yml
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"
}

0 comments on commit 43d94f6

Please sign in to comment.