Files
AWatch-rus/.github/workflows/ci.yml
T

62 lines
1.9 KiB
YAML

name: shell-and-powershell-ci
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
shell-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install shellcheck
run: sudo apt-get update && sudo apt-get install -y shellcheck
- name: Run shellcheck
run: |
find . -type f -name "*.sh" -print0 | xargs -0 -r shellcheck -e SC1007,SC1090,SC2016
powershell-analyzer:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -Scope CurrentUser -Force
- name: Analyze PowerShell scripts
shell: pwsh
run: |
$targets = @(
"windows/*.ps1",
"windows/*.psm1",
"windows/*.psd1"
)
$settings = @{
Rules = @{
PSAvoidUsingEmptyCatchBlock = @{ Enable = $false }
PSAvoidUsingWriteHost = @{ Enable = $false }
PSUseApprovedVerbs = @{ Enable = $false }
PSUseBOMForUnicodeEncodedFile = @{ Enable = $false }
PSUseDeclaredVarsMoreThanAssignments = @{ Enable = $false }
PSUseShouldProcessForStateChangingFunctions = @{ Enable = $false }
PSUseSingularNouns = @{ Enable = $false }
PSUseToExportFieldsInManifest = @{ Enable = $false }
}
}
$issues = $targets | ForEach-Object {
Invoke-ScriptAnalyzer -Path $_ -Recurse -Severity Error,Warning -Settings $settings
}
if ($issues) {
$issues | Format-Table -AutoSize
throw "PSScriptAnalyzer detected issues."
}