New workflow to check WAU installation and first run

pull/309/head
Fabian Seitz 2023-03-30 11:30:55 +02:00
parent 1e318f6668
commit 9b01832750
1 changed files with 61 additions and 0 deletions

61
.github/workflows/powershell-tests.yaml vendored Normal file
View File

@ -0,0 +1,61 @@
name: WAU PS Test
# yamllint disable-line rule:truthy
on:
push:
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:
permissions:
contents: read
pull-requests: read
jobs:
powershell-tests:
name: Pester test and PSScriptAnalyzer
runs-on: windows-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Perform a Pester test for the WAU installation
shell: powershell
run: |
$command = New-PesterContainer -Path Winget-AutoUpdate-Install.ps1 -Data @{ Silent = $true }
Invoke-Pester -PassThru -Container $command -ErrorAction Continue
- name: Perform a Pester test for WAU run
shell: powershell
run: |
$command = New-PesterContainer -Path C:\ProgramData\Winget-AutoUpdate\user-run.ps1
Invoke-Pester -PassThru -Container $command -ErrorAction Continue
#- name: Read WAU Log
# id: package
# uses: juliangruber/read-file-action@v1
# with:
# path: 'C:\ProgramData\Winget-AutoUpdate\Logs\updates.log'
#- name: Display WAU Log
# run: type "${{ steps.package.outputs.content }}"
- name: Install PSScriptAnalyzer module from PSGallery
shell: powershell
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -ErrorAction Stop
- name: Lint with PSScriptAnalyzer
shell: powershell
run: |
Invoke-ScriptAnalyzer -Path *.ps1 -Recurse -Outvariable issues
$errors = $issues.Where({$_.Severity -eq 'Error'})
$warnings = $issues.Where({$_.Severity -eq 'Warning'})
if ($($errors.Count) -gt 0) {
$ErrorAction = "Stop"
} else {
$ErrorAction = "Continue"
}
if ($errors) {
Write-Error "There were $($errors.Count) errors and $($warnings.Count) warnings total." -ErrorAction $ErrorAction
} else {
Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total."
}