diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index bdb347a..5636993 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -18,7 +18,8 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.x' + global-json-file: global.json + - name: Restore dependencies run: dotnet restore @@ -30,7 +31,9 @@ jobs: shell: pwsh run: | Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser - Invoke-Pester -Path .\Tests\FindOpenFile.Tests.ps1 -Output Detailed -Configuration @{ Run = @{ Container = New-PesterContainer -Path .\Tests\FindOpenFile.Tests.ps1 -Data @{ Configuration = 'Release' } } } + Invoke-Pester -Path .\Tests\FindOpenFile.Tests.ps1 -Output Detailed + env: + BUILD_CONFIGURATION: Release - name: Upload build artifacts uses: actions/upload-artifact@v4 @@ -49,7 +52,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.x' + dotnet-version: '10.0.x' - name: Build Release run: dotnet build --configuration Release diff --git a/Tests/FindOpenFile.Tests.ps1 b/Tests/FindOpenFile.Tests.ps1 index 6c0131b..7a0eb82 100644 --- a/Tests/FindOpenFile.Tests.ps1 +++ b/Tests/FindOpenFile.Tests.ps1 @@ -1,10 +1,15 @@ -param( - [Parameter()] - [ValidateSet('Debug', 'Release')] - [string]$Configuration = 'Debug' -) - BeforeAll { + # Get configuration from environment variable, default to 'Debug' if not set + $Configuration = $env:BUILD_CONFIGURATION + if ([string]::IsNullOrWhiteSpace($Configuration)) { + $Configuration = 'Debug' + } + + # Validate configuration value + if ($Configuration -notin @('Debug', 'Release')) { + throw "Invalid BUILD_CONFIGURATION value: '$Configuration'. Must be 'Debug' or 'Release'." + } + # Import the module from the specified build configuration directory $modulePath = Join-Path $PSScriptRoot "..\bin\$Configuration\netstandard2.0\FindOpenFile.psd1" diff --git a/global.json b/global.json new file mode 100644 index 0000000..1e7fdfa --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "10.0.100", + "rollForward": "latestMinor" + } +}