Repository navigation
Add CI to check the scripts - #4
Conversation
Nothing runs against this repo today. A syntax error here breaks symbol upload in obs-studio, obs-studio-node, a-files-updater and crash-handler, and nobody finds out until a release build fails. Three checks on every PR: - Parse every .ps1 under Windows PowerShell 5.1. main.bat invokes powershell.exe, so 5.1 is the runtime that has to accept these files; parsing clean under pwsh 7 is a weaker guarantee. - Confirm the scripts main.ps1 calls by relative path are still there, so a rename fails review instead of a release. - PSScriptAnalyzer, failing only on Error severity. The analyzer excludes three rules that are structurally wrong for this repo: Write-Host is how these scripts talk to the CI log, the parameters it reports as unused are read at script scope from inside functions, and trailing whitespace is noise. Current state is 14 warnings, 0 errors. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new GitHub Actions workflow to validate the repository’s PowerShell scripts on PRs and pushes to main, to catch breakages (syntax, missing companion scripts, and analyzer errors) during review rather than at release time.
Changes:
- Introduces a Windows-based CI job that parses all
*.ps1under Windows PowerShell 5.1. - Adds a check ensuring
main.ps1and its companion scripts/files are present at expected relative paths. - Runs PSScriptAnalyzer and fails the workflow only on
Error-severity findings (while still emitting annotations for warnings).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Install-Module PSScriptAnalyzer -Force -Scope CurrentUser -AllowClobber | ||
| Import-Module PSScriptAnalyzer |
There was a problem hiding this comment.
Taking this. $ErrorActionPreference = Stop plus -ErrorAction Stop on both, and an explicit Get-Command Invoke-ScriptAnalyzer guard afterwards.
The failure mode worth naming: a quiet install failure would not just skip the check, it would report a clean run against zero files — a green tick that means nothing. Fixed in bee6e09.
An install or import that failed quietly would leave the step reporting a clean run against zero files, which is worse than having no check. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
.github/workflows/check-scripts.yml:70
Install-Module PSScriptAnalyzerinstalls the latest version at run time, which makes this CI check non-reproducible (a new upstream release can change rules/severity and start failing PRs without any repo change). Consider pinning to a known-good version (and bump it intentionally) so the workflow stays stable.
Install-Module PSScriptAnalyzer -Force -Scope CurrentUser -AllowClobber -ErrorAction Stop
Import-Module PSScriptAnalyzer -ErrorAction Stop
Description
Adds
.github/workflows/check-scripts.yml. Three checks on every PR and push tomain:.ps1under Windows PowerShell 5.1.main.batinvokespowershell.exe, so 5.1 is the runtime that actually has to accept these files — parsing clean under pwsh 7 is a weaker guarantee.main.ps1callsgithub-sourceindexer.ps1ands3upload.ps1by relative path, so a rename should fail review, not a release.Errorseverity.Motivation and Context
Nothing runs against this repo today. A syntax error here breaks symbol upload in four repos — obs-studio, obs-studio-node, a-files-updater, crash-handler — and nobody finds out until a release build fails, because it is only reached on tag builds.
The analyzer excludes three rules that are structurally wrong for this repo rather than genuine findings:
PSAvoidUsingWriteHostWrite-Hostis how these scripts talk to the CI logPSReviewUnusedParametergithub-sourceindexer.ps1reads those params at script scope from inside its functionsPSAvoidTrailingWhitespaceWarnings are surfaced as annotations but do not fail the build, so this lands green and stays useful rather than being switched off in a month.
How Has This Been Tested?
Ran both steps locally against this repo, on Windows PowerShell 5.1.26100:
Remaining warnings, none of which fail the build: 9
PSPossibleIncorrectComparisonWithNull, 3PSUseSingularNouns, 1PSPossibleIncorrectUsageOfRedirectionOperator(a false positive on2>$null), 1PSUseShouldProcessForStateChangingFunctions. The null-comparison ones are addressed in the follow-up maintenance PR.actionlinton the new workflow: clean.Types of changes
Checklist: