diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91f06ff..05280b1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - ci/testing-ps tags: - v* pull_request: @@ -13,7 +14,7 @@ on: jobs: test: - name: πŸ› οΈ Build and Test + name: πŸ› οΈ Build and Test C# runs-on: ubuntu-latest permissions: contents: read @@ -61,6 +62,64 @@ jobs: if: always() run: dotnet format --verify-no-changes + testps: + name: πŸ› οΈ Build and Test PowerShell + runs-on: ubuntu-latest + permissions: + contents: read + issues: read + checks: write + steps: + - name: πŸ‘¨β€πŸ’» Check-out code + uses: actions/checkout@v4 + + - name: πŸ‘¨β€πŸ”§ Setup .NET Core SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x + + - name: πŸ” Enable problem matchers + run: echo "::add-matcher::.github/matchers/dotnet.json" + + - name: πŸ¦Έβ€β™‚οΈ Restore steriods + uses: actions/cache@v4 + with: + path: ~/.nuget/packages + # Look to see if there is a cache hit for the corresponding requirements file + key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: | + ${{ runner.os }}-nuget + + - name: πŸŽ’ Load packages + run: dotnet restore + + - name: πŸ› οΈ Build module + shell: pwsh + run: dotnet build ./src/Svrooij.WinTuner.CmdLets/Svrooij.WinTuner.CmdLets.csproj --configuration Release --no-restore -p:Version=$("${{ github.ref_name }}".Substring(1)) -o ./dist/WinTuner + + - name: πŸ“¦ Install Pester + run: Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser + + - name: πŸ•΅οΈ Import module and list commands + shell: pwsh + run: | + Import-Module ./dist/WinTuner/WinTuner.psd1 + Get-Command -Module WinTuner + Get-Command -Module WinTuner | Select-Object -ExpandProperty Name | ForEach-Object { Get-Help -Name $_ -Full } + + - name: πŸ§ͺ Run test + shell: pwsh + run: + Import-Module Pester + Import-Module ./dist/WinTuner/WinTuner.psd1 + ./tests/run.ps1 + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + files: ./TestResults.xml + publish-nuget: name: πŸ“¦ Publish WinTuner to nuget runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index db8019b..f43c980 100644 --- a/.gitignore +++ b/.gitignore @@ -367,3 +367,5 @@ dist # LUT config file from Visual Studio *.lutconfig + +TestResults.xml \ No newline at end of file diff --git a/src/Svrooij.WinTuner.CmdLets/WinTuner.psd1 b/src/Svrooij.WinTuner.CmdLets/WinTuner.psd1 index 326d712..d3849cf 100644 --- a/src/Svrooij.WinTuner.CmdLets/WinTuner.psd1 +++ b/src/Svrooij.WinTuner.CmdLets/WinTuner.psd1 @@ -58,15 +58,15 @@ # FunctionsToExport = @() # Cmdlets to export from this module. - CmdletsToExport = @( - "Deploy-WtWin32App", - "Get-WtWin32Apps", - "New-IntuneWinPackage", - "New-WtWingetPackage", - "Remove-WtWin32App", - "Unprotect-IntuneWinPackage" - "Update-WtIntuneApp" - ) + # CmdletsToExport = @( + # "Deploy-WtWin32App", + # "Get-WtWin32Apps", + # "New-IntuneWinPackage", + # "New-WtWingetPackage", + # "Remove-WtWin32App", + # "Unprotect-IntuneWinPackage" + # "Update-WtIntuneApp" + # ) # Variables to export from this module. # VariablesToExport = @() diff --git a/tests/WinTuner.Cmdlets.Tests/Deploy-WtMsStoreApp.Tests.ps1 b/tests/WinTuner.Cmdlets.Tests/Deploy-WtMsStoreApp.Tests.ps1 new file mode 100644 index 0000000..e69dcc2 --- /dev/null +++ b/tests/WinTuner.Cmdlets.Tests/Deploy-WtMsStoreApp.Tests.ps1 @@ -0,0 +1,6 @@ +Describe 'Deploy-WtMsStoreApp' { + It 'Should be available' { + $cmdlet = Get-Command -Name 'Deploy-WtMsStoreApp' + $cmdlet.CommandType | Should -Be 'Cmdlet' + } +} \ No newline at end of file diff --git a/tests/WinTuner.Cmdlets.Tests/Deploy-WtWin32App.Tests.ps1 b/tests/WinTuner.Cmdlets.Tests/Deploy-WtWin32App.Tests.ps1 new file mode 100644 index 0000000..2ce8cc2 --- /dev/null +++ b/tests/WinTuner.Cmdlets.Tests/Deploy-WtWin32App.Tests.ps1 @@ -0,0 +1,6 @@ +Describe 'Deploy-WtWin32App' { + It 'Should be available' { + $cmdlet = Get-Command -Name 'Deploy-WtWin32App' + $cmdlet.CommandType | Should -Be 'Cmdlet' + } +} \ No newline at end of file diff --git a/tests/WinTuner.Cmdlets.Tests/Get-WtWin32Apps.Tests.ps1 b/tests/WinTuner.Cmdlets.Tests/Get-WtWin32Apps.Tests.ps1 new file mode 100644 index 0000000..f9bc6b1 --- /dev/null +++ b/tests/WinTuner.Cmdlets.Tests/Get-WtWin32Apps.Tests.ps1 @@ -0,0 +1,6 @@ +Describe 'Get-WtWin32Appsp' { + It 'Should be available' { + $cmdlet = Get-Command -Name 'Get-WtWin32Apps' + $cmdlet.CommandType | Should -Be 'Cmdlet' + } +} \ No newline at end of file diff --git a/tests/WinTuner.Cmdlets.Tests/New-IntuneWinPackage.ps1 b/tests/WinTuner.Cmdlets.Tests/New-IntuneWinPackage.ps1 new file mode 100644 index 0000000..4d32b28 --- /dev/null +++ b/tests/WinTuner.Cmdlets.Tests/New-IntuneWinPackage.ps1 @@ -0,0 +1,6 @@ +Describe 'New-IntuneWinPackage' { + It 'Should be available' { + $cmdlet = Get-Command -Name 'New-IntuneWinPackage' + $cmdlet.CommandType | Should -Be 'Cmdlet' + } +} \ No newline at end of file diff --git a/tests/WinTuner.Cmdlets.Tests/NewWtWingetPackage.Tests.ps1 b/tests/WinTuner.Cmdlets.Tests/NewWtWingetPackage.Tests.ps1 new file mode 100644 index 0000000..de3a223 --- /dev/null +++ b/tests/WinTuner.Cmdlets.Tests/NewWtWingetPackage.Tests.ps1 @@ -0,0 +1,6 @@ +Describe 'New-WtWingetPackage' { + It 'Should be available' { + $cmdlet = Get-Command -Name 'New-WtWingetPackage' + $cmdlet.CommandType | Should -Be 'Cmdlet' + } +} \ No newline at end of file diff --git a/tests/WinTuner.Cmdlets.Tests/RemoveWtWin32App.Tests.ps1 b/tests/WinTuner.Cmdlets.Tests/RemoveWtWin32App.Tests.ps1 new file mode 100644 index 0000000..17f6915 --- /dev/null +++ b/tests/WinTuner.Cmdlets.Tests/RemoveWtWin32App.Tests.ps1 @@ -0,0 +1,6 @@ +Describe 'Remove-WtWin32App' { + It 'Should be available' { + $cmdlet = Get-Command -Name 'Remove-WtWin32App' + $cmdlet.CommandType | Should -Be 'Cmdlet' + } +} \ No newline at end of file diff --git a/tests/WinTuner.Cmdlets.Tests/Unprotect-IntuneWinPackage.ps1 b/tests/WinTuner.Cmdlets.Tests/Unprotect-IntuneWinPackage.ps1 new file mode 100644 index 0000000..a0e6ffc --- /dev/null +++ b/tests/WinTuner.Cmdlets.Tests/Unprotect-IntuneWinPackage.ps1 @@ -0,0 +1,6 @@ +Describe 'Unprotect-IntuneWinPackage' { + It 'Should be available' { + $cmdlet = Get-Command -Name 'Unprotect-IntuneWinPackage' + $cmdlet.CommandType | Should -Be 'Cmdlet' + } +} \ No newline at end of file diff --git a/tests/WinTuner.Cmdlets.Tests/Update-WtIntuneApp.ps1 b/tests/WinTuner.Cmdlets.Tests/Update-WtIntuneApp.ps1 new file mode 100644 index 0000000..1ae2abb --- /dev/null +++ b/tests/WinTuner.Cmdlets.Tests/Update-WtIntuneApp.ps1 @@ -0,0 +1,6 @@ +Describe 'Update-WtIntuneApp' { + It 'Should be available' { + $cmdlet = Get-Command -Name 'Update-WtIntuneApp' + $cmdlet.CommandType | Should -Be 'Cmdlet' + } +} \ No newline at end of file diff --git a/tests/WinTuner.Cmdlets.Tests/run.ps1 b/tests/WinTuner.Cmdlets.Tests/run.ps1 new file mode 100644 index 0000000..164b978 --- /dev/null +++ b/tests/WinTuner.Cmdlets.Tests/run.ps1 @@ -0,0 +1,20 @@ +$pesterConfig = [PesterConfiguration]@{ + Output = @{ + Verbosity = "Normal" + } + OutputFormat = "NUnitXML" + TestResult = @{ + Enabled = $true + Path = "TestResults.xml" + Format = "NUnitXML" + } + Run = @{ + Path = "./tests/WinTuner.Cmdlets.Tests" + Exit = $true + } + Should = @{ + ErrorAction = "Continue" + } +} + +Invoke-Pester -Configuration $pesterConfig \ No newline at end of file