From 79f75dc23456bf2e57393a20db8cedc384bd17ea Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 19 Aug 2025 21:03:16 +0200 Subject: [PATCH 01/28] Refactor Copilot setup workflow for improved clarity and functionality --- .github/workflows/copilot-setup-steps.yml | 209 +++++++++------------- CHANGELOG.md | 4 + 2 files changed, 85 insertions(+), 128 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 7a115fc222..67b48926b4 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -1,16 +1,12 @@ name: 'Copilot Setup Steps' +env: + MODULE_NAME: 'SqlServerDsc' -# This workflow sets up a complete development environment for the SqlServerDsc PowerShell DSC module project +# 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: - # inputs: - # skip_tests: - # description: 'Skip running tests during setup' - # required: false - # default: true - # type: boolean pull_request: paths: - '.github/workflows/copilot-setup-steps.yml' @@ -18,16 +14,13 @@ on: paths: - '.github/workflows/copilot-setup-steps.yml' -# cSpell: ignore pwsh cmdlets DSCResources nupkg HQRM SqlServerDsc dotnet gitversion +# cSpell: ignore unshallow LASTEXITCODE PSDSC jobs: copilot-setup-steps: - name: Setup SqlServerDsc Development Environment + name: Setup PowerShell 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: @@ -36,16 +29,39 @@ jobs: with: fetch-depth: 0 # Full history needed for GitVersion - - name: Unshallow repository for GitVersion - if: startsWith(github.ref, 'refs/heads/copilot/') + # 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 "Unshallow Copilot branch..." -ForegroundColor Green + Write-Host 'Ensuring full history for GitVersion...' -ForegroundColor Green - Write-Host "Removing the depth limit, prune unused refs, and grab tags" -ForegroundColor DarkGray - git fetch --prune --unshallow --tags --no-recurse-submodules + $isShallow = (& git rev-parse --is-shallow-repository) -eq 'true' - Write-Host "Unshallow complete." -ForegroundColor Green + 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: Configure PowerShell Environment shell: pwsh @@ -77,155 +93,92 @@ jobs: - name: Install .NET Tools shell: pwsh run: | - Write-Host "Installing .NET tools..." -ForegroundColor Green + Write-Host 'Installing/Updating .NET tools...' -ForegroundColor Green - # Install GitVersion for semantic versioning - dotnet tool install --global GitVersion.Tool --version 5.* + # 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 + dotnet-gitversion /version - Write-Host ".NET tools installation complete." -ForegroundColor Green + Write-Host '.NET tools ready.' -ForegroundColor Green - name: Verify GitVersion shell: pwsh run: | - Write-Host "Running GitVersion to determine semantic version..." -ForegroundColor Green + 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 + Write-Host 'Resolving project dependencies...' -ForegroundColor Green # Run dependency resolution - .\build.ps1 -ResolveDependency -Tasks 'noop' -ErrorAction Stop + ./build.ps1 -ResolveDependency -Tasks 'noop' -ErrorAction Stop - Write-Host "Dependencies resolved successfully." -ForegroundColor Green + Write-Host 'Dependencies resolved successfully.' -ForegroundColor Green - name: Build Module shell: pwsh run: | - Write-Host "Building SqlServerDsc module..." -ForegroundColor Green + Write-Host "Building $env:MODULE_NAME module..." -ForegroundColor Green # Build the module - .\build.ps1 -Tasks 'build' -ErrorAction Stop + ./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" + if (Test-Path -Path "output\builtModule\$env:MODULE_NAME") + { + Write-Host "Module built successfully at: output\builtModule\$env:MODULE_NAME" -ForegroundColor Green + Get-ChildItem -Path "output\builtModule\$env:MODULE_NAME" -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 + Write-Host "Importing built $env:MODULE_NAME module..." -ForegroundColor Green - .\build.ps1 -Tasks 'noop' - Import-Module -Name 'SqlServerDsc' -Force + ./build.ps1 -Tasks 'noop' + Import-Module -Name $env:MODULE_NAME -Force # Verify module is loaded - $module = Get-Module -Name SqlServerDsc - if ($module) { - Write-Host "Module imported successfully:" -ForegroundColor Green + $module = Get-Module -Name $env:MODULE_NAME -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 and resources - $commands = Get-Command -Module SqlServerDsc - Write-Host " Exported Commands: $($commands.Count)" -ForegroundColor Cyan + # Show available commands + $commands = Get-Command -Module $env:MODULE_NAME + 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 + } $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 } + else + { + Write-Error 'Failed to import module' - # - 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 + exit 1 + } diff --git a/CHANGELOG.md b/CHANGELOG.md index c61dafd5c5..54110daa32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Module now outputs a verbose message instead of a warning when the SMO dependency module is missing during import to work around a DSC v3 issue. - VS Code tasks configuration was improved to support AI. +- `.github/workflows/copilot-setup-steps.yml` + - Ensure full Git history/tags for GitVersion with a robust shallow check. + - Generalize workflow via `MODULE_NAME` env var and Linux‑friendly paths. + - Make .NET tool install idempotent and tighten module import verification. - `Prerequisites` tests - Added creation of `SqlIntegrationTest` local Windows user for integration testing. - `tests/Integration/Commands/README.md` From 466ec717651b9e4bc06ac79521074f63f71db5ac Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 19 Aug 2025 21:05:19 +0200 Subject: [PATCH 02/28] Update GitHub Copilot setup workflow for improved generalization and idempotency --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54110daa32..aecf6be510 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,7 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Module now outputs a verbose message instead of a warning when the SMO dependency module is missing during import to work around a DSC v3 issue. - VS Code tasks configuration was improved to support AI. -- `.github/workflows/copilot-setup-steps.yml` +- `.github/workflows/copilot-setup-steps.yml` (fixes [issue #2127](https://github.com/dsccommunity/SqlServerDsc/issues/2127)) - Ensure full Git history/tags for GitVersion with a robust shallow check. - Generalize workflow via `MODULE_NAME` env var and Linux‑friendly paths. - Make .NET tool install idempotent and tighten module import verification. From 2228574022b1b76823099c55a1b5c57d09bbf653 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 19 Aug 2025 21:09:01 +0200 Subject: [PATCH 03/28] debug 1 --- .github/workflows/copilot-setup-steps.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 67b48926b4..4cb900fa31 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -53,7 +53,8 @@ jobs: { Write-Host 'Repository is not shallow. Refreshing tags...' -ForegroundColor DarkGray - git fetch --prune --tags --no-recurse-submodules + #git fetch --prune --tags --no-recurse-submodules + git fetch --prune --unshallow --tags --no-recurse-submodules if ($LASTEXITCODE -ne 0) { From 0616bdbe7b0695d1133ee110e5fd50e222580cf8 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 19 Aug 2025 21:10:34 +0200 Subject: [PATCH 04/28] debug 2 --- .github/workflows/copilot-setup-steps.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 4cb900fa31..67b48926b4 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -53,8 +53,7 @@ jobs: { Write-Host 'Repository is not shallow. Refreshing tags...' -ForegroundColor DarkGray - #git fetch --prune --tags --no-recurse-submodules - git fetch --prune --unshallow --tags --no-recurse-submodules + git fetch --prune --tags --no-recurse-submodules if ($LASTEXITCODE -ne 0) { From 26a5516c9ab2077e2aafdc95a8829f65d7df6b6b Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 19 Aug 2025 21:12:14 +0200 Subject: [PATCH 05/28] dbug 3 --- .github/workflows/copilot-setup-steps.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 67b48926b4..49b150d95a 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -108,6 +108,7 @@ jobs: shell: pwsh run: | Write-Host 'Running GitVersion to determine semantic version...' -ForegroundColor Green + dotnet-gitversion dotnet-gitversion | ConvertFrom-Json - name: Resolve Dependencies From 6695c88a5c6758364559e6b8d582be439e18ebc0 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 19 Aug 2025 21:14:18 +0200 Subject: [PATCH 06/28] Enhance GitVersion step to include parsing output to PowerShell object --- .github/workflows/copilot-setup-steps.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 49b150d95a..a4adb3514f 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -109,6 +109,7 @@ jobs: run: | Write-Host 'Running GitVersion to determine semantic version...' -ForegroundColor Green dotnet-gitversion + Write-Host 'Running GitVersion to determine semantic version (parsing to PowerShell object)...' -ForegroundColor Green dotnet-gitversion | ConvertFrom-Json - name: Resolve Dependencies From 7cf9180db2e763317816d48958a8531b59fb0fd0 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 19 Aug 2025 21:16:42 +0200 Subject: [PATCH 07/28] Add output of available class-based DSC resources to the setup workflow --- .github/workflows/copilot-setup-steps.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index a4adb3514f..bd33e12915 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -177,6 +177,7 @@ jobs: $dscResources = @(dsc resource list --adapter Microsoft.DSC/PowerShell --output-format json | ConvertFrom-Json) Write-Host " Available class-based DSC Resources: $($dscResources.Count)" -ForegroundColor Cyan + $dscResources } else { From 689ef9b7f2d12a6184a12795efb4df2391ef6c28 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 19 Aug 2025 21:18:27 +0200 Subject: [PATCH 08/28] Update dependency resolution step to use fast module option --- .github/workflows/copilot-setup-steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index bd33e12915..967d35bb7a 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -118,7 +118,7 @@ jobs: Write-Host 'Resolving project dependencies...' -ForegroundColor Green # Run dependency resolution - ./build.ps1 -ResolveDependency -Tasks 'noop' -ErrorAction Stop + ./build.ps1 -ResolveDependency -Tasks 'noop' -UseModuleFast -ErrorAction Stop Write-Host 'Dependencies resolved successfully.' -ForegroundColor Green From db05f5d4fd7e10911432ecc16dfc91546d82c6da Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 19 Aug 2025 21:25:57 +0200 Subject: [PATCH 09/28] debug 10 --- .github/workflows/copilot-setup-steps.yml | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 967d35bb7a..7bcb1d6aab 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -63,6 +63,22 @@ jobs: Write-Host 'History ready for GitVersion.' -ForegroundColor Green + - name: Install Linux Dependencies + shell: bash + run: | + echo "Installing Linux dependencies for PowerShell DSC..." + + # Update package list + sudo apt-get update + + # Install OMI (Open Management Infrastructure) which provides libmi + sudo apt-get install -y omi + + # Also install other dependencies that might be needed + sudo apt-get install -y libc6-dev libssl-dev + + echo "Linux dependencies installed successfully." + - name: Configure PowerShell Environment shell: pwsh run: | @@ -76,6 +92,9 @@ jobs: - name: Install DSCv3 shell: pwsh + env: + # Ensure OMI libraries can be found + LD_LIBRARY_PATH: /opt/omi/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH run: | Write-Host "Install DSCv3 in environment..." -ForegroundColor Green @@ -86,6 +105,9 @@ jobs: - name: Verify DSCv3 shell: pwsh + env: + # Ensure OMI libraries can be found + LD_LIBRARY_PATH: /opt/omi/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH run: | Write-Host "Running DSCv3 to validate correct operation..." -ForegroundColor Green dsc --version @@ -124,6 +146,9 @@ jobs: - name: Build Module shell: pwsh + env: + # Ensure OMI libraries can be found + LD_LIBRARY_PATH: /opt/omi/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH run: | Write-Host "Building $env:MODULE_NAME module..." -ForegroundColor Green @@ -144,6 +169,9 @@ jobs: - name: Import Built Module shell: pwsh + env: + # Ensure OMI libraries can be found + LD_LIBRARY_PATH: /opt/omi/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH run: | Write-Host "Importing built $env:MODULE_NAME module..." -ForegroundColor Green From ba63b22eb20cac49cacafc3a5d6a40d2c285e5df Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 10:07:15 +0200 Subject: [PATCH 10/28] Set LD_LIBRARY_PATH permanently for the runner session and remove redundant environment variable settings in DSCv3 steps --- .github/workflows/copilot-setup-steps.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 7bcb1d6aab..01c0d09427 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -77,6 +77,9 @@ jobs: # Also install other dependencies that might be needed sudo apt-get install -y libc6-dev libssl-dev + # Set LD_LIBRARY_PATH permanently for the runner session + echo "LD_LIBRARY_PATH=/opt/omi/lib:/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV + echo "Linux dependencies installed successfully." - name: Configure PowerShell Environment @@ -92,9 +95,6 @@ jobs: - name: Install DSCv3 shell: pwsh - env: - # Ensure OMI libraries can be found - LD_LIBRARY_PATH: /opt/omi/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH run: | Write-Host "Install DSCv3 in environment..." -ForegroundColor Green @@ -105,9 +105,6 @@ jobs: - name: Verify DSCv3 shell: pwsh - env: - # Ensure OMI libraries can be found - LD_LIBRARY_PATH: /opt/omi/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH run: | Write-Host "Running DSCv3 to validate correct operation..." -ForegroundColor Green dsc --version @@ -146,9 +143,6 @@ jobs: - name: Build Module shell: pwsh - env: - # Ensure OMI libraries can be found - LD_LIBRARY_PATH: /opt/omi/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH run: | Write-Host "Building $env:MODULE_NAME module..." -ForegroundColor Green @@ -169,9 +163,6 @@ jobs: - name: Import Built Module shell: pwsh - env: - # Ensure OMI libraries can be found - LD_LIBRARY_PATH: /opt/omi/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH run: | Write-Host "Importing built $env:MODULE_NAME module..." -ForegroundColor Green From 59f02eca25f38d6d8fe6f4c8fc931546e9607aa9 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 10:07:21 +0200 Subject: [PATCH 11/28] Add additional terms to cSpell dictionary for improved spell checking --- .vscode/settings.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 1e6fedf669..0913d396f7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -89,7 +89,9 @@ "wsfc", "SOURCEBRANCH", "SOURCEBRANCHNAME", - "setvariable" + "setvariable", + "libmi", + "libc" ], "cSpell.ignorePaths": [ ".git" From f22f54af0240dbb270e6e7ca017ea9d4012373eb Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 10:09:24 +0200 Subject: [PATCH 12/28] Fix path separator in built module verification step for cross-platform compatibility --- .github/workflows/copilot-setup-steps.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 01c0d09427..225a52f7bb 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -150,10 +150,10 @@ jobs: ./build.ps1 -Tasks 'build' -ErrorAction Stop # Verify build output - if (Test-Path -Path "output\builtModule\$env:MODULE_NAME") + if (Test-Path -Path "output/builtModule/$env:MODULE_NAME") { - Write-Host "Module built successfully at: output\builtModule\$env:MODULE_NAME" -ForegroundColor Green - Get-ChildItem -Path "output\builtModule\$env:MODULE_NAME" -Recurse | Select-Object Name, Length | Format-Table + Write-Host "Module built successfully at: output/builtModule/$env:MODULE_NAME" -ForegroundColor Green + Get-ChildItem -Path "output/builtModule/$env:MODULE_NAME" -Recurse | Select-Object Name, Length | Format-Table } else { From e4de7241f87b08b6df9a77070df4ca12e17b3f1a Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 10:14:06 +0200 Subject: [PATCH 13/28] Wrap Get-Command output in an array for consistent handling of exported commands --- .github/workflows/copilot-setup-steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 225a52f7bb..11f2a8dd4b 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -180,7 +180,7 @@ jobs: Write-Host " Path: $($module.Path)" -ForegroundColor Cyan # Show available commands - $commands = Get-Command -Module $env:MODULE_NAME + $commands = @(Get-Command -Module $env:MODULE_NAME) if ($commands.Count -gt 0) { Write-Host " Exported Commands: $($commands.Count)" -ForegroundColor Cyan From 9ea87d91bb0e35bdaf5609a58e99e3b2363587f1 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 10:17:50 +0200 Subject: [PATCH 14/28] Refactor GitHub Copilot setup workflow for improved script handling and robustness --- CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aecf6be510..eb6430d9ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Switch the workflow to use Linux. - Attempt to unshallow the Copilot branch - Improved AI instructions. + - Refactor to use improved script ([issue #2127](https://github.com/dsccommunity/SqlServerDsc/issues/2127)). - `Assert-SqlDscLogin` - Added new public command to validate that a specified SQL Server principal exists as a login, throwing a terminating error if it doesn't exist. @@ -53,10 +54,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Module now outputs a verbose message instead of a warning when the SMO dependency module is missing during import to work around a DSC v3 issue. - VS Code tasks configuration was improved to support AI. -- `.github/workflows/copilot-setup-steps.yml` (fixes [issue #2127](https://github.com/dsccommunity/SqlServerDsc/issues/2127)) - - Ensure full Git history/tags for GitVersion with a robust shallow check. - - Generalize workflow via `MODULE_NAME` env var and Linux‑friendly paths. - - Make .NET tool install idempotent and tighten module import verification. - `Prerequisites` tests - Added creation of `SqlIntegrationTest` local Windows user for integration testing. - `tests/Integration/Commands/README.md` From 158b9065d9b833bcf1fa5e207d6e4d150a347425 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 10:21:23 +0200 Subject: [PATCH 15/28] Add check for Microsoft repository before installation of OMI --- .github/workflows/copilot-setup-steps.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 11f2a8dd4b..310f05823b 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -71,6 +71,19 @@ jobs: # Update package list sudo apt-get update + # Check if Microsoft repository is already added, if not add it + if ! grep -q "packages.microsoft.com" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then + echo "Adding Microsoft repository..." + # Add Microsoft's GPG key and repository + wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - + sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -cs)-prod $(lsb_release -cs) main" + + # Update package list again after adding the new repo + sudo apt-get update + else + echo "Microsoft repository already configured, skipping..." + fi + # Install OMI (Open Management Infrastructure) which provides libmi sudo apt-get install -y omi From 3129233fa0d2eedc39f4d398b47350c7d251e9a7 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 11:42:30 +0200 Subject: [PATCH 16/28] Enhance OMI installation step with Microsoft repository check and improved error handling --- .github/workflows/copilot-setup-steps.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 310f05823b..9eaff3fd8a 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -74,9 +74,12 @@ jobs: # Check if Microsoft repository is already added, if not add it if ! grep -q "packages.microsoft.com" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then echo "Adding Microsoft repository..." - # Add Microsoft's GPG key and repository - wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - - sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -cs)-prod $(lsb_release -cs) main" + # Add Microsoft's GPG key and repository (keyring) + sudo install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg >/dev/null + sudo chmod a+r /etc/apt/keyrings/microsoft.gpg + DISTRO_CODENAME="$(lsb_release -cs)" + echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/microsoft-ubuntu-${DISTRO_CODENAME}-prod ${DISTRO_CODENAME} main" | sudo tee "/etc/apt/sources.list.d/microsoft-${DISTRO_CODENAME}-prod.list" >/dev/null # Update package list again after adding the new repo sudo apt-get update @@ -85,13 +88,19 @@ jobs: fi # Install OMI (Open Management Infrastructure) which provides libmi - sudo apt-get install -y omi + if apt-cache policy omi 2>/dev/null | grep -q 'Candidate:'; then + if ! sudo apt-get install -y omi; then + echo "WARNING: 'omi' package failed to install; continuing." + fi + else + echo "Package 'omi' not found in repositories; skipping OMI install." + fi # Also install other dependencies that might be needed sudo apt-get install -y libc6-dev libssl-dev # Set LD_LIBRARY_PATH permanently for the runner session - echo "LD_LIBRARY_PATH=/opt/omi/lib:/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=/opt/omi/lib:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}" >> $GITHUB_ENV echo "Linux dependencies installed successfully." From 0b47c1eacd9a4a38044465c943948b232db6632d Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 11:42:36 +0200 Subject: [PATCH 17/28] Refactor GitHub Copilot workflow setup for module-agnostic configuration and improved dependency handling --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb6430d9ae..d7cc0a5043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Switch the workflow to use Linux. - Attempt to unshallow the Copilot branch - Improved AI instructions. - - Refactor to use improved script ([issue #2127](https://github.com/dsccommunity/SqlServerDsc/issues/2127)). - `Assert-SqlDscLogin` - Added new public command to validate that a specified SQL Server principal exists as a login, throwing a terminating error if it doesn't exist. @@ -51,6 +50,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Refactored GitHub Copilot workflow setup to be module-agnostic via MODULE_NAME + environment variable, includes full-history detection, uses idempotent .NET + tool install, and adds Linux dependency handling ([issue #2127](https://github.com/dsccommunity/SqlServerDsc/issues/2127)). - Module now outputs a verbose message instead of a warning when the SMO dependency module is missing during import to work around a DSC v3 issue. - VS Code tasks configuration was improved to support AI. From ff0ecaf43b141eb0268e2b51d8ea18ce2927668f Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 11:52:10 +0200 Subject: [PATCH 18/28] Enhance Linux dependency installation by adding quiet mode to apt-get commands and checking for Microsoft repository before installation --- .github/workflows/copilot-setup-steps.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 9eaff3fd8a..1ecd5d981a 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -69,7 +69,7 @@ jobs: echo "Installing Linux dependencies for PowerShell DSC..." # Update package list - sudo apt-get update + sudo apt-get update -qq # Check if Microsoft repository is already added, if not add it if ! grep -q "packages.microsoft.com" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then @@ -82,14 +82,14 @@ jobs: echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/microsoft-ubuntu-${DISTRO_CODENAME}-prod ${DISTRO_CODENAME} main" | sudo tee "/etc/apt/sources.list.d/microsoft-${DISTRO_CODENAME}-prod.list" >/dev/null # Update package list again after adding the new repo - sudo apt-get update + sudo apt-get update -qq else echo "Microsoft repository already configured, skipping..." fi # Install OMI (Open Management Infrastructure) which provides libmi if apt-cache policy omi 2>/dev/null | grep -q 'Candidate:'; then - if ! sudo apt-get install -y omi; then + if ! sudo apt-get install -y -qq omi; then echo "WARNING: 'omi' package failed to install; continuing." fi else @@ -97,7 +97,7 @@ jobs: fi # Also install other dependencies that might be needed - sudo apt-get install -y libc6-dev libssl-dev + sudo apt-get install -y -qq libc6-dev libssl-dev # Set LD_LIBRARY_PATH permanently for the runner session echo "LD_LIBRARY_PATH=/opt/omi/lib:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}" >> $GITHUB_ENV From 12ac228b91bca6205aa5b7f5e975db91c873d702 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 12:04:55 +0200 Subject: [PATCH 19/28] Enhance Linux dependency installation with improved logging, Microsoft repository check, and error handling --- .github/workflows/copilot-setup-steps.yml | 54 +++++++++++++++++------ 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 1ecd5d981a..c9ac1984ba 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -66,14 +66,19 @@ jobs: - name: Install Linux Dependencies shell: bash run: | - echo "Installing Linux dependencies for PowerShell DSC..." + echo -e "\033[32mInstalling Linux dependencies for PowerShell DSC...\033[0m" # Update package list - sudo apt-get update -qq + echo "::group::Update package list" + echo -e "\033[36mUpdating package list...\033[0m" + sudo apt-get update + echo -e "\033[32m✓ Package list updated successfully\033[0m" + echo "::endgroup::" # Check if Microsoft repository is already added, if not add it if ! grep -q "packages.microsoft.com" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then - echo "Adding Microsoft repository..." + echo "::group::Add Microsoft repository" + echo -e "\033[33mAdding Microsoft repository...\033[0m" # Add Microsoft's GPG key and repository (keyring) sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg >/dev/null @@ -82,27 +87,43 @@ jobs: echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/microsoft-ubuntu-${DISTRO_CODENAME}-prod ${DISTRO_CODENAME} main" | sudo tee "/etc/apt/sources.list.d/microsoft-${DISTRO_CODENAME}-prod.list" >/dev/null # Update package list again after adding the new repo - sudo apt-get update -qq + echo -e "\033[36mUpdating package list after adding Microsoft repository...\033[0m" + sudo apt-get update + echo -e "\033[32m✓ Microsoft repository added successfully\033[0m" + echo "::endgroup::" else - echo "Microsoft repository already configured, skipping..." + echo -e "\033[33mMicrosoft repository already configured, skipping...\033[0m" + echo "::notice::Microsoft repository was already configured" fi # Install OMI (Open Management Infrastructure) which provides libmi + echo "::group::Install OMI and dependencies" if apt-cache policy omi 2>/dev/null | grep -q 'Candidate:'; then - if ! sudo apt-get install -y -qq omi; then - echo "WARNING: 'omi' package failed to install; continuing." + echo -e "\033[36mInstalling OMI package...\033[0m" + if ! sudo apt-get install -y omi; then + echo -e "\033[31m⚠ OMI package failed to install; continuing...\033[0m" + echo "::warning::OMI package failed to install; continuing without OMI" + else + echo -e "\033[32m✓ OMI package installed successfully\033[0m" fi else - echo "Package 'omi' not found in repositories; skipping OMI install." + echo -e "\033[33mPackage 'omi' not found in repositories; skipping OMI install.\033[0m" + echo "::notice::OMI package not found in repositories, skipping installation" fi + echo "::endgroup::" - # Also install other dependencies that might be needed - sudo apt-get install -y -qq libc6-dev libssl-dev + echo "::group::Installing additional development dependencies..." + echo -e "\033[36mInstalling development dependencies (libc6-dev, libssl-dev)...\033[0m" + sudo apt-get install -y libc6-dev libssl-dev + echo -e "\033[32m✓ Development dependencies installed successfully\033[0m" + echo "::endgroup::" # Set LD_LIBRARY_PATH permanently for the runner session + echo -e "\033[36mSetting LD_LIBRARY_PATH environment variable...\033[0m" echo "LD_LIBRARY_PATH=/opt/omi/lib:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}" >> $GITHUB_ENV + echo -e "\033[32m✓ Environment variable set successfully\033[0m" - echo "Linux dependencies installed successfully." + echo -e "\033[32m🎉 Linux dependencies installed successfully!\033[0m" - name: Configure PowerShell Environment shell: pwsh @@ -110,10 +131,15 @@ jobs: Write-Host "Configure PowerShell environment..." -ForegroundColor Green # Install dependent PowerShell modules + Write-Host "Installing SqlServer module..." -ForegroundColor Cyan Install-PSResource -Name 'SqlServer' -Version '21.1.18256' -Scope 'CurrentUser' -Repository 'PSGallery' -TrustRepository + Write-Host "✓ SqlServer module installed successfully" -ForegroundColor Green + + Write-Host "Installing PSDSC module..." -ForegroundColor Cyan Install-PSResource -Name 'PSDSC' -Scope 'CurrentUser' -Repository 'PSGallery' -TrustRepository + Write-Host "✓ PSDSC module installed successfully" -ForegroundColor Green - Write-Host "PowerShell environment configuration complete." -ForegroundColor Green + Write-Host "🎉 PowerShell environment configuration complete!" -ForegroundColor Green - name: Install DSCv3 shell: pwsh @@ -121,9 +147,11 @@ jobs: Write-Host "Install DSCv3 in environment..." -ForegroundColor Green # Install dependent PowerShell modules + Write-Host "Installing DSCv3 executable..." -ForegroundColor Cyan Install-DscExe -IncludePrerelease -Force + Write-Host "✓ DSCv3 installed successfully" -ForegroundColor Green - Write-Host "DSCv3 install complete." -ForegroundColor Green + Write-Host "🎉 DSCv3 install complete!" -ForegroundColor Green - name: Verify DSCv3 shell: pwsh From 2e633fc587fd31506f9ee7380ff13830d226a80f Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 12:05:00 +0200 Subject: [PATCH 20/28] Add additional words to cSpell dictionary for improved spell checking --- .vscode/settings.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 0913d396f7..90ac866b91 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -91,7 +91,11 @@ "SOURCEBRANCHNAME", "setvariable", "libmi", - "libc" + "libc", + "endgroup", + "keyrings", + "distro", + "dearmor" ], "cSpell.ignorePaths": [ ".git" From c0d88187e1e202220b9868006b33d99838f1b244 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 12:12:59 +0200 Subject: [PATCH 21/28] Refactor logging in Copilot setup steps for improved readability and consistency --- .github/workflows/copilot-setup-steps.yml | 99 +++++++++++------------ 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index c9ac1984ba..251f04dd86 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -34,13 +34,13 @@ jobs: - name: Ensure full history for GitVersion shell: pwsh run: | - Write-Host 'Ensuring full history for GitVersion...' -ForegroundColor Green + Write-Host 'Ensuring full history for GitVersion...' $isShallow = (& git rev-parse --is-shallow-repository) -eq 'true' if ($isShallow) { - Write-Host 'Repository is shallow. Fetching full history and tags...' -ForegroundColor DarkGray + Write-Host 'Repository is shallow. Fetching full history and tags...' git fetch --prune --unshallow --tags --no-recurse-submodules @@ -51,7 +51,7 @@ jobs: } else { - Write-Host 'Repository is not shallow. Refreshing tags...' -ForegroundColor DarkGray + Write-Host 'Repository is not shallow. Refreshing tags...' git fetch --prune --tags --no-recurse-submodules @@ -61,24 +61,24 @@ jobs: } } - Write-Host 'History ready for GitVersion.' -ForegroundColor Green + Write-Host 'History ready for GitVersion.' - name: Install Linux Dependencies shell: bash run: | - echo -e "\033[32mInstalling Linux dependencies for PowerShell DSC...\033[0m" + echo "Installing Linux dependencies for PowerShell DSC..." # Update package list echo "::group::Update package list" - echo -e "\033[36mUpdating package list...\033[0m" + echo "Updating package list..." sudo apt-get update - echo -e "\033[32m✓ Package list updated successfully\033[0m" + echo "Package list updated successfully" echo "::endgroup::" # Check if Microsoft repository is already added, if not add it if ! grep -q "packages.microsoft.com" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then echo "::group::Add Microsoft repository" - echo -e "\033[33mAdding Microsoft repository...\033[0m" + echo "Adding Microsoft repository..." # Add Microsoft's GPG key and repository (keyring) sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg >/dev/null @@ -87,82 +87,81 @@ jobs: echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/microsoft-ubuntu-${DISTRO_CODENAME}-prod ${DISTRO_CODENAME} main" | sudo tee "/etc/apt/sources.list.d/microsoft-${DISTRO_CODENAME}-prod.list" >/dev/null # Update package list again after adding the new repo - echo -e "\033[36mUpdating package list after adding Microsoft repository...\033[0m" + echo "Updating package list after adding Microsoft repository..." sudo apt-get update - echo -e "\033[32m✓ Microsoft repository added successfully\033[0m" + echo "Microsoft repository added successfully" echo "::endgroup::" else - echo -e "\033[33mMicrosoft repository already configured, skipping...\033[0m" - echo "::notice::Microsoft repository was already configured" + echo "Microsoft repository already configured, skipping..." fi # Install OMI (Open Management Infrastructure) which provides libmi echo "::group::Install OMI and dependencies" if apt-cache policy omi 2>/dev/null | grep -q 'Candidate:'; then - echo -e "\033[36mInstalling OMI package...\033[0m" + echo "Installing OMI package..." if ! sudo apt-get install -y omi; then - echo -e "\033[31m⚠ OMI package failed to install; continuing...\033[0m" + echo "OMI package failed to install; continuing..." echo "::warning::OMI package failed to install; continuing without OMI" else - echo -e "\033[32m✓ OMI package installed successfully\033[0m" + echo "OMI package installed successfully" fi else - echo -e "\033[33mPackage 'omi' not found in repositories; skipping OMI install.\033[0m" - echo "::notice::OMI package not found in repositories, skipping installation" + echo "Package 'omi' not found in repositories; skipping OMI install." + echo "::warning::OMI package not found in repositories, skipping installation" fi echo "::endgroup::" echo "::group::Installing additional development dependencies..." - echo -e "\033[36mInstalling development dependencies (libc6-dev, libssl-dev)...\033[0m" + echo "Installing development dependencies (libc6-dev, libssl-dev)..." sudo apt-get install -y libc6-dev libssl-dev - echo -e "\033[32m✓ Development dependencies installed successfully\033[0m" + echo "Development dependencies installed successfully" echo "::endgroup::" # Set LD_LIBRARY_PATH permanently for the runner session - echo -e "\033[36mSetting LD_LIBRARY_PATH environment variable...\033[0m" + echo "Setting LD_LIBRARY_PATH environment variable..." echo "LD_LIBRARY_PATH=/opt/omi/lib:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}" >> $GITHUB_ENV - echo -e "\033[32m✓ Environment variable set successfully\033[0m" + echo "Environment variable set successfully" - echo -e "\033[32m🎉 Linux dependencies installed successfully!\033[0m" + echo "Linux dependencies installed successfully" - name: Configure PowerShell Environment shell: pwsh run: | - Write-Host "Configure PowerShell environment..." -ForegroundColor Green + Write-Host "Configure PowerShell environment..." # Install dependent PowerShell modules - Write-Host "Installing SqlServer module..." -ForegroundColor Cyan + Write-Host "Installing SqlServer module..." Install-PSResource -Name 'SqlServer' -Version '21.1.18256' -Scope 'CurrentUser' -Repository 'PSGallery' -TrustRepository - Write-Host "✓ SqlServer module installed successfully" -ForegroundColor Green + Write-Host "SqlServer module installed successfully" - Write-Host "Installing PSDSC module..." -ForegroundColor Cyan + Write-Host "Installing PSDSC module..." Install-PSResource -Name 'PSDSC' -Scope 'CurrentUser' -Repository 'PSGallery' -TrustRepository - Write-Host "✓ PSDSC module installed successfully" -ForegroundColor Green + Write-Host "PSDSC module installed successfully" - Write-Host "🎉 PowerShell environment configuration complete!" -ForegroundColor Green + Write-Host "PowerShell environment configuration complete" - name: Install DSCv3 shell: pwsh run: | - Write-Host "Install DSCv3 in environment..." -ForegroundColor Green + Write-Host "Install DSCv3 in environment..." # Install dependent PowerShell modules - Write-Host "Installing DSCv3 executable..." -ForegroundColor Cyan + Write-Host "Installing DSCv3 executable..." Install-DscExe -IncludePrerelease -Force - Write-Host "✓ DSCv3 installed successfully" -ForegroundColor Green + Write-Host "DSCv3 installed successfully" - Write-Host "🎉 DSCv3 install complete!" -ForegroundColor Green + Write-Host "DSCv3 install complete" - name: Verify DSCv3 shell: pwsh run: | - Write-Host "Running DSCv3 to validate correct operation..." -ForegroundColor Green + Write-Host "Running DSCv3 to validate correct operation..." dsc --version - name: Install .NET Tools shell: pwsh run: | - Write-Host 'Installing/Updating .NET tools...' -ForegroundColor Green + Write-Host 'Installing/Updating .NET tools...' # Install GitVersion for semantic versioning (idempotent) dotnet tool update --global GitVersion.Tool --version 5.* ` @@ -171,30 +170,30 @@ jobs: # Verify installation dotnet-gitversion /version - Write-Host '.NET tools ready.' -ForegroundColor Green + Write-Host '.NET tools ready.' - name: Verify GitVersion shell: pwsh run: | - Write-Host 'Running GitVersion to determine semantic version...' -ForegroundColor Green + Write-Host 'Running GitVersion to determine semantic version...' dotnet-gitversion - Write-Host 'Running GitVersion to determine semantic version (parsing to PowerShell object)...' -ForegroundColor Green + Write-Host 'Running GitVersion to determine semantic version (parsing to PowerShell object)...' dotnet-gitversion | ConvertFrom-Json - name: Resolve Dependencies shell: pwsh run: | - Write-Host 'Resolving project dependencies...' -ForegroundColor Green + Write-Host 'Resolving project dependencies...' # Run dependency resolution ./build.ps1 -ResolveDependency -Tasks 'noop' -UseModuleFast -ErrorAction Stop - Write-Host 'Dependencies resolved successfully.' -ForegroundColor Green + Write-Host 'Dependencies resolved successfully.' - name: Build Module shell: pwsh run: | - Write-Host "Building $env:MODULE_NAME module..." -ForegroundColor Green + Write-Host "Building $env:MODULE_NAME module..." # Build the module ./build.ps1 -Tasks 'build' -ErrorAction Stop @@ -202,7 +201,7 @@ jobs: # Verify build output if (Test-Path -Path "output/builtModule/$env:MODULE_NAME") { - Write-Host "Module built successfully at: output/builtModule/$env:MODULE_NAME" -ForegroundColor Green + Write-Host "Module built successfully at: output/builtModule/$env:MODULE_NAME" Get-ChildItem -Path "output/builtModule/$env:MODULE_NAME" -Recurse | Select-Object Name, Length | Format-Table } else @@ -214,7 +213,7 @@ jobs: - name: Import Built Module shell: pwsh run: | - Write-Host "Importing built $env:MODULE_NAME module..." -ForegroundColor Green + Write-Host "Importing built $env:MODULE_NAME module..." ./build.ps1 -Tasks 'noop' Import-Module -Name $env:MODULE_NAME -Force @@ -224,28 +223,28 @@ jobs: 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 + Write-Host 'Module imported successfully:' + Write-Host " Name: $($module.Name)" + Write-Host " Version: $($module.Version)" + Write-Host " Path: $($module.Path)" # Show available commands $commands = @(Get-Command -Module $env:MODULE_NAME) if ($commands.Count -gt 0) { - Write-Host " Exported Commands: $($commands.Count)" -ForegroundColor Cyan - Write-Host 'Available Commands:' -ForegroundColor Cyan + Write-Host " Exported Commands: $($commands.Count)" + Write-Host 'Available Commands:' $commands | Select-Object Name, ModuleName | Format-Table -AutoSize } else { - Write-Host 'No commands exported by the module.' -ForegroundColor Yellow + Write-Host 'No commands exported by the module.' } $dscResources = @(dsc resource list --adapter Microsoft.DSC/PowerShell --output-format json | ConvertFrom-Json) - Write-Host " Available class-based DSC Resources: $($dscResources.Count)" -ForegroundColor Cyan + Write-Host " Available class-based DSC Resources: $($dscResources.Count)" $dscResources } else From 83d5844489bffd012d4a0f3469b427773d0475e9 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 12:21:11 +0200 Subject: [PATCH 22/28] Format output of available DSC resources for improved readability --- .github/workflows/copilot-setup-steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 251f04dd86..ba98ee9c42 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -245,7 +245,7 @@ jobs: $dscResources = @(dsc resource list --adapter Microsoft.DSC/PowerShell --output-format json | ConvertFrom-Json) Write-Host " Available class-based DSC Resources: $($dscResources.Count)" - $dscResources + $dscResources | Format-Table type, capabilities, implementedAs, requireAdapter -GroupBy kind } else { From c1acde09e464e569216d7dc85ca3cd7685c7ab74 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 12:23:35 +0200 Subject: [PATCH 23/28] Improve output formatting for available DSC resources in setup steps --- .github/workflows/copilot-setup-steps.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index ba98ee9c42..5a6987e1da 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -233,7 +233,7 @@ jobs: if ($commands.Count -gt 0) { Write-Host " Exported Commands: $($commands.Count)" - Write-Host 'Available Commands:' + Write-Host "`nAvailable Commands:" $commands | Select-Object Name, ModuleName | Format-Table -AutoSize @@ -244,7 +244,7 @@ jobs: } $dscResources = @(dsc resource list --adapter Microsoft.DSC/PowerShell --output-format json | ConvertFrom-Json) - Write-Host " Available class-based DSC Resources: $($dscResources.Count)" + Write-Host "`n Available class-based DSC Resources: $($dscResources.Count)`n" $dscResources | Format-Table type, capabilities, implementedAs, requireAdapter -GroupBy kind } else From 1f4c9aa814aec92b9b737fe168e113df82f7c69e Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 12:26:53 +0200 Subject: [PATCH 24/28] Enhance output formatting of available DSC resources for improved readability --- .github/workflows/copilot-setup-steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 5a6987e1da..a49ba48b43 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -245,7 +245,7 @@ jobs: $dscResources = @(dsc resource list --adapter Microsoft.DSC/PowerShell --output-format json | ConvertFrom-Json) Write-Host "`n Available class-based DSC Resources: $($dscResources.Count)`n" - $dscResources | Format-Table type, capabilities, implementedAs, requireAdapter -GroupBy kind + $dscResources | Format-Table type, capabilities, implementedAs, requireAdapter -GroupBy kind -AutoSize } else { From 0011ba8f27c68e7a37eef370b30f6f76a0b7aa59 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 12:56:58 +0200 Subject: [PATCH 25/28] Enhance development dependency installation and output verification in Copilot setup steps --- .github/workflows/copilot-setup-steps.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index a49ba48b43..5f858031f8 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -112,8 +112,8 @@ jobs: echo "::endgroup::" echo "::group::Installing additional development dependencies..." - echo "Installing development dependencies (libc6-dev, libssl-dev)..." - sudo apt-get install -y libc6-dev libssl-dev + echo "Installing development dependencies..." + sudo apt-get install -y libc6-dev libssl-dev tree echo "Development dependencies installed successfully" echo "::endgroup::" @@ -199,10 +199,16 @@ jobs: ./build.ps1 -Tasks 'build' -ErrorAction Stop # Verify build output - if (Test-Path -Path "output/builtModule/$env:MODULE_NAME") + $builtPath = "output/builtModule/$env:MODULE_NAME" + if (Test-Path -Path $builtPath) { - Write-Host "Module built successfully at: output/builtModule/$env:MODULE_NAME" - Get-ChildItem -Path "output/builtModule/$env:MODULE_NAME" -Recurse | Select-Object Name, Length | Format-Table + Write-Host "Module built successfully at: $builtPath" + # Show files with paths relative to the built module base path using `tree` (run directly in PowerShell) + $base = (Resolve-Path -Path $builtPath).ProviderPath + Write-Host "Files under $base (relative paths):" + + # Run tree directly and strip leading './' from its output + tree --noreport $builtPath } else { From b43659500f3efc67c89712c807b1f302241423c6 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 13:02:18 +0200 Subject: [PATCH 26/28] Add error handling for apt-get update and improve environment variable setting --- .github/workflows/copilot-setup-steps.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 5f858031f8..31392918b8 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -88,7 +88,9 @@ jobs: # Update package list again after adding the new repo echo "Updating package list after adding Microsoft repository..." - sudo apt-get update + if ! sudo apt-get update; then + echo "::warning::apt-get update failed after adding Microsoft repo (repo may be unavailable for this distro). Continuing..." + fi echo "Microsoft repository added successfully" echo "::endgroup::" else @@ -119,7 +121,7 @@ jobs: # Set LD_LIBRARY_PATH permanently for the runner session echo "Setting LD_LIBRARY_PATH environment variable..." - echo "LD_LIBRARY_PATH=/opt/omi/lib:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}" >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=/opt/omi/lib:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}" >> "$GITHUB_ENV" echo "Environment variable set successfully" echo "Linux dependencies installed successfully" From 76a40720c3f46476e50488673bb900ec80460372 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 13:04:47 +0200 Subject: [PATCH 27/28] Update cSpell ignore list for improved spell checking in workflow --- .github/workflows/copilot-setup-steps.yml | 2 +- .vscode/settings.json | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 31392918b8..24d1cce9a8 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -14,7 +14,7 @@ on: paths: - '.github/workflows/copilot-setup-steps.yml' -# cSpell: ignore unshallow LASTEXITCODE PSDSC +# cSpell: ignore unshallow LASTEXITCODE PSDSC noreport dearmor distro keyrings endgroup libmi libc jobs: copilot-setup-steps: name: Setup PowerShell Development Environment diff --git a/.vscode/settings.json b/.vscode/settings.json index 90ac866b91..1e6fedf669 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -89,13 +89,7 @@ "wsfc", "SOURCEBRANCH", "SOURCEBRANCHNAME", - "setvariable", - "libmi", - "libc", - "endgroup", - "keyrings", - "distro", - "dearmor" + "setvariable" ], "cSpell.ignorePaths": [ ".git" From bf318ead63fc0ec36a0f4e4cce1b73421e55bfe0 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 20 Aug 2025 13:07:52 +0200 Subject: [PATCH 28/28] Ensure gpg is available by installing gnupg in the setup steps --- .github/workflows/copilot-setup-steps.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 24d1cce9a8..58d38c87c8 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -75,6 +75,9 @@ jobs: echo "Package list updated successfully" echo "::endgroup::" + # Ensure gpg is available + sudo apt-get install -y gnupg + # Check if Microsoft repository is already added, if not add it if ! grep -q "packages.microsoft.com" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then echo "::group::Add Microsoft repository"