From d4670635c5096b3d1324a93a46225bceb4db06f3 Mon Sep 17 00:00:00 2001 From: ASVLCII Date: Thu, 15 Oct 2026 18:07:45 +0700 Subject: [PATCH] ci: add Windows launcher and script checks --- .github/workflows/checks.yml | 28 ++++++++++++++++++++++++++++ README.md | 11 +++++++++++ scripts/check-powershell-syntax.ps1 | 28 ++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 .github/workflows/checks.yml create mode 100644 scripts/check-powershell-syntax.ps1 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..ea99f47 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,28 @@ +name: Source checks + +on: + push: + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + checks: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: cmd/launcher/go.mod + cache: false + - name: Test launcher + working-directory: cmd/launcher + run: go test ./... + - name: Vet launcher + working-directory: cmd/launcher + run: go vet ./... + - name: Check PowerShell syntax + shell: pwsh + run: ./scripts/check-powershell-syntax.ps1 diff --git a/README.md b/README.md index a20ec41..099c139 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,17 @@ cd cmd/launcher go test ./... ``` +GitHub Actions runs launcher tests, `go vet`, and PowerShell syntax checks on +Windows for pushes and pull requests. These checks use source files only; they +do not download or package Firefox or uBlock Origin. Run the same syntax check +locally from the repository root: + +```powershell +pwsh -File scripts/check-powershell-syntax.ps1 +``` + +The syntax check parses scripts without executing their packaging operations. + ## Licensing The Nano Origin-original files in this repository are MIT licensed; see [LICENSE](LICENSE). diff --git a/scripts/check-powershell-syntax.ps1 b/scripts/check-powershell-syntax.ps1 new file mode 100644 index 0000000..f9c492a --- /dev/null +++ b/scripts/check-powershell-syntax.ps1 @@ -0,0 +1,28 @@ +[CmdletBinding()] +param( + [string]$ScriptsPath = $PSScriptRoot +) + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version Latest + +$scripts = @(Get-ChildItem -LiteralPath $ScriptsPath -Filter '*.ps1' -File -Recurse) +if ($scripts.Count -eq 0) { throw "No PowerShell scripts found in: $ScriptsPath" } + +$invalid = 0 +foreach ($script in $scripts) { + $tokens = $null + $parseErrors = $null + $null = [System.Management.Automation.Language.Parser]::ParseFile( + $script.FullName, [ref]$tokens, [ref]$parseErrors + ) + foreach ($parseError in $parseErrors) { + $invalid++ + Write-Host ('{0}:{1}:{2}: {3}' -f $script.FullName, + $parseError.Extent.StartLineNumber, $parseError.Extent.StartColumnNumber, + $parseError.Message) + } +} + +if ($invalid -gt 0) { throw "Found $invalid PowerShell parse error(s)." } +Write-Host "PowerShell syntax passed for $($scripts.Count) scripts."