Skip to content

Add CI to check the scripts - #4

Merged
summeroff merged 2 commits into
mainfrom
ci/add-script-checks
Jul 28, 2026
Merged

summeroff merged 2 commits into
mainfrom
ci/add-script-checks

Conversation

@summeroff

Copy link
Copy Markdown
Contributor

Description

Adds .github/workflows/check-scripts.yml. Three checks on every PR and push to main:

  • Parse every .ps1 under Windows PowerShell 5.1. main.bat invokes powershell.exe, so 5.1 is the runtime that actually has to accept these files — parsing clean under pwsh 7 is a weaker guarantee.
  • Confirm the partner scripts resolve. main.ps1 calls github-sourceindexer.ps1 and s3upload.ps1 by relative path, so a rename should fail review, not a release.
  • PSScriptAnalyzer, failing only on Error severity.

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:

Rule Why excluded
PSAvoidUsingWriteHost Write-Host is how these scripts talk to the CI log
PSReviewUnusedParameter The 7 hits are false — github-sourceindexer.ps1 reads those params at script scope from inside its functions
PSAvoidTrailingWhitespace Noise; fixing it would bury real diffs

Warnings 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:

OK   github-sourceindexer.ps1
OK   main.ps1
OK   s3upload.ps1
PSVersion: 5.1.26100.8875

PSScriptAnalyzer: 14 finding(s), 0 errors  =>  PASS

Remaining warnings, none of which fail the build: 9 PSPossibleIncorrectComparisonWithNull, 3 PSUseSingularNouns, 1 PSPossibleIncorrectUsageOfRedirectionOperator (a false positive on 2>$null), 1 PSUseShouldProcessForStateChangingFunctions. The null-comparison ones are addressed in the follow-up maintenance PR.

actionlint on the new workflow: clean.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code has been run through clang-format. — n/a, no C++ here
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 *.ps1 under Windows PowerShell 5.1.
  • Adds a check ensuring main.ps1 and 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.

Comment thread .github/workflows/check-scripts.yml Outdated
Comment on lines +65 to +66
Install-Module PSScriptAnalyzer -Force -Scope CurrentUser -AllowClobber
Import-Module PSScriptAnalyzer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PSScriptAnalyzer installs 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

@summeroff
summeroff merged commit f2e377f into main Jul 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants