Skip to content

init

init #22

name: "PSScriptAnalyzer CI workflow windows"
on:
push:
branches: [ test ]
jobs:
windows-latest-pwsh-scripts:
name: "pwsh scripts - windows-latest Microsoft Windows Server 2019 Datacenter"
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: "powershell version"
run: |
$PSVersionTable
pwsh
- name: "Install PSScriptAnalyzer module"
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -ErrorAction Stop
- name: "Lint with PSScriptAnalyzer"
shell: pwsh
run: |
Write-Host $(Join-Path -Path $(Get-Location) -ChildPath "\scripts\*.ps1")
$workdir = $(Join-Path -Path $(Get-Location) -ChildPath "\scripts\*.ps1")
Write-Host $workdir
Invoke-ScriptAnalyzer -Path $workdir -Recurse -Outvariable issues
$errors = $issues.Where({$_.Severity -eq 'Error'})
$warnings = $issues.Where({$_.Severity -eq 'Warning'})
if ($errors) {
Write-Error "There were $($errors.Count) errors and $($warnings.Count) warnings total." -ErrorAction Stop
} else {
Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total."
}
install-dependencies:
name: "Install from PSGallery windows latest"
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: "powershell version"
run: $PSVersionTable
- name: "Install from PSGallery"
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module SqlServer, PSScriptAnalyzer
# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-powershell
lint-with-PSScriptAnalyzer:
name: "Install and run PSScriptAnalyzer windows latest"
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: "powershell version"
run: $PSVersionTable
- name: "Install PSScriptAnalyzer module"
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -ErrorAction Stop
- name: "Lint with PSScriptAnalyzer"
shell: pwsh
run: |
Invoke-ScriptAnalyzer -Path *.ps1 -Recurse -Outvariable issues
$errors = $issues.Where({$_.Severity -eq 'Error'})
$warnings = $issues.Where({$_.Severity -eq 'Warning'})
if ($errors) {
Write-Error "There were $($errors.Count) errors and $($warnings.Count) warnings total." -ErrorAction Stop
} else {
Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total."
}
windows-latest-PSScriptAnalyzer-build:
name: "build from source - windows-latest Microsoft Windows Server 2019 Datacenter"
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: "powershell version"
run: $PSVersionTable
# https://github.com/PowerShell/PSScriptAnalyzer#usage
- name: "git clone PSScriptAnalyzer module"
shell: pwsh
run: |
$PSVersionTable
git clone https://github.com/PowerShell/PSScriptAnalyzer
cd PSScriptAnalyzer
.\build.ps1 -PSVersion 7
.\build.ps1 -Documentation #Rebuild documentation since it gets built automatically only the first time
Get-ScriptAnalyzerRule #confirm installation
pester-psscriptanalyzer:
name: "Pester-based PSScriptAnalyzer Tests windows latest"
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: "powershell version"
run: $PSVersionTable
# https://github.com/PowerShell/PSScriptAnalyzer#usage
- name: "git clone PSScriptAnalyzer module"
shell: pwsh
run: |
$PSVersionTable
git clone https://github.com/PowerShell/PSScriptAnalyzer
cd PSScriptAnalyzer
.\build.ps1 -PSVersion 7
.\build.ps1 -Documentation #Rebuild documentation since it gets built automatically only the first time
Get-ScriptAnalyzerRule #confirm installation
./build -Test
# Import-Module ./build.psm1
# Get-TestResults
# Import-Module ./build.psm1
# Get-TestFailures