-
Notifications
You must be signed in to change notification settings - Fork 226
225 lines (188 loc) · 9.65 KB
/
copilot-setup-steps.yml
File metadata and controls
225 lines (188 loc) · 9.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: 'Copilot Setup Steps'
# This workflow sets up a complete development environment for the SqlServerDsc PowerShell DSC module project
# when executed by GitHub Copilot Agent for development assistance.
on:
workflow_dispatch:
# inputs:
# skip_tests:
# description: 'Skip running tests during setup'
# required: false
# default: true
# type: boolean
pull_request:
paths:
- '.github/workflows/copilot-setup-steps.yml'
push:
paths:
- '.github/workflows/copilot-setup-steps.yml'
# cSpell: ignore pwsh cmdlets DSCResources nupkg HQRM SqlServerDsc dotnet gitversion
jobs:
copilot-setup-steps:
name: Setup SqlServerDsc Development Environment
runs-on: ubuntu-latest
# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history needed for GitVersion
- name: Configure PowerShell Environment
shell: pwsh
run: |
Write-Host "Configure PowerShell environment..." -ForegroundColor Green
# Install dependent PowerShell modules
Install-PSResource -Name 'SqlServer' -Version '21.1.18256' -Scope 'CurrentUser' -Repository 'PSGallery' -TrustRepository
Install-PSResource -Name 'PSDSC' -Scope 'CurrentUser' -Repository 'PSGallery' -TrustRepository
Write-Host "PowerShell environment configuration complete." -ForegroundColor Green
- name: Install DSCv3
shell: pwsh
run: |
Write-Host "Install DSCv3 in environment..." -ForegroundColor Green
# Install dependent PowerShell modules
Install-DscExe -IncludePrerelease -Force
Write-Host "DSCv3 install complete." -ForegroundColor Green
- name: Verify DSCv3
shell: pwsh
run: |
Write-Host "Running DSCv3 to validate correct operation..." -ForegroundColor Green
dsc --version
- name: Install .NET Tools
shell: pwsh
run: |
Write-Host "Installing .NET tools..." -ForegroundColor Green
# Install GitVersion for semantic versioning
dotnet tool install --global GitVersion.Tool --version 5.*
# # Verify installation
# dotnet-gitversion
Write-Host ".NET tools installation complete." -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: |
Write-Host "Building SqlServerDsc module..." -ForegroundColor Green
# Hard-code versin due to how Coilot is switching branch (?) so gitversion fails.
$ModuleVersion = '0.0.1'
$env:ModuleVersion = '0.0.1'
[System.Environment]::SetEnvironmentVariable('ModuleVersion','0.0.1', 'Machine')
# Build the module
.\build.ps1 -Tasks 'build' -ErrorAction Stop
# Verify build output
if (Test-Path -Path "output\builtModule\SqlServerDsc") {
Write-Host "Module built successfully at: output\builtModule\SqlServerDsc" -ForegroundColor Green
Get-ChildItem -Path "output\builtModule\SqlServerDsc" -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: |
Write-Host "Importing built SqlServerDsc module..." -ForegroundColor Green
.\build.ps1 -Tasks 'noop'
Import-Module -Name 'SqlServerDsc' -Force
# Verify module is loaded
$module = Get-Module -Name SqlServerDsc
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 and resources
$commands = Get-Command -Module SqlServerDsc
Write-Host " Exported Commands: $($commands.Count)" -ForegroundColor Cyan
$dscResources = @(dsc resource list --adapter Microsoft.DSC/PowerShell --output-format json | ConvertFrom-Json)
Write-Host " Available class-based DSC Resources: $($dscResources.Count)" -ForegroundColor Cyan
} else {
Write-Error "Failed to import module"
exit 1
}
# - name: Run QA & Unit Tests (Optional)
# if: ${{ inputs.skip_tests == false }}
# shell: powershell
# run: |
# Write-Host "Running QA & unit tests..." -ForegroundColor Green
# # Run QA & unit tests only (skip integration tests in setup)
# .\build.ps1 -Tasks 'test' -PesterPath 'tests\Unit', 'tests\QA'
# Write-Host "QA & unit tests completed." -ForegroundColor Green
# - name: Validate Project Structure
# shell: pwsh
# run: |
# Write-Host "Validating project structure..." -ForegroundColor Green
# $requiredPaths = @(
# 'source\Classes',
# 'source\Public',
# 'source\Private',
# 'source\DSCResources',
# 'source\en-US',
# 'tests\Unit',
# 'tests\Integration',
# 'build.ps1',
# 'build.yaml',
# 'RequiredModules.psd1'
# )
# $missingPaths = @()
# foreach ($path in $requiredPaths) {
# if (-not (Test-Path -Path $path)) {
# $missingPaths += $path
# } else {
# Write-Host "✓ $path" -ForegroundColor Green
# }
# }
# if ($missingPaths.Count -gt 0) {
# Write-Warning "Missing expected project paths:"
# $missingPaths | ForEach-Object { Write-Host " ✗ $_" -ForegroundColor Red }
# } else {
# Write-Host "All expected project paths found." -ForegroundColor Green
# }
- name: Setup Complete - Display Environment Info
shell: pwsh
run: |
Write-Host ""
Write-Host "=========================================" -ForegroundColor Green
Write-Host "SqlServerDsc Development Environment Ready!" -ForegroundColor Green
Write-Host "=========================================" -ForegroundColor Green
Write-Host ""
Write-Host "Project Information:" -ForegroundColor Cyan
Write-Host " Repository: SqlServerDsc PowerShell DSC Module" -ForegroundColor White
Write-Host " Type: Class-based DSC resources for SQL Server" -ForegroundColor White
Write-Host " Framework: Sampler + ModuleBuilder" -ForegroundColor White
Write-Host " Testing: Pester v5 framework" -ForegroundColor White
Write-Host ""
Write-Host "Available Build Commands:" -ForegroundColor Cyan
Write-Host " .\build.ps1 -Tasks build # Build module" -ForegroundColor White
Write-Host " .\build.ps1 -Tasks test # Run all tests" -ForegroundColor White
Write-Host " .\build.ps1 -Tasks docs # Generate documentation" -ForegroundColor White
Write-Host " .\build.ps1 -Tasks clean # Clean output" -ForegroundColor White
Write-Host ""
Write-Host "Key Directories:" -ForegroundColor Cyan
Write-Host " source\Classes\ # DSC class-based resources" -ForegroundColor White
Write-Host " source\Public\ # Public PowerShell commands" -ForegroundColor White
Write-Host " source\Private\ # Private helper functions" -ForegroundColor White
Write-Host " tests\Unit\ # Unit tests (Pester v5)" -ForegroundColor White
Write-Host " tests\Integration\ # Integration tests" -ForegroundColor White
Write-Host " output\builtModule\ # Built module output" -ForegroundColor White
Write-Host ""
Write-Host "Development Guidelines:" -ForegroundColor Cyan
Write-Host " • Follow DSC Community style guidelines" -ForegroundColor White
Write-Host " • Use PascalCase for functions, camelCase for variables" -ForegroundColor White
Write-Host " • Inherit DSC resources from ResourceBase or SqlResourceBase" -ForegroundColor White
Write-Host " • Include comment-based help for all functions" -ForegroundColor White
Write-Host " • Add unit tests for all new code" -ForegroundColor White
Write-Host " • Use localized strings for user messages" -ForegroundColor White
Write-Host ""
Write-Host "Ready for development! 🚀" -ForegroundColor Green