Skip to content

Commit

Permalink
chore(ci): update tests (#176)
Browse files Browse the repository at this point in the history
- Updates the basic tests to be generic and discoverable for pull requests.
- Tests that the module can be imported and that the manifest is well formed.
- Updated to Pester 5 syntax with detailed output.

Signed-off-by: Ryan Johnson <[email protected]>
  • Loading branch information
tenthirtyam authored Sep 23, 2023
1 parent afbb702 commit f6c259a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 61 deletions.
10 changes: 3 additions & 7 deletions .ci/pester.tests.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
BeforeAll {
Import-Module -Name "$PSScriptRoot/../VMware.CloudFoundation.Reporting.psd1" -Force -ErrorAction Stop
}

Describe -Tag:('ModuleValidation') 'Module Baseline Validation' {
Describe -Tag:('ModuleValidation') 'Module Basic Tests' {

It 'is present' {
$module = Get-Module VMware.CloudFoundation.Reporting
$module = Get-Module -Name $moduleName
$module | Should -Be $true
}

It ('passes Test-ModuleManifest') {
Test-ModuleManifest -Path:("$PSScriptRoot/../VMware.CloudFoundation.Reporting.psd1") | Should -Not -BeNullOrEmpty
Test-ModuleManifest -Path $moduleManifest | Should -Not -BeNullOrEmpty
$? | Should -Be $true
}
}
54 changes: 0 additions & 54 deletions .github/workflows/ci-module.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tests

on:
pull_request:
branches: [develop]
paths:
- "**.psm1"
- "**.psd1"

jobs:
basic_tests:
strategy:
matrix:
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Run Basic Tests
working-directory: ${{ github.workspace }}
run: |
$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'."
}
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."
}
Set-PSRepository psgallery -InstallationPolicy trusted
Install-Module -Name Pester -confirm:$false -Force
Invoke-Pester -Path "./.ci/pester.tests.ps1" -Output Detailed -PassThru
shell: pwsh

0 comments on commit f6c259a

Please sign in to comment.