|
| 1 | +name: 'GitHub Copilot Setup Steps' |
| 2 | + |
| 3 | +# This workflow sets up a complete development environment for the SqlServerDsc PowerShell DSC module project |
| 4 | +# when executed by GitHub Copilot Agent for development assistance. |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + skip_tests: |
| 10 | + description: 'Skip running tests during setup' |
| 11 | + required: false |
| 12 | + default: true |
| 13 | + type: boolean |
| 14 | + pull_request: |
| 15 | + paths: |
| 16 | + - '.github/workflows/copilot-setup-steps.yml' |
| 17 | + push: |
| 18 | + paths: |
| 19 | + - '.github/workflows/copilot-setup-steps.yml' |
| 20 | + |
| 21 | +# cSpell: ignore pwsh cmdlets DSCResources nupkg HQRM SqlServerDsc dotnet gitversion |
| 22 | +jobs: |
| 23 | + setup-development-environment: |
| 24 | + name: Setup SqlServerDsc Development Environment |
| 25 | + runs-on: windows-latest |
| 26 | + steps: |
| 27 | + - name: Checkout Repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + fetch-depth: 0 # Full history needed for GitVersion |
| 31 | + |
| 32 | + - name: Setup PowerShell Environment |
| 33 | + shell: pwsh |
| 34 | + run: | |
| 35 | + Write-Host "Setting up PowerShell environment..." -ForegroundColor Green |
| 36 | +
|
| 37 | + # Install dependent PowerShell modules |
| 38 | + Install-PSResource -Name 'SqlServer' -Version '21.1.18256' -Scope 'CurrentUser' -Repository 'PSGallery' -TrustRepository |
| 39 | +
|
| 40 | + # Set execution policy for development |
| 41 | + Set-ExecutionPolicy -ExecutionPolicy 'RemoteSigned' -Scope 'CurrentUser' -Force |
| 42 | +
|
| 43 | + Write-Host "PowerShell environment setup complete." -ForegroundColor Green |
| 44 | +
|
| 45 | + - name: Install .NET Tools |
| 46 | + shell: pwsh |
| 47 | + run: | |
| 48 | + Write-Host "Installing .NET tools..." -ForegroundColor Green |
| 49 | +
|
| 50 | + # Install GitVersion for semantic versioning |
| 51 | + dotnet tool install --global GitVersion.Tool --version 5.* |
| 52 | +
|
| 53 | + # Verify installation |
| 54 | + dotnet-gitversion |
| 55 | +
|
| 56 | + Write-Host ".NET tools installation complete." -ForegroundColor Green |
| 57 | +
|
| 58 | + - name: Verify GitVersion |
| 59 | + shell: pwsh |
| 60 | + run: | |
| 61 | + Write-Host "Running GitVersion to determine semantic version..." -ForegroundColor Green |
| 62 | + dotnet-gitversion | ConvertFrom-Json |
| 63 | +
|
| 64 | + - name: Resolve Dependencies |
| 65 | + shell: pwsh |
| 66 | + run: | |
| 67 | + Write-Host "Resolving project dependencies..." -ForegroundColor Green |
| 68 | +
|
| 69 | + # Run dependency resolution |
| 70 | + .\build.ps1 -ResolveDependency -Tasks 'noop' -ErrorAction Stop |
| 71 | +
|
| 72 | + Write-Host "Dependencies resolved successfully." -ForegroundColor Green |
| 73 | +
|
| 74 | + - name: Build Module |
| 75 | + shell: pwsh |
| 76 | + run: | |
| 77 | + Write-Host "Building SqlServerDsc module..." -ForegroundColor Green |
| 78 | +
|
| 79 | + # Build the module |
| 80 | + .\build.ps1 -Tasks 'build' -ErrorAction Stop |
| 81 | +
|
| 82 | + # Verify build output |
| 83 | + if (Test-Path -Path "output\builtModule\SqlServerDsc") { |
| 84 | + Write-Host "Module built successfully at: output\builtModule\SqlServerDsc" -ForegroundColor Green |
| 85 | + Get-ChildItem -Path "output\builtModule\SqlServerDsc" -Recurse | Select-Object Name, Length | Format-Table |
| 86 | + } else { |
| 87 | + Write-Error "Module build failed - output directory not found" |
| 88 | + exit 1 |
| 89 | + } |
| 90 | +
|
| 91 | + - name: Import Built Module |
| 92 | + shell: pwsh |
| 93 | + run: | |
| 94 | + Write-Host "Importing built SqlServerDsc module..." -ForegroundColor Green |
| 95 | +
|
| 96 | + .\build.ps1 -Tasks 'noop' |
| 97 | + Import-Module -Name 'SqlServerDsc' -Force |
| 98 | +
|
| 99 | + # Verify module is loaded |
| 100 | + $module = Get-Module -Name SqlServerDsc |
| 101 | + if ($module) { |
| 102 | + Write-Host "Module imported successfully:" -ForegroundColor Green |
| 103 | + Write-Host " Name: $($module.Name)" -ForegroundColor Cyan |
| 104 | + Write-Host " Version: $($module.Version)" -ForegroundColor Cyan |
| 105 | + Write-Host " Path: $($module.Path)" -ForegroundColor Cyan |
| 106 | +
|
| 107 | + # Show available commands and resources |
| 108 | + $commands = Get-Command -Module SqlServerDsc |
| 109 | + Write-Host " Exported Commands: $($commands.Count)" -ForegroundColor Cyan |
| 110 | +
|
| 111 | + $dscResources = Get-DscResource -Module SqlServerDsc |
| 112 | + Write-Host " DSC Resources: $($dscResources.Count)" -ForegroundColor Cyan |
| 113 | + } else { |
| 114 | + Write-Error "Failed to import module" |
| 115 | + exit 1 |
| 116 | + } |
| 117 | +
|
| 118 | + # - name: Run QA & Unit Tests (Optional) |
| 119 | + # if: ${{ inputs.skip_tests == false }} |
| 120 | + # shell: powershell |
| 121 | + # run: | |
| 122 | + # Write-Host "Running QA & unit tests..." -ForegroundColor Green |
| 123 | + |
| 124 | + # # Run QA & unit tests only (skip integration tests in setup) |
| 125 | + # .\build.ps1 -Tasks 'test' -PesterPath 'tests\Unit', 'tests\QA' |
| 126 | + |
| 127 | + # Write-Host "QA & unit tests completed." -ForegroundColor Green |
| 128 | + |
| 129 | + # - name: Validate Project Structure |
| 130 | + # shell: pwsh |
| 131 | + # run: | |
| 132 | + # Write-Host "Validating project structure..." -ForegroundColor Green |
| 133 | + |
| 134 | + # $requiredPaths = @( |
| 135 | + # 'source\Classes', |
| 136 | + # 'source\Public', |
| 137 | + # 'source\Private', |
| 138 | + # 'source\DSCResources', |
| 139 | + # 'source\en-US', |
| 140 | + # 'tests\Unit', |
| 141 | + # 'tests\Integration', |
| 142 | + # 'build.ps1', |
| 143 | + # 'build.yaml', |
| 144 | + # 'RequiredModules.psd1' |
| 145 | + # ) |
| 146 | + |
| 147 | + # $missingPaths = @() |
| 148 | + # foreach ($path in $requiredPaths) { |
| 149 | + # if (-not (Test-Path -Path $path)) { |
| 150 | + # $missingPaths += $path |
| 151 | + # } else { |
| 152 | + # Write-Host "✓ $path" -ForegroundColor Green |
| 153 | + # } |
| 154 | + # } |
| 155 | + |
| 156 | + # if ($missingPaths.Count -gt 0) { |
| 157 | + # Write-Warning "Missing expected project paths:" |
| 158 | + # $missingPaths | ForEach-Object { Write-Host " ✗ $_" -ForegroundColor Red } |
| 159 | + # } else { |
| 160 | + # Write-Host "All expected project paths found." -ForegroundColor Green |
| 161 | + # } |
| 162 | + |
| 163 | + - name: Setup Complete - Display Environment Info |
| 164 | + shell: pwsh |
| 165 | + run: | |
| 166 | + Write-Host "" |
| 167 | + Write-Host "=========================================" -ForegroundColor Green |
| 168 | + Write-Host "SqlServerDsc Development Environment Ready!" -ForegroundColor Green |
| 169 | + Write-Host "=========================================" -ForegroundColor Green |
| 170 | + Write-Host "" |
| 171 | + Write-Host "Project Information:" -ForegroundColor Cyan |
| 172 | + Write-Host " Repository: SqlServerDsc PowerShell DSC Module" -ForegroundColor White |
| 173 | + Write-Host " Type: Class-based DSC resources for SQL Server" -ForegroundColor White |
| 174 | + Write-Host " Framework: Sampler + ModuleBuilder" -ForegroundColor White |
| 175 | + Write-Host " Testing: Pester v5 framework" -ForegroundColor White |
| 176 | + Write-Host "" |
| 177 | + Write-Host "Available Build Commands:" -ForegroundColor Cyan |
| 178 | + Write-Host " .\build.ps1 -Tasks build # Build module" -ForegroundColor White |
| 179 | + Write-Host " .\build.ps1 -Tasks test # Run all tests" -ForegroundColor White |
| 180 | + Write-Host " .\build.ps1 -Tasks docs # Generate documentation" -ForegroundColor White |
| 181 | + Write-Host " .\build.ps1 -Tasks clean # Clean output" -ForegroundColor White |
| 182 | + Write-Host "" |
| 183 | + Write-Host "Key Directories:" -ForegroundColor Cyan |
| 184 | + Write-Host " source\Classes\ # DSC class-based resources" -ForegroundColor White |
| 185 | + Write-Host " source\Public\ # Public PowerShell commands" -ForegroundColor White |
| 186 | + Write-Host " source\Private\ # Private helper functions" -ForegroundColor White |
| 187 | + Write-Host " tests\Unit\ # Unit tests (Pester v5)" -ForegroundColor White |
| 188 | + Write-Host " tests\Integration\ # Integration tests" -ForegroundColor White |
| 189 | + Write-Host " output\builtModule\ # Built module output" -ForegroundColor White |
| 190 | + Write-Host "" |
| 191 | + Write-Host "Development Guidelines:" -ForegroundColor Cyan |
| 192 | + Write-Host " • Follow DSC Community style guidelines" -ForegroundColor White |
| 193 | + Write-Host " • Use PascalCase for functions, camelCase for variables" -ForegroundColor White |
| 194 | + Write-Host " • Inherit DSC resources from ResourceBase or SqlResourceBase" -ForegroundColor White |
| 195 | + Write-Host " • Include comment-based help for all functions" -ForegroundColor White |
| 196 | + Write-Host " • Add unit tests for all new code" -ForegroundColor White |
| 197 | + Write-Host " • Use localized strings for user messages" -ForegroundColor White |
| 198 | + Write-Host "" |
| 199 | + Write-Host "Ready for development! 🚀" -ForegroundColor Green |
0 commit comments