PSSAResource.common.v5.Tests: Test ps1 and psm1 files in source (#…
#5
Workflow file for this run
This file contains hidden or 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
| name: 'Copilot Setup Steps' | |
| # This workflow sets up a complete development environment for the PowerShell module project | |
| # when executed by GitHub Copilot Agent for development assistance. | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| paths: | |
| - '.github/workflows/copilot-setup-steps.yml' | |
| push: | |
| paths: | |
| - '.github/workflows/copilot-setup-steps.yml' | |
| # cSpell: ignore unshallow | |
| jobs: | |
| copilot-setup-steps: | |
| name: Setup PowerShell Development Environment | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Full history needed for GitVersion | |
| # This step is needed for GitVersion because Copilot switches to its working branch | |
| # after checkout and fetches only depth 2. | |
| - name: Ensure full history for GitVersion | |
| shell: pwsh | |
| run: | | |
| Write-Host 'Ensuring full history for GitVersion...' -ForegroundColor Green | |
| $isShallow = (& git rev-parse --is-shallow-repository) -eq 'true' | |
| if ($isShallow) | |
| { | |
| Write-Host 'Repository is shallow. Fetching full history and tags...' -ForegroundColor DarkGray | |
| git fetch --prune --unshallow --tags --no-recurse-submodules | |
| if ($LASTEXITCODE -ne 0) | |
| { | |
| throw 'git fetch --unshallow failed' | |
| } | |
| } | |
| else | |
| { | |
| Write-Host 'Repository is not shallow. Refreshing tags...' -ForegroundColor DarkGray | |
| git fetch --prune --tags --no-recurse-submodules | |
| if ($LASTEXITCODE -ne 0) | |
| { | |
| throw 'git fetch --tags failed' | |
| } | |
| } | |
| Write-Host 'History ready for GitVersion.' -ForegroundColor Green | |
| - name: Install .NET Tools | |
| shell: pwsh | |
| run: | | |
| Write-Host 'Installing/Updating .NET tools...' -ForegroundColor Green | |
| # Install GitVersion for semantic versioning (idempotent) | |
| dotnet tool update --global GitVersion.Tool --version 5.* ` | |
| || dotnet tool install --global GitVersion.Tool --version 5.* | |
| # Verify installation | |
| dotnet-gitversion /version | |
| Write-Host '.NET tools ready.' -ForegroundColor Green | |
| - name: Verify GitVersion | |
| shell: pwsh | |
| run: | | |
| Write-Host 'Running GitVersion to determine semantic version...' -ForegroundColor Green | |
| dotnet-gitversion | ConvertFrom-Json | |
| - name: Resolve Dependencies | |
| shell: pwsh | |
| run: | | |
| Write-Host 'Resolving project dependencies...' -ForegroundColor Green | |
| # Run dependency resolution | |
| ./build.ps1 -ResolveDependency -Tasks 'noop' -ErrorAction Stop | |
| Write-Host 'Dependencies resolved successfully.' -ForegroundColor Green | |
| - name: Build Module | |
| shell: pwsh | |
| run: | | |
| $moduleName = 'DscResource.Test' | |
| Write-Host "Building $moduleName module..." -ForegroundColor Green | |
| # Build the module | |
| ./build.ps1 -Tasks 'build' -ErrorAction Stop | |
| # Verify build output | |
| if (Test-Path -Path "output\builtModule\$moduleName") | |
| { | |
| Write-Host "Module built successfully at: output\builtModule\$moduleName" -ForegroundColor Green | |
| Get-ChildItem -Path "output\builtModule\$moduleName" -Recurse | Select-Object Name, Length | Format-Table | |
| } | |
| else | |
| { | |
| Write-Error 'Module build failed - output directory not found' | |
| exit 1 | |
| } | |
| - name: Import Built Module | |
| shell: pwsh | |
| run: | | |
| $moduleName = 'DscResource.Test' | |
| Write-Host "Importing built $moduleName module..." -ForegroundColor Green | |
| ./build.ps1 -Tasks 'noop' | |
| Import-Module -Name $moduleName -Force | |
| # Verify module is loaded | |
| $module = Get-Module -Name $moduleName -ErrorAction SilentlyContinue | |
| if ($module) | |
| { | |
| Write-Host 'Module imported successfully:' -ForegroundColor Green | |
| Write-Host " Name: $($module.Name)" -ForegroundColor Cyan | |
| Write-Host " Version: $($module.Version)" -ForegroundColor Cyan | |
| Write-Host " Path: $($module.Path)" -ForegroundColor Cyan | |
| # Show available commands | |
| $commands = Get-Command -Module $moduleName | |
| if ($commands.Count -gt 0) | |
| { | |
| Write-Host " Exported Commands: $($commands.Count)" -ForegroundColor Cyan | |
| Write-Host 'Available Commands:' -ForegroundColor Cyan | |
| $commands | | |
| Select-Object Name, ModuleName | Format-Table -AutoSize | |
| } | |
| else | |
| { | |
| Write-Host 'No commands exported by the module.' -ForegroundColor Yellow | |
| } | |
| } | |
| else | |
| { | |
| Write-Error 'Failed to import module' | |
| exit 1 | |
| } |