Skip to content

Commit

Permalink
ci: First try to test powershell module
Browse files Browse the repository at this point in the history
  • Loading branch information
svrooij committed May 4, 2024
1 parent d5488ed commit 90d62ba
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 10 deletions.
61 changes: 60 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- ci/testing-ps
tags:
- v*
pull_request:
Expand All @@ -13,7 +14,7 @@ on:

jobs:
test:
name: 🛠️ Build and Test
name: 🛠️ Build and Test C#
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,5 @@ dist

# LUT config file from Visual Studio
*.lutconfig

TestResults.xml
18 changes: 9 additions & 9 deletions src/Svrooij.WinTuner.CmdLets/WinTuner.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @()
Expand Down
6 changes: 6 additions & 0 deletions tests/WinTuner.Cmdlets.Tests/Deploy-WtMsStoreApp.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Describe 'Deploy-WtMsStoreApp' {
It 'Should be available' {
$cmdlet = Get-Command -Name 'Deploy-WtMsStoreApp'
$cmdlet.CommandType | Should -Be 'Cmdlet'
}
}
6 changes: 6 additions & 0 deletions tests/WinTuner.Cmdlets.Tests/Deploy-WtWin32App.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Describe 'Deploy-WtWin32App' {
It 'Should be available' {
$cmdlet = Get-Command -Name 'Deploy-WtWin32App'
$cmdlet.CommandType | Should -Be 'Cmdlet'
}
}
6 changes: 6 additions & 0 deletions tests/WinTuner.Cmdlets.Tests/Get-WtWin32Apps.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Describe 'Get-WtWin32Appsp' {
It 'Should be available' {
$cmdlet = Get-Command -Name 'Get-WtWin32Apps'
$cmdlet.CommandType | Should -Be 'Cmdlet'
}
}
6 changes: 6 additions & 0 deletions tests/WinTuner.Cmdlets.Tests/New-IntuneWinPackage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Describe 'New-IntuneWinPackage' {
It 'Should be available' {
$cmdlet = Get-Command -Name 'New-IntuneWinPackage'
$cmdlet.CommandType | Should -Be 'Cmdlet'
}
}
6 changes: 6 additions & 0 deletions tests/WinTuner.Cmdlets.Tests/NewWtWingetPackage.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Describe 'New-WtWingetPackage' {
It 'Should be available' {
$cmdlet = Get-Command -Name 'New-WtWingetPackage'
$cmdlet.CommandType | Should -Be 'Cmdlet'
}
}
6 changes: 6 additions & 0 deletions tests/WinTuner.Cmdlets.Tests/RemoveWtWin32App.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Describe 'Remove-WtWin32App' {
It 'Should be available' {
$cmdlet = Get-Command -Name 'Remove-WtWin32App'
$cmdlet.CommandType | Should -Be 'Cmdlet'
}
}
6 changes: 6 additions & 0 deletions tests/WinTuner.Cmdlets.Tests/Unprotect-IntuneWinPackage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Describe 'Unprotect-IntuneWinPackage' {
It 'Should be available' {
$cmdlet = Get-Command -Name 'Unprotect-IntuneWinPackage'
$cmdlet.CommandType | Should -Be 'Cmdlet'
}
}
6 changes: 6 additions & 0 deletions tests/WinTuner.Cmdlets.Tests/Update-WtIntuneApp.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Describe 'Update-WtIntuneApp' {
It 'Should be available' {
$cmdlet = Get-Command -Name 'Update-WtIntuneApp'
$cmdlet.CommandType | Should -Be 'Cmdlet'
}
}
20 changes: 20 additions & 0 deletions tests/WinTuner.Cmdlets.Tests/run.ps1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 90d62ba

Please sign in to comment.